This program is invalid because the field in class B should be declared as an external getter/setter:
@JS()
import 'package:js/js.dart';
@JS()
@anonymous
class B {
int Function() callback;
}
external B makeB();
main() {
makeB().callback();
}
Today it produces this crash in the compiler:
The compiler crashed: NoSuchMethodError: Class 'FunctionType' has no instance getter 'element'.
Receiver: Instance of 'FunctionType'
Tried calling: element
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
#1 InferrerEngineImpl.typeOfNativeBehavior (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/inferrer_engine.dart:383:48)
#2 FieldTypeInformation.handleSpecialCases (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart:540:12)
#3 MemberTypeInformation.computeType (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart:487:29)
#4 TypeInformation.refine (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart:149:54)
#5 InferrerEngineImpl.refine (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/inferrer_engine.dart:792:36)
#6 InferrerEngineImpl.runOverAllElements (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/inferrer_engine.dart:489:5)
#7 TypeGraphInferrer.analyzeMain (file:///path/to/sdk/sdk/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart:67:14)
#8 GlobalTypeInferenceTask.runGlobalTypeInference.<anonymous closure> (file:///path/to/sdk/sdk/pkg/compiler/lib/src/types/types.dart:233:29)
#9 CompilerTask.measure (file:///path/to/sdk/sdk/pkg/compiler/lib/src/common/tasks.dart:63:51)
#10 GlobalTypeInferenceTask.runGlobalTypeInference (file:///path/to/sdk/sdk/pkg/compiler/lib/src/types/types.dart:229:12)
#11 Compiler.performGlobalTypeInference (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:383:28)
#12 Compiler.compileLoadedLibraries.<anonymous closure> (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:424:15)
#13 CompilerTask.measureSubtask (file:///path/to/sdk/sdk/pkg/compiler/lib/src/common/tasks.dart:178:35)
#14 Compiler.compileLoadedLibraries (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:420:16)
#15 Compiler.runInternal (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:297:5)
<asynchronous suspension>
#16 Compiler.run.<anonymous closure>.<anonymous closure> (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:223:38)
#17 new Future.sync (dart:async/future.dart:222:31)
#18 Compiler.run.<anonymous closure> (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:223:20)
#19 CompilerTask.measureSubtask (file:///path/to/sdk/sdk/pkg/compiler/lib/src/common/tasks.dart:178:35)
#20 Compiler.run (file:///path/to/sdk/sdk/pkg/compiler/lib/src/compiler.dart:220:41)
#21 CompilerImpl.run.<anonymous closure>.<anonymous closure> (file:///path/to/sdk/sdk/pkg/compiler/lib/src/apiimpl.dart:148:22)
#22 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#23 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#24 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638:45)
#25 Future._propagateToListeners (dart:async/future_impl.dart:667:32)
#26 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:347:9)
#27 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#28 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#29 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:113:13)
#30 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:166:5)
Finished with a exit code: 253
This program is invalid because the field in class
Bshould be declared as an external getter/setter:Today it produces this crash in the compiler: