| 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 computation of callers of an element works when two | 5 // Test that computation of callers of an element works when two |
| 6 // elements of the same name are being invoked in the same method. | 6 // elements of the same name are being invoked in the same method. |
| 7 | 7 |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/common_elements.dart'; | 10 import 'package:compiler/src/common_elements.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 main() { | 25 main() { |
| 26 new A().field; | 26 new A().field; |
| 27 new B().field; | 27 new B().field; |
| 28 } | 28 } |
| 29 """; | 29 """; |
| 30 | 30 |
| 31 // Create our own type inferrer to avoid clearing out the internal | 31 // Create our own type inferrer to avoid clearing out the internal |
| 32 // data structures. | 32 // data structures. |
| 33 class MyInferrer extends TypeGraphInferrer { | 33 class MyInferrer extends AstTypeGraphInferrer { |
| 34 MyInferrer(compiler, closedWorld, closedWorldRefiner) | 34 MyInferrer(compiler, closedWorld, closedWorldRefiner) |
| 35 : super(compiler, closedWorld, closedWorldRefiner); | 35 : super(compiler, closedWorld, closedWorldRefiner); |
| 36 clear() {} | 36 clear() {} |
| 37 } | 37 } |
| 38 | 38 |
| 39 void main() { | 39 void main() { |
| 40 Uri uri = new Uri(scheme: 'source'); | 40 Uri uri = new Uri(scheme: 'source'); |
| 41 var compiler = compilerFor(TEST, uri, analyzeOnly: true); | 41 var compiler = compilerFor(TEST, uri, analyzeOnly: true); |
| 42 asyncTest(() => compiler.run(uri).then((_) { | 42 asyncTest(() => compiler.run(uri).then((_) { |
| 43 ElementEnvironment elementEnvironment = | 43 ElementEnvironment elementEnvironment = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 var mainElement = findElement(compiler, 'main'); | 56 var mainElement = findElement(compiler, 'main'); |
| 57 dynamic classA = findElement(compiler, 'A'); | 57 dynamic classA = findElement(compiler, 'A'); |
| 58 var fieldA = classA.lookupLocalMember('field'); | 58 var fieldA = classA.lookupLocalMember('field'); |
| 59 dynamic classB = findElement(compiler, 'B'); | 59 dynamic classB = findElement(compiler, 'B'); |
| 60 var fieldB = classB.lookupLocalMember('field'); | 60 var fieldB = classB.lookupLocalMember('field'); |
| 61 | 61 |
| 62 Expect.isTrue(inferrer.getCallersOf(fieldA).contains(mainElement)); | 62 Expect.isTrue(inferrer.getCallersOf(fieldA).contains(mainElement)); |
| 63 Expect.isTrue(inferrer.getCallersOf(fieldB).contains(mainElement)); | 63 Expect.isTrue(inferrer.getCallersOf(fieldB).contains(mainElement)); |
| 64 })); | 64 })); |
| 65 } | 65 } |
| OLD | NEW |