-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.os-fuchsia
Description
When running the following program there is a type error in the assert()
.
test.dart
:
typedef T DoSpecialThing<T>(T thing);
String specialStringThing(String thing) => thing;
double specialDoubleThing(double thing) => thing;
class Property<T> {
Property(this._operation);
T doThing(T thing) => thing;
DoSpecialThing<T> get doSpecialThing => _operation;
DoSpecialThing<T> _operation;
}
Property<String> stringProperty = new Property<String>(specialStringThing);
Property<double> doubleProperty = new Property<double>(specialDoubleThing);
void main() {
List<Property> properties = [ stringProperty, doubleProperty ];
List values = [ "String value", 0.0 ];
for (int i = 0; i < properties.length; ++i) {
assert(properties[i].doSpecialThing(values[i]) == values[i]);
}
}
$ dart --enable-asserts --preview-dart-2 test.dart
Unhandled exception:
type '(String) => String' is not a subtype of type '(dynamic) => dynamic'
#0 main (file:///usr/local/google/home/zra/dart/dart2tests/test.dart)
#1 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
#2 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
However, if doSpecialThing
is replaced with doThing
, which should have the same type(?), there is no type error.
Metadata
Metadata
Assignees
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.os-fuchsia