| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 // Test for locateSingleElement bug. |
| 6 |
| 7 import 'package:expect/expect.dart'; |
| 8 |
| 9 class T { |
| 10 foo() => 'T.foo'; // This is the single element. |
| 11 } |
| 12 |
| 13 class C implements T { |
| 14 // There is a warning that C does not implement 'foo'. |
| 15 } |
| 16 |
| 17 @NoInline() @AssumeDynamic() |
| 18 assumeT(x) { // returns inferred subtype(T). |
| 19 if (x is T) return x; |
| 20 throw "Not T"; |
| 21 } |
| 22 |
| 23 var log = []; |
| 24 demo() { |
| 25 log.add(new T()); // T is created. |
| 26 var a = assumeT(new C()); // C is created. |
| 27 |
| 28 // The call "a.foo()" should be a NoSuchMethodError, but a bug in |
| 29 // locateSingleElement used to lead to T.foo being inlined. There is a single |
| 30 // method. T.foo, that matches subtype(T), but it should be rejected because |
| 31 // not all instantiated classes that are subtype(T) have that method. |
| 32 log.add(a.foo()); |
| 33 } |
| 34 |
| 35 main() { |
| 36 Expect.throws(demo); |
| 37 } |
| OLD | NEW |