You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In checked mode (dartc --enable_type_checks), there is a bug in runtime type checking in some cases. Here's a test that exercises it
TypeChecksInFactoryMethods.dart
interface Foo<T> default Bar {
Foo.from();
}
class Bar<T> implements Foo<T> {
Bar() {}
factory Bar.from() {
var func = (T arg) { print(arg); }; // If T is not a string, runtime checks should fail
func("Hello World!");
return new Bar<T>();
}
}
main() {
Foo value;
value = new Foo<String>.from();
bool gotError = false;
try {
value = new Foo<int>.from();
} catch (TypeError e) {
gotError = true;
}
Expect.equals(true, gotError);
}
Basically, getting type arguments into the hoisted methods from a factory method hasn't been worked out. Factory methods get their type arguments passed in as the first parameter, for other methods, the arguments are passed on a property of 'this' but in these hoisted methods from a factory, 'this' is set to Dart$Null.
The text was updated successfully, but these errors were encountered:
This issue was originally filed by [email protected]
In checked mode (dartc --enable_type_checks), there is a bug in runtime type checking in some cases. Here's a test that exercises it
TypeChecksInFactoryMethods.dart
interface Foo<T> default Bar {
Foo.from();
}
class Bar<T> implements Foo<T> {
Bar() {}
factory Bar.from() {
var func = (T arg) { print(arg); }; // If T is not a string, runtime checks should fail
func("Hello World!");
return new Bar<T>();
}
}
main() {
Foo value;
value = new Foo<String>.from();
bool gotError = false;
try {
value = new Foo<int>.from();
} catch (TypeError e) {
gotError = true;
}
Expect.equals(true, gotError);
}
Basically, getting type arguments into the hoisted methods from a factory method hasn't been worked out. Factory methods get their type arguments passed in as the first parameter, for other methods, the arguments are passed on a property of 'this' but in these hoisted methods from a factory, 'this' is set to Dart$Null.
The text was updated successfully, but these errors were encountered: