| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Regression test for dart2js that used to duplicate some `Object` | 5 // Regression test for dart2js that used to duplicate some `Object` |
| 6 // methods to handle `noSuchMethod`. | 6 // methods to handle `noSuchMethod`. |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "compiler_annotations.dart"; | 9 import "compiler_annotations.dart"; |
| 10 | 10 |
| 11 abstract /// 01: static type warning | 11 abstract class Foo { |
| 12 class Foo { | |
| 13 noSuchMethod(im) => 42; | 12 noSuchMethod(im) => 42; |
| 14 } | 13 } |
| 15 | 14 |
| 16 @DontInline() | 15 @DontInline() |
| 17 returnFoo() { | 16 returnFoo() { |
| 18 (() => 42)(); | 17 (() => 42)(); |
| 19 return new Foo(); | 18 return new Foo(); |
| 20 } | 19 } |
| 21 | 20 |
| 22 class Bar { | 21 class Bar { |
| 23 operator==(other) => false; | 22 operator==(other) => false; |
| 24 } | 23 } |
| 25 | 24 |
| 26 var a = [false, true, new Object(), new Bar()]; | 25 var a = [false, true, new Object(), new Bar()]; |
| 27 | 26 |
| 28 main() { | 27 main() { |
| 29 if (a[0]) { | 28 if (a[0]) { |
| 30 // This `==` call will make the compiler create a selector with an | 29 // This `==` call will make the compiler create a selector with an |
| 31 // exact `TypeMask` of `Foo`. Since `Foo` is abstract, such a call | 30 // exact `TypeMask` of `Foo`. Since `Foo` is abstract, such a call |
| 32 // cannot happen, but we still used to generate a `==` method on | 31 // cannot happen, but we still used to generate a `==` method on |
| 33 // the `Object` class to handle `noSuchMethod`. | 32 // the `Object` class to handle `noSuchMethod`. |
| 34 print(returnFoo() == 42); | 33 print(returnFoo() == 42); |
| 35 } else { | 34 } else { |
| 36 Expect.isFalse(a[2] == 42); | 35 Expect.isFalse(a[2] == 42); |
| 37 } | 36 } |
| 38 } | 37 } |
| OLD | NEW |