Open
Description
- Dart SDK Version: 2.7.2 (I tried to test on 2.9.3 but hit Could not find an option named "sound-null-safety" build#2832)
- MacOSX
- Chrome
pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dev_dependencies:
build_runner: any
build_web_compilers: any
js: any
web/main.dart
@JS()
library main;
import 'package:js/js.dart';
@anonymous
@JS()
abstract class Foo {
external String get bar;
external factory Foo({String bar});
factory Foo.namedFactory() => Foo(bar: '!!');
}
void main() {
print(Foo(bar: 'baz').bar); // Prints "baz"
Foo.namedFactory(); // Throws a "NoSuchMethodError"
}
When built with DDC, running the above throws this error:
main.dart:16 Uncaught
NoSuchMethodError: tried to call a non-function, such as null: 'dart.global.Foo' at main.dart 16:28 main$
main$ @ main.dart:16
(anonymous) @ main.dart.bootstrap.js:266
window.$dartRunMain @ main.dart.bootstrap.js:265
(anonymous) @ VM259:1
runMain @ client.js:8758
(anonymous) @ client.js:22459
(anonymous) @ client.js:3802
call$2 @ client.js:10996
_asyncStartSync @ client.js:3766
$call$body$main__closure @ client.js:22471
call$1 @ client.js:22398
_rootRunUnary @ client.js:4136
runUnary$2$2 @ client.js:12301
runUnaryGuarded$1$2 @ client.js:12233
_sendData$1 @ client.js:11784
perform$1 @ client.js:11936
call$0 @ client.js:11985
_microtaskLoop @ client.js:3969
_startMicrotaskLoop @ client.js:3975
call$1 @ client.js:10865
invokeClosure @ client.js:1204
(anonymous) @ client.js:1223
childList (async)
call$1 @ client.js:10875
_scheduleAsyncCallback @ client.js:3989
_rootScheduleMicrotask @ client.js:4183
scheduleMicrotask @ client.js:4018
schedule$1 @ client.js:11967
_addPending$1 @ client.js:11775
_sendData$1 @ client.js:11607
add$1 @ client.js:11507
_onIncomingMessage$1 @ client.js:22011
eval @ VM242:3
invokeClosure @ client.js:1204
(anonymous) @ client.js:1223
This works as expected when building with dart2js.