| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 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. |
| 7 |
| 8 import 'package:expect/expect.dart'; |
| 9 import "package:async_helper/async_helper.dart"; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; |
| 11 import '../../../sdk/lib/_internal/compiler/implementation/types/simple_types_in
ferrer.dart'; |
| 12 |
| 13 import 'compiler_helper.dart'; |
| 14 import 'parser_helper.dart'; |
| 15 |
| 16 const String TEST = """ |
| 17 class A { |
| 18 var field; |
| 19 } |
| 20 |
| 21 class B { |
| 22 var field; |
| 23 } |
| 24 |
| 25 main() { |
| 26 new A().field; |
| 27 new B().field; |
| 28 } |
| 29 """; |
| 30 |
| 31 // Create our own type inferrer to avoid clearing out the internal |
| 32 // data structures. |
| 33 class MyInferrer extends SimpleTypesInferrer { |
| 34 MyInferrer(compiler) : super(compiler); |
| 35 clear() {} |
| 36 } |
| 37 |
| 38 void main() { |
| 39 Uri uri = new Uri(scheme: 'source'); |
| 40 var compiler = compilerFor(TEST, uri); |
| 41 var inferrer = new MyInferrer(compiler); |
| 42 compiler.typesTask.typesInferrer = inferrer; |
| 43 asyncTest(() => compiler.runCompiler(uri).then((_) { |
| 44 var mainElement = findElement(compiler, 'main'); |
| 45 var classA = findElement(compiler, 'A'); |
| 46 var fieldA = classA.lookupLocalMember(buildSourceString('field')); |
| 47 var classB = findElement(compiler, 'B'); |
| 48 var fieldB = classB.lookupLocalMember(buildSourceString('field'));; |
| 49 |
| 50 Expect.isTrue(inferrer.getCallersOf(fieldA).contains(mainElement)); |
| 51 Expect.isTrue(inferrer.getCallersOf(fieldB).contains(mainElement)); |
| 52 })); |
| 53 } |
| OLD | NEW |