|
| 1 | +library /*isNonNullableByDefault*/; |
| 2 | +// |
| 3 | +// Problems in library: |
| 4 | +// |
| 5 | +// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Error: Operator '==' should have exactly one parameter. |
| 6 | +// bool operator ==() => true; |
| 7 | +// ^^ |
| 8 | +// |
| 9 | +// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Error: The method 'E.==' has fewer positional arguments than those of overridden method 'Object.=='. |
| 10 | +// bool operator ==() => true; |
| 11 | +// ^ |
| 12 | +// sdk/lib/_internal/vm/lib/object_patch.dart:18:17: Context: This is the overridden method ('=='). |
| 13 | +// bool operator ==(Object other) native "Object_equals"; |
| 14 | +// ^ |
| 15 | +// |
| 16 | +// pkg/front_end/testcases/nnbd/issue42603.dart:22:17: Error: The method 'F.==' has more required arguments than those of overridden method 'E.=='. |
| 17 | +// bool operator ==(Object? other) => super == other; |
| 18 | +// ^ |
| 19 | +// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Context: This is the overridden method ('=='). |
| 20 | +// bool operator ==() => true; |
| 21 | +// ^ |
| 22 | +// |
| 23 | +// pkg/front_end/testcases/nnbd/issue42603.dart:22:44: Error: Too many positional arguments: 0 allowed, but 1 found. |
| 24 | +// Try removing the extra positional arguments. |
| 25 | +// bool operator ==(Object? other) => super == other; |
| 26 | +// ^ |
| 27 | +// |
| 28 | +import self as self; |
| 29 | +import "dart:core" as core; |
| 30 | + |
| 31 | +class C extends core::Object { |
| 32 | + synthetic constructor •() → self::C |
| 33 | + : super core::Object::•() |
| 34 | + ; |
| 35 | + operator ==(core::Object other) → core::bool |
| 36 | + return true; |
| 37 | +} |
| 38 | +class D extends self::C { |
| 39 | + synthetic constructor •() → self::D |
| 40 | + : super self::C::•() |
| 41 | + ; |
| 42 | + operator ==(core::Object? other) → core::bool |
| 43 | + return super.{self::C::==}(other); |
| 44 | + method method1(dynamic o) → core::bool |
| 45 | + return super.{self::C::==}(o); |
| 46 | + method method2(core::Null? o) → core::bool |
| 47 | + return super.{self::C::==}(o); |
| 48 | +} |
| 49 | +class E extends core::Object { |
| 50 | + synthetic constructor •() → self::E |
| 51 | + : super core::Object::•() |
| 52 | + ; |
| 53 | + operator ==() → core::bool |
| 54 | + return true; |
| 55 | +} |
| 56 | +class F extends self::E { |
| 57 | + synthetic constructor •() → self::F |
| 58 | + : super self::E::•() |
| 59 | + ; |
| 60 | + operator ==(core::Object? other) → core::bool |
| 61 | + return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42603.dart:22:44: Error: Too many positional arguments: 0 allowed, but 1 found. |
| 62 | +Try removing the extra positional arguments. |
| 63 | + bool operator ==(Object? other) => super == other; |
| 64 | + ^" in super.{self::E::==}(other); |
| 65 | +} |
| 66 | +static method main() → dynamic { |
| 67 | + self::expect(true, new self::D::•().{self::D::==}(new self::D::•())); |
| 68 | + self::expect(false, new self::D::•().{self::D::method1}(null)); |
| 69 | + self::expect(false, new self::D::•().{self::D::method2}(null)); |
| 70 | +} |
| 71 | +static method expect(dynamic expected, dynamic actual) → dynamic { |
| 72 | + if(!expected.{core::Object::==}(actual)) |
| 73 | + throw "Expected ${expected}, actual ${actual}"; |
| 74 | +} |
0 commit comments