Skip to content

Bytecode needs to check for type arguments passed to closures in prologue #39283

@mkustermann

Description

@mkustermann

For this example:

class A {
  dynamic foo(a) {
    baz() {
      print('a $a');
    }
    return baz;
  }
}

main() {
  dynamic x = A().foo(1);
  x<List>();
}

Default:

% rm -rf out/ReleaseX64
% tools/build.py -ax64 -mrelease runtime_kernel
% out/ReleaseX64/dart test.dart
Unhandled exception:
NoSuchMethodError: Closure call with mismatched arguments: function 'A.foo.baz'
Receiver: Closure: () => Null
Tried calling: A.foo.baz<List<dynamic>>()
Found: A.foo.baz() => Null
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      main (../test.dart:12:4)
#2      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

Bytecode:

% rm -rf out/ReleaseX64
% tools/gn.py -mrelease --bytecode -ax64
% tools/build.py -ax64 -mrelease runtime_kernel
% out/ReleaseX64/dart test.dart
a 1

^^^ This should have thrown an exception instead.

/cc @alexmarkov @a-siva @mraleph

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions