| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 final y; | 228 final y; |
| 229 const C() : y = x.length; | 229 const C() : y = x.length; |
| 230 } | 230 } |
| 231 const x = [const C()]; | 231 const x = [const C()]; |
| 232 '''); | 232 '''); |
| 233 testLibrary.libraryCycleForLink.ensureLinked(); | 233 testLibrary.libraryCycleForLink.ensureLinked(); |
| 234 ClassElementForLink classC = testLibrary.getContainedName('C'); | 234 ClassElementForLink classC = testLibrary.getContainedName('C'); |
| 235 expect(classC.unnamedConstructor.isCycleFree, false); | 235 expect(classC.unnamedConstructor.isCycleFree, false); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void test_createPackageBundle_withPackageUri() { |
| 239 PackageBundle bundle = createPackageBundle( |
| 240 ''' |
| 241 class B { |
| 242 void f(int i) {} |
| 243 } |
| 244 class C extends B { |
| 245 f(i) {} // Inferred param type: int |
| 246 } |
| 247 ''', |
| 248 uri: 'package:foo/bar.dart'); |
| 249 UnlinkedExecutable cf = bundle.unlinkedUnits[0].classes[1].executables[0]; |
| 250 UnlinkedParam cfi = cf.parameters[0]; |
| 251 expect(cfi.inferredTypeSlot, isNot(0)); |
| 252 EntityRef typeRef = |
| 253 bundle.linkedLibraries[0].units[0].types[cfi.inferredTypeSlot]; |
| 254 expect(bundle.unlinkedUnits[0].references[typeRef.reference].name, 'int'); |
| 255 } |
| 256 |
| 238 void test_getContainedName_nonStaticField() { | 257 void test_getContainedName_nonStaticField() { |
| 239 createLinker('class C { var f; }'); | 258 createLinker('class C { var f; }'); |
| 240 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 259 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 241 ClassElementForLink_Class c = library.getContainedName('C'); | 260 ClassElementForLink_Class c = library.getContainedName('C'); |
| 242 expect(c.getContainedName('f'), isNot(isUndefined)); | 261 expect(c.getContainedName('f'), isNot(isUndefined)); |
| 243 } | 262 } |
| 244 | 263 |
| 245 void test_getContainedName_nonStaticGetter() { | 264 void test_getContainedName_nonStaticGetter() { |
| 246 createLinker('class C { get g => null; }'); | 265 createLinker('class C { get g => null; }'); |
| 247 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 266 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); | 908 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); |
| 890 expect(j.variable.initializer, isNull); | 909 expect(j.variable.initializer, isNull); |
| 891 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); | 910 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); |
| 892 expect(v.variable.initializer, isNotNull); | 911 expect(v.variable.initializer, isNotNull); |
| 893 } | 912 } |
| 894 | 913 |
| 895 VariableElementForLink _getVariable(ReferenceableElementForLink element) { | 914 VariableElementForLink _getVariable(ReferenceableElementForLink element) { |
| 896 return (element as PropertyAccessorElementForLink_Variable).variable; | 915 return (element as PropertyAccessorElementForLink_Variable).variable; |
| 897 } | 916 } |
| 898 } | 917 } |
| OLD | NEW |