mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:07:49 +00:00
6bb89e4fbf
R=johnniwinther@google.com, paulberry@google.com Review-Url: https://codereview.chromium.org/2967923002 .
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
typedef Callback<T extends core::Object> = (T) → void;
|
|
class Foo<T extends core::Object> extends core::Object {
|
|
final field self::Foo::T finalField;
|
|
final field (self::Foo::T) → void callbackField;
|
|
field self::Foo::T mutableField = null;
|
|
field (self::Foo::T) → void mutableCallbackField = null;
|
|
constructor •(self::Foo::T finalField, (self::Foo::T) → void callbackField) → void
|
|
: self::Foo::finalField = finalField, self::Foo::callbackField = callbackField, super core::Object::•()
|
|
;
|
|
method method(self::Foo::T x) → void {}
|
|
set setter(self::Foo::T x) → dynamic {}
|
|
method withCallback((self::Foo::T) → void callback) → void {
|
|
callback.call(this.finalField);
|
|
}
|
|
}
|
|
static method main() → dynamic {
|
|
self::Foo<core::int> fooInt = new self::Foo::•<core::int>(1, (core::int x) → dynamic {});
|
|
fooInt.method(3);
|
|
fooInt.setter = 3;
|
|
fooInt.withCallback((core::int x) → dynamic {});
|
|
fooInt.withCallback((core::num x) → dynamic {});
|
|
fooInt.mutableField = 3;
|
|
fooInt.mutableCallbackField = (core::int x) → dynamic {};
|
|
self::Foo<core::num> fooNum = fooInt;
|
|
fooNum.method(3);
|
|
fooNum.method(2.5);
|
|
fooNum.setter = 3;
|
|
fooNum.setter = 2.5;
|
|
fooNum.withCallback((core::num x) → dynamic {});
|
|
fooNum.mutableField = 3;
|
|
fooNum.mutableField = 2.5;
|
|
fooNum.mutableCallbackField(3);
|
|
fooNum.mutableCallbackField(2.5);
|
|
fooNum.mutableCallbackField = (core::num x) → dynamic {};
|
|
}
|