| library; |
| import self as self; |
| import "dart:core" as core; |
| |
| typedef Callback<T extends core::Object = dynamic> = (T) → void; |
| class Foo<T extends core::Object = dynamic> extends core::Object { |
| final field self::Foo::T finalField; |
| final field (self::Foo::T) → void callbackField; |
| generic-covariant-impl field self::Foo::T mutableField = null; |
| field (self::Foo::T) → void mutableCallbackField = null; |
| constructor •(self::Foo::T finalField, (self::Foo::T) → void callbackField) → self::Foo<self::Foo::T> |
| : self::Foo::finalField = finalField, self::Foo::callbackField = callbackField, super core::Object::•() |
| ; |
| method method(generic-covariant-impl self::Foo::T x) → void {} |
| set setter(generic-covariant-impl self::Foo::T x) → void {} |
| method withCallback((self::Foo::T) → void callback) → void { |
| callback.call(this.{self::Foo::finalField}); |
| } |
| } |
| static method main() → dynamic { |
| self::Foo<core::int> fooInt = new self::Foo::•<core::int>(1, (core::int x) → core::Null {}); |
| fooInt.{self::Foo::method}(3); |
| fooInt.{self::Foo::setter} = 3; |
| fooInt.{self::Foo::withCallback}((core::int x) → core::Null {}); |
| fooInt.{self::Foo::withCallback}((core::num x) → core::Null {}); |
| fooInt.{self::Foo::mutableField} = 3; |
| fooInt.{self::Foo::mutableCallbackField} = (core::int x) → core::Null {}; |
| self::Foo<core::num> fooNum = fooInt; |
| fooNum.{self::Foo::method}(3); |
| fooNum.{self::Foo::method}(2.5); |
| fooNum.{self::Foo::setter} = 3; |
| fooNum.{self::Foo::setter} = 2.5; |
| fooNum.{self::Foo::withCallback}((core::num x) → core::Null {}); |
| fooNum.{self::Foo::mutableField} = 3; |
| fooNum.{self::Foo::mutableField} = 2.5; |
| (fooNum.{self::Foo::mutableCallbackField} as{TypeError} (core::num) → void).call(3); |
| (fooNum.{self::Foo::mutableCallbackField} as{TypeError} (core::num) → void).call(2.5); |
| fooNum.{self::Foo::mutableCallbackField} = (core::num x) → core::Null {}; |
| } |