| library test /*isNonNullableByDefault*/; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart:51:7: Error: The mixin application class 'C' introduces an erroneous override of 'y'. |
| // class C = B with M implements I<int>; |
| // ^ |
| // pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart:48:7: Context: The field 'M.y' has type 'int', which does not match the corresponding type, 'Object', in the overridden setter, 'I.y'. |
| // - 'Object' is from 'dart:core'. |
| // int y = 0; |
| // ^ |
| // pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart:43:12: Context: This is the overridden method ('y'). |
| // void set y(covariant Object value); |
| // ^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| |
| class B extends core::Object { |
| synthetic constructor •() → self::B |
| : 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 •() → self::I<self::I::T%> |
| : super core::Object::•() |
| ; |
| abstract get x() → self::I::T%; |
| abstract set x(covariant-by-class self::I::T% value) → void; |
| abstract get y() → core::Object; |
| abstract set y(covariant-by-declaration core::Object value) → void; |
| } |
| class M extends core::Object { |
| field core::int x = 0; |
| field core::int y = 0; |
| synthetic constructor •() → self::M |
| : super core::Object::•() |
| ; |
| } |
| class C extends self::B implements self::I<core::int>, self::M /*isEliminatedMixin*/ { |
| covariant-by-class field core::int x = 0; |
| covariant-by-declaration field core::int y = 0; |
| synthetic constructor •() → self::C |
| : super self::B::•() |
| ; |
| } |
| static method expectTypeError(() → void callback) → void { |
| try { |
| callback(){() → void}; |
| 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 =={core::Object::==}{(core::Object) → core::bool} expected)) { |
| throw "Expected ${expected}, got ${value}"; |
| } |
| } |
| static method test(self::I<core::Object> i) → void { |
| self::expectTypeError(() → void { |
| i.{self::I::x} = "hello"; |
| }); |
| i.{self::I::x} = 1; |
| self::expect(i.{self::I::x}{core::Object}, 1); |
| self::expectTypeError(() → void { |
| i.{self::I::y} = "hello"; |
| }); |
| i.{self::I::y} = 2; |
| self::expect(i.{self::I::y}{core::Object}, 2); |
| } |
| static method main() → void { |
| self::test(new self::C::•()); |
| } |