| library test; |
| import self as self; |
| import "dart:core" as core; |
| |
| class B extends core::Object { |
| synthetic constructor •() → void |
| : super core::Object::•() |
| ; |
| get x() → core::int { |
| throw "Should not be reached"; |
| } |
| set x(core::int value) → void { |
| throw "Should not be reached"; |
| } |
| get y() → core::int { |
| throw "Should not be reached"; |
| } |
| set y(core::int value) → void { |
| throw "Should not be reached"; |
| } |
| } |
| abstract class I<T extends core::Object = dynamic> extends core::Object { |
| synthetic constructor •() → void |
| : super core::Object::•() |
| ; |
| abstract get x() → self::I::T; |
| abstract set x(self::I::T value) → void; |
| abstract get y() → core::Object; |
| abstract set y(covariant core::Object value) → void; |
| } |
| class M extends core::Object { |
| field core::int x = null; |
| field core::int y = null; |
| synthetic constructor •() → void |
| : super core::Object::•() |
| ; |
| } |
| class C = self::B with self::M implements self::I<core::int> { |
| synthetic constructor •() → void |
| : super self::B::•() |
| ; |
| } |
| 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 test(self::I<core::Object> i) → void { |
| self::expectTypeError(() → dynamic { |
| i.x = "hello"; |
| }); |
| i.x = 1; |
| self::expect(i.x, 1); |
| self::expectTypeError(() → dynamic { |
| i.y = "hello"; |
| }); |
| i.y = 2; |
| self::expect(i.y, 2); |
| } |
| static method main() → void { |
| self::test(new self::C::•()); |
| } |