| 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 // Test that dart2js type inferrer detects dead code. | |
| 6 | |
| 7 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 8 | 6 |
| 9 class A { | 7 class F { |
| 10 var field; | 8 call() => null; |
| 11 A(test) { | 9 noSuchMethod(Invocation i) { |
| 12 if (test) { | 10 if (i.memberName == #call && i.isMethod) { |
| 13 return; | 11 return i.positionalArguments[0]; |
| 14 field = 42; | |
| 15 } else { | |
| 16 field = 54; | |
| 17 } | 12 } |
| 13 return super.noSuchMethod(i); |
| 18 } | 14 } |
| 19 } | 15 } |
| 20 | 16 |
| 21 main() { | 17 main() { |
| 22 var a = new A(true); | 18 var result = Function.apply(new F(), ['a', 'b', 'c', 'd']); |
| 23 Expect.throws(() => a.field + 42, (e) => e is NoSuchMethodError); | 19 Expect.equals('a', result); |
| 24 } | 20 } |
| OLD | NEW |