| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/element/type.dart'; | 5 import 'package:analyzer/dart/element/type.dart'; |
| 6 import 'package:analyzer/src/dart/element/element.dart'; | 6 import 'package:analyzer/src/dart/element/element.dart'; |
| 7 import 'package:analyzer/src/summary/format.dart'; | 7 import 'package:analyzer/src/summary/format.dart'; |
| 8 import 'package:analyzer/src/summary/idl.dart'; | 8 import 'package:analyzer/src/summary/idl.dart'; |
| 9 import 'package:analyzer/src/summary/link.dart'; | 9 import 'package:analyzer/src/summary/link.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 addBundle(bundle); | 191 addBundle(bundle); |
| 192 createLinker(''' | 192 createLinker(''' |
| 193 import 'a.dart'; | 193 import 'a.dart'; |
| 194 var y = x; | 194 var y = x; |
| 195 '''); | 195 '''); |
| 196 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 196 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 197 expect(_getVariable(library.getContainedName('y')).inferredType.toString(), | 197 expect(_getVariable(library.getContainedName('y')).inferredType.toString(), |
| 198 '() → dynamic'); | 198 '() → dynamic'); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void test_inferredType_closure_fromBundle_identifierSequence() { |
| 202 var bundle = createPackageBundle( |
| 203 ''' |
| 204 class C { |
| 205 static final x = (D d) => d.e; |
| 206 } |
| 207 class D { |
| 208 E e; |
| 209 } |
| 210 class E {} |
| 211 ''', |
| 212 path: '/a.dart'); |
| 213 addBundle(bundle); |
| 214 createLinker(''' |
| 215 import 'a.dart'; |
| 216 var y = C.x; |
| 217 '''); |
| 218 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 219 expect(_getVariable(library.getContainedName('y')).inferredType.toString(), |
| 220 '(D) → E'); |
| 221 } |
| 222 |
| 201 void test_inferredType_instanceField_dynamic() { | 223 void test_inferredType_instanceField_dynamic() { |
| 202 createLinker(''' | 224 createLinker(''' |
| 203 var x; | 225 var x; |
| 204 class C { | 226 class C { |
| 205 var f = x; // Inferred type: dynamic | 227 var f = x; // Inferred type: dynamic |
| 206 } | 228 } |
| 207 '''); | 229 '''); |
| 208 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 230 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 209 library.libraryCycleForLink.ensureLinked(); | 231 library.libraryCycleForLink.ensureLinked(); |
| 210 ClassElementForLink_Class cls = library.getContainedName('C'); | 232 ClassElementForLink_Class cls = library.getContainedName('C'); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); | 799 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); |
| 778 expect(j.variable.initializer, isNull); | 800 expect(j.variable.initializer, isNull); |
| 779 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); | 801 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); |
| 780 expect(v.variable.initializer, isNotNull); | 802 expect(v.variable.initializer, isNotNull); |
| 781 } | 803 } |
| 782 | 804 |
| 783 VariableElementForLink _getVariable(ReferenceableElementForLink element) { | 805 VariableElementForLink _getVariable(ReferenceableElementForLink element) { |
| 784 return (element as PropertyAccessorElementForLink_Variable).variable; | 806 return (element as PropertyAccessorElementForLink_Variable).variable; |
| 785 } | 807 } |
| 786 } | 808 } |
| OLD | NEW |