| 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 miscompile | 5 // Regression test for dart2js that used to miscompile |
| 6 // [A.visitInvokeDynamicMethod]. | 6 // [A.visitInvokeDynamicMethod]. |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 var a = 2; | 10 var a = 2; |
| 11 | 11 |
| 12 class Tupe { | 12 class Tupe { |
| 13 const Tupe(); | 13 const Tupe(); |
| 14 get instructionType => a == 2 ? this : new A(); | 14 get instructionType => a == 2 ? this : new A(); |
| 15 refine(a, b) => '$a$b'; | 15 refine(a, b) => '$a$b'; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class Node { | 18 class Node { |
| 19 final selector = null; | 19 final selector = null; |
| 20 var inputs = {"a": const Tupe(), "b": const Tupe() }; | 20 var inputs = {"a": const Tupe(), "b": const Tupe() }; |
| 21 bool isCallOnInterceptor; | 21 bool isCallOnInterceptor = false; |
| 22 | 22 |
| 23 getDartReceiver() { | 23 getDartReceiver() { |
| 24 return isCallOnInterceptor ? inputs["a"] : inputs["b"]; | 24 return isCallOnInterceptor ? inputs["a"] : inputs["b"]; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 class A { | 28 class A { |
| 29 visitInvokeDynamicMethod(node) { | 29 visitInvokeDynamicMethod(node) { |
| 30 var receiverType = node.getDartReceiver().instructionType; | 30 var receiverType = node.getDartReceiver().instructionType; |
| 31 return receiverType.refine(node.selector, node.selector); | 31 return receiverType.refine(node.selector, node.selector); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 main() { | 35 main() { |
| 36 Expect.equals('nullnull', | 36 Expect.equals('nullnull', |
| 37 [new A()].last.visitInvokeDynamicMethod(new Node())); | 37 [new A()].last.visitInvokeDynamicMethod(new Node())); |
| 38 } | 38 } |
| OLD | NEW |