| library test; |
| import self as self; |
| import "dart:core" as core; |
| |
| class C<T extends core::Object = dynamic> extends core::Object { |
| final field (self::C::T) → core::num plusResult; |
| constructor •((self::C::T) → core::num plusResult) → void |
| : self::C::plusResult = plusResult, super core::Object::•() |
| ; |
| operator +(core::int i) → (self::C::T) → core::num |
| return this.{self::C::plusResult}; |
| } |
| class D extends core::Object { |
| final field self::C<core::num> getValue; |
| field (core::int) → core::int setValue = null; |
| constructor •(self::C<core::num> getValue) → void |
| : self::D::getValue = getValue, super core::Object::•() |
| ; |
| get value() → self::C<core::num> |
| return this.{self::D::getValue}; |
| set value((core::int) → core::int value) → void { |
| this.{self::D::setValue} = value; |
| } |
| } |
| static method expectTypeError(() → void callback) → void { |
| try { |
| callback.call(); |
| throw "Expected TypeError, did not occur"; |
| } |
| on core::TypeError catch(no-exception-var) { |
| } |
| } |
| static method expect(core::Object value, core::Object expected) → void { |
| if(!value.==(expected)) { |
| throw "Expected ${expected}, got ${value}"; |
| } |
| } |
| static method numToInt(core::num n) → core::int |
| return 1; |
| static method numToNum(core::num n) → core::num |
| return 2; |
| static method main() → void { |
| self::D d = new self::D::•(new self::C::•<dynamic>(self::numToInt)); |
| let final dynamic #t1 = d in #t1.value = #t1.value.+(1); |
| self::expect(d.setValue(0), 1); |
| d = new self::D::•(new self::C::•<dynamic>(self::numToNum)); |
| self::expectTypeError(() → dynamic { |
| let final dynamic #t2 = d in #t2.value = #t2.value.+(1); |
| }); |
| self::expect(d.setValue, null); |
| } |