| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library engine.element_test; | 5 library analyzer.test.src.dart.element.element_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; |
| 11 import 'package:analyzer/src/dart/element/element.dart'; |
| 12 import 'package:analyzer/src/dart/element/handle.dart'; |
| 13 import 'package:analyzer/src/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' | 14 import 'package:analyzer/src/generated/engine.dart' |
| 10 show AnalysisContext, AnalysisOptionsImpl; | 15 show AnalysisContext, AnalysisOptionsImpl; |
| 11 import 'package:analyzer/src/generated/java_core.dart'; | |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 16 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 14 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 15 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 19 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 20 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 16 import 'package:unittest/unittest.dart'; | 21 import 'package:unittest/unittest.dart'; |
| 17 | 22 |
| 18 import '../reflective_tests.dart'; | 23 import '../../../generated/analysis_context_factory.dart' |
| 19 import '../utils.dart'; | 24 show AnalysisContextHelper; |
| 20 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper; | 25 import '../../../generated/resolver_test_case.dart'; |
| 21 import 'test_support.dart'; | 26 import '../../../generated/test_support.dart'; |
| 27 import '../../../utils.dart'; |
| 22 | 28 |
| 23 main() { | 29 main() { |
| 24 initializeTestEnvironment(); | 30 initializeTestEnvironment(); |
| 25 runReflectiveTests(ElementKindTest); | 31 defineReflectiveTests(ElementAnnotationImplTest); |
| 26 runReflectiveTests(FieldElementImplTest); | 32 defineReflectiveTests(FieldElementImplTest); |
| 27 runReflectiveTests(FunctionTypeImplTest); | 33 defineReflectiveTests(FunctionTypeImplTest); |
| 28 runReflectiveTests(InterfaceTypeImplTest); | 34 defineReflectiveTests(InterfaceTypeImplTest); |
| 29 runReflectiveTests(TypeParameterTypeImplTest); | 35 defineReflectiveTests(LocalVariableElementImplTest); |
| 30 runReflectiveTests(VoidTypeImplTest); | 36 defineReflectiveTests(TypeParameterTypeImplTest); |
| 31 runReflectiveTests(ClassElementImplTest); | 37 defineReflectiveTests(VoidTypeImplTest); |
| 32 runReflectiveTests(CompilationUnitElementImplTest); | 38 defineReflectiveTests(ClassElementImplTest); |
| 33 runReflectiveTests(ElementLocationImplTest); | 39 defineReflectiveTests(CompilationUnitElementImplTest); |
| 34 runReflectiveTests(ElementImplTest); | 40 defineReflectiveTests(ElementLocationImplTest); |
| 35 runReflectiveTests(HtmlElementImplTest); | 41 defineReflectiveTests(ElementImplTest); |
| 36 runReflectiveTests(LibraryElementImplTest); | 42 defineReflectiveTests(LibraryElementImplTest); |
| 37 runReflectiveTests(MethodElementImplTest); | 43 defineReflectiveTests(MethodElementImplTest); |
| 38 runReflectiveTests(MultiplyDefinedElementImplTest); | 44 defineReflectiveTests(MultiplyDefinedElementImplTest); |
| 39 runReflectiveTests(ParameterElementImplTest); | 45 defineReflectiveTests(ParameterElementImplTest); |
| 46 defineReflectiveTests(PropertyAccessorElementImplTest); |
| 47 defineReflectiveTests(TopLevelVariableElementImplTest); |
| 40 } | 48 } |
| 41 | 49 |
| 42 @reflectiveTest | 50 @reflectiveTest |
| 43 class ClassElementImplTest extends EngineTestCase { | 51 class ClassElementImplTest extends EngineTestCase { |
| 44 void test_computeNode_ClassDeclaration() { | 52 void test_computeNode_ClassDeclaration() { |
| 45 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 53 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 46 AnalysisContext context = contextHelper.context; | 54 AnalysisContext context = contextHelper.context; |
| 47 Source source = contextHelper.addSource( | 55 Source source = contextHelper.addSource( |
| 48 "/test.dart", | 56 "/test.dart", |
| 49 r''' | 57 r''' |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // A | 118 // A |
| 111 { | 119 { |
| 112 ClassElement elementA = unitElement.getType("A"); | 120 ClassElement elementA = unitElement.getType("A"); |
| 113 ClassTypeAlias nodeA = elementA.computeNode(); | 121 ClassTypeAlias nodeA = elementA.computeNode(); |
| 114 expect(nodeA, isNotNull); | 122 expect(nodeA, isNotNull); |
| 115 expect(nodeA.name.name, "A"); | 123 expect(nodeA.name.name, "A"); |
| 116 expect(nodeA.element, same(elementA)); | 124 expect(nodeA.element, same(elementA)); |
| 117 } | 125 } |
| 118 } | 126 } |
| 119 | 127 |
| 128 void test_constructors_mixinApplicationWithHandle() { |
| 129 AnalysisContext context = createAnalysisContext(); |
| 130 context.sourceFactory = new SourceFactory([]); |
| 131 |
| 132 ElementLocation location = new ElementLocationImpl.con2(''); |
| 133 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 134 classA.mixinApplication = true; |
| 135 TestElementResynthesizer resynthesizer = |
| 136 new TestElementResynthesizer(context, {location: classA}); |
| 137 ClassElementHandle classAHandle = |
| 138 new ClassElementHandle(resynthesizer, location); |
| 139 ClassElementImpl classB = |
| 140 ElementFactory.classElement("B", new InterfaceTypeImpl(classAHandle)); |
| 141 classB.mixinApplication = true; |
| 142 |
| 143 expect(classB.constructors, hasLength(1)); |
| 144 } |
| 145 |
| 120 void test_getAllSupertypes_interface() { | 146 void test_getAllSupertypes_interface() { |
| 121 ClassElement classA = ElementFactory.classElement2("A"); | 147 ClassElement classA = ElementFactory.classElement2("A"); |
| 122 ClassElement classB = ElementFactory.classElement("B", classA.type); | 148 ClassElement classB = ElementFactory.classElement("B", classA.type); |
| 123 ClassElementImpl elementC = ElementFactory.classElement2("C"); | 149 ClassElementImpl elementC = ElementFactory.classElement2("C"); |
| 124 InterfaceType typeObject = classA.supertype; | 150 InterfaceType typeObject = classA.supertype; |
| 125 InterfaceType typeA = classA.type; | 151 InterfaceType typeA = classA.type; |
| 126 InterfaceType typeB = classB.type; | 152 InterfaceType typeB = classB.type; |
| 127 InterfaceType typeC = elementC.type; | 153 InterfaceType typeC = elementC.type; |
| 128 elementC.interfaces = <InterfaceType>[typeB]; | 154 elementC.interfaces = <InterfaceType>[typeB]; |
| 129 List<InterfaceType> supers = elementC.allSupertypes; | 155 List<InterfaceType> supers = elementC.allSupertypes; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ElementFactory.setterElement("foo", false, null); | 301 ElementFactory.setterElement("foo", false, null); |
| 276 classA.accessors = <PropertyAccessorElement>[setter]; | 302 classA.accessors = <PropertyAccessorElement>[setter]; |
| 277 // "foo" is static | 303 // "foo" is static |
| 278 setter.static = true; | 304 setter.static = true; |
| 279 expect(classA.hasStaticMember, isTrue); | 305 expect(classA.hasStaticMember, isTrue); |
| 280 } | 306 } |
| 281 | 307 |
| 282 void test_isEnum() { | 308 void test_isEnum() { |
| 283 String firstConst = "A"; | 309 String firstConst = "A"; |
| 284 String secondConst = "B"; | 310 String secondConst = "B"; |
| 285 ClassElementImpl enumE = ElementFactory.enumElement( | 311 EnumElementImpl enumE = ElementFactory |
| 286 new TestTypeProvider(), "E", [firstConst, secondConst]); | 312 .enumElement(new TestTypeProvider(), "E", [firstConst, secondConst]); |
| 287 | 313 |
| 288 // E is an enum | 314 // E is an enum |
| 289 expect(enumE.isEnum, true); | 315 expect(enumE.isEnum, true); |
| 290 | 316 |
| 291 // A and B are static members | 317 // A and B are static members |
| 292 expect(enumE.getField(firstConst).isEnumConstant, true); | 318 expect(enumE.getField(firstConst).isEnumConstant, true); |
| 293 expect(enumE.getField(secondConst).isEnumConstant, true); | 319 expect(enumE.getField(secondConst).isEnumConstant, true); |
| 294 } | 320 } |
| 295 | 321 |
| 296 void test_lookUpConcreteMethod_declared() { | 322 void test_lookUpConcreteMethod_declared() { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 inheritedMethod.abstract = true; | 653 inheritedMethod.abstract = true; |
| 628 classA.methods = <MethodElement>[inheritedMethod]; | 654 classA.methods = <MethodElement>[inheritedMethod]; |
| 629 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 655 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 630 MethodElement method = ElementFactory.methodElement(methodName, null); | 656 MethodElement method = ElementFactory.methodElement(methodName, null); |
| 631 classB.methods = <MethodElement>[method]; | 657 classB.methods = <MethodElement>[method]; |
| 632 (library.definingCompilationUnit as CompilationUnitElementImpl).types = | 658 (library.definingCompilationUnit as CompilationUnitElementImpl).types = |
| 633 <ClassElement>[classA, classB]; | 659 <ClassElement>[classA, classB]; |
| 634 expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull); | 660 expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull); |
| 635 } | 661 } |
| 636 | 662 |
| 637 void test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetwee
n() { | 663 void |
| 664 test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetween
() { |
| 638 // class A { | 665 // class A { |
| 639 // m() {} | 666 // m() {} |
| 640 // } | 667 // } |
| 641 // class B extends A { | 668 // class B extends A { |
| 642 // m(); | 669 // m(); |
| 643 // } | 670 // } |
| 644 // class C extends B { | 671 // class C extends B { |
| 645 // m() {} | 672 // m() {} |
| 646 // } | 673 // } |
| 647 LibraryElementImpl library = | 674 LibraryElementImpl library = |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 CompilationUnitElementImpl unit = | 1088 CompilationUnitElementImpl unit = |
| 1062 ElementFactory.compilationUnit("/lib.dart"); | 1089 ElementFactory.compilationUnit("/lib.dart"); |
| 1063 String className = "C"; | 1090 String className = "C"; |
| 1064 ClassElement classElement = ElementFactory.classElement2(className); | 1091 ClassElement classElement = ElementFactory.classElement2(className); |
| 1065 unit.types = <ClassElement>[classElement]; | 1092 unit.types = <ClassElement>[classElement]; |
| 1066 expect(unit.getType("${className}x"), isNull); | 1093 expect(unit.getType("${className}x"), isNull); |
| 1067 } | 1094 } |
| 1068 } | 1095 } |
| 1069 | 1096 |
| 1070 @reflectiveTest | 1097 @reflectiveTest |
| 1098 class ElementAnnotationImplTest extends ResolverTestCase { |
| 1099 void test_computeConstantValue() { |
| 1100 addNamedSource( |
| 1101 '/a.dart', |
| 1102 r''' |
| 1103 class A { |
| 1104 final String f; |
| 1105 const A(this.f); |
| 1106 } |
| 1107 void f(@A('x') int p) {} |
| 1108 '''); |
| 1109 Source source = addSource(r''' |
| 1110 import 'a.dart'; |
| 1111 main() { |
| 1112 f(3); |
| 1113 } |
| 1114 '''); |
| 1115 LibraryElement library = resolve2(source); |
| 1116 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 1117 FunctionDeclaration main = unit.declarations[0]; |
| 1118 BlockFunctionBody body = main.functionExpression.body; |
| 1119 ExpressionStatement statement = body.block.statements[0]; |
| 1120 MethodInvocation invocation = statement.expression; |
| 1121 ParameterElement parameter = |
| 1122 invocation.argumentList.arguments[0].bestParameterElement; |
| 1123 ElementAnnotation annotation = parameter.metadata[0]; |
| 1124 expect(annotation.constantValue, isNull); |
| 1125 DartObject value = annotation.computeConstantValue(); |
| 1126 expect(value, isNotNull); |
| 1127 expect(value.getField('f').toStringValue(), 'x'); |
| 1128 expect(annotation.constantValue, value); |
| 1129 } |
| 1130 } |
| 1131 |
| 1132 @reflectiveTest |
| 1071 class ElementImplTest extends EngineTestCase { | 1133 class ElementImplTest extends EngineTestCase { |
| 1072 void test_equals() { | 1134 void test_equals() { |
| 1073 LibraryElementImpl library = | 1135 LibraryElementImpl library = |
| 1074 ElementFactory.library(createAnalysisContext(), "lib"); | 1136 ElementFactory.library(createAnalysisContext(), "lib"); |
| 1075 ClassElementImpl classElement = ElementFactory.classElement2("C"); | 1137 ClassElementImpl classElement = ElementFactory.classElement2("C"); |
| 1076 (library.definingCompilationUnit as CompilationUnitElementImpl).types = | 1138 (library.definingCompilationUnit as CompilationUnitElementImpl).types = |
| 1077 <ClassElement>[classElement]; | 1139 <ClassElement>[classElement]; |
| 1078 FieldElement field = ElementFactory.fieldElement( | 1140 FieldElement field = ElementFactory.fieldElement( |
| 1079 "next", false, false, false, classElement.type); | 1141 "next", false, false, false, classElement.type); |
| 1080 classElement.fields = <FieldElement>[field]; | 1142 classElement.fields = <FieldElement>[field]; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 classElementA.nameOffset = 1; | 1219 classElementA.nameOffset = 1; |
| 1158 ClassElementImpl classElementB = ElementFactory.classElement2("B"); | 1220 ClassElementImpl classElementB = ElementFactory.classElement2("B"); |
| 1159 classElementB.nameOffset = 2; | 1221 classElementB.nameOffset = 2; |
| 1160 expect(Element.SORT_BY_OFFSET(classElementA, classElementA), 0); | 1222 expect(Element.SORT_BY_OFFSET(classElementA, classElementA), 0); |
| 1161 expect(Element.SORT_BY_OFFSET(classElementA, classElementB) < 0, isTrue); | 1223 expect(Element.SORT_BY_OFFSET(classElementA, classElementB) < 0, isTrue); |
| 1162 expect(Element.SORT_BY_OFFSET(classElementB, classElementA) > 0, isTrue); | 1224 expect(Element.SORT_BY_OFFSET(classElementB, classElementA) > 0, isTrue); |
| 1163 } | 1225 } |
| 1164 } | 1226 } |
| 1165 | 1227 |
| 1166 @reflectiveTest | 1228 @reflectiveTest |
| 1167 class ElementKindTest extends EngineTestCase { | |
| 1168 void test_of_nonNull() { | |
| 1169 expect(ElementKind.of(ElementFactory.classElement2("A")), | |
| 1170 same(ElementKind.CLASS)); | |
| 1171 } | |
| 1172 | |
| 1173 void test_of_null() { | |
| 1174 expect(ElementKind.of(null), same(ElementKind.ERROR)); | |
| 1175 } | |
| 1176 } | |
| 1177 | |
| 1178 @reflectiveTest | |
| 1179 class ElementLocationImplTest extends EngineTestCase { | 1229 class ElementLocationImplTest extends EngineTestCase { |
| 1180 void test_create_encoding() { | 1230 void test_create_encoding() { |
| 1181 String encoding = "a;b;c"; | 1231 String encoding = "a;b;c"; |
| 1182 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); | 1232 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); |
| 1183 expect(location.encoding, encoding); | 1233 expect(location.encoding, encoding); |
| 1184 } | 1234 } |
| 1185 | 1235 |
| 1186 /** | 1236 /** |
| 1187 * For example unnamed constructor. | 1237 * For example unnamed constructor. |
| 1188 */ | 1238 */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 expect(s.type == u.type, new isInstanceOf<bool>()); | 1351 expect(s.type == u.type, new isInstanceOf<bool>()); |
| 1302 } | 1352 } |
| 1303 | 1353 |
| 1304 void test_getElement() { | 1354 void test_getElement() { |
| 1305 FunctionElementImpl typeElement = | 1355 FunctionElementImpl typeElement = |
| 1306 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); | 1356 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); |
| 1307 FunctionTypeImpl type = new FunctionTypeImpl(typeElement); | 1357 FunctionTypeImpl type = new FunctionTypeImpl(typeElement); |
| 1308 expect(type.element, typeElement); | 1358 expect(type.element, typeElement); |
| 1309 } | 1359 } |
| 1310 | 1360 |
| 1311 void test_getNamedParameterTypes() { | 1361 void test_getNamedParameterTypes_namedParameters() { |
| 1312 FunctionTypeImpl type = new FunctionTypeImpl( | 1362 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1313 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))); | 1363 FunctionElement element = ElementFactory |
| 1364 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1365 ElementFactory.requiredParameter2('a', typeProvider.intType), |
| 1366 ElementFactory.requiredParameter('b'), |
| 1367 ElementFactory.namedParameter2('c', typeProvider.stringType), |
| 1368 ElementFactory.namedParameter('d') |
| 1369 ]); |
| 1370 FunctionTypeImpl type = element.type; |
| 1371 Map<String, DartType> types = type.namedParameterTypes; |
| 1372 expect(types, hasLength(2)); |
| 1373 expect(types['c'], typeProvider.stringType); |
| 1374 expect(types['d'], DynamicTypeImpl.instance); |
| 1375 } |
| 1376 |
| 1377 void test_getNamedParameterTypes_noNamedParameters() { |
| 1378 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1379 FunctionElement element = ElementFactory |
| 1380 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1381 ElementFactory.requiredParameter2('a', typeProvider.intType), |
| 1382 ElementFactory.requiredParameter('b'), |
| 1383 ElementFactory.positionalParameter2('c', typeProvider.stringType) |
| 1384 ]); |
| 1385 FunctionTypeImpl type = element.type; |
| 1314 Map<String, DartType> types = type.namedParameterTypes; | 1386 Map<String, DartType> types = type.namedParameterTypes; |
| 1315 expect(types, hasLength(0)); | 1387 expect(types, hasLength(0)); |
| 1316 } | 1388 } |
| 1317 | 1389 |
| 1318 void test_getNormalParameterTypes() { | 1390 void test_getNamedParameterTypes_noParameters() { |
| 1319 FunctionTypeImpl type = new FunctionTypeImpl( | 1391 FunctionTypeImpl type = ElementFactory.functionElement('f').type; |
| 1320 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))); | 1392 Map<String, DartType> types = type.namedParameterTypes; |
| 1393 expect(types, hasLength(0)); |
| 1394 } |
| 1395 |
| 1396 void test_getNormalParameterTypes_noNormalParameters() { |
| 1397 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1398 FunctionElement element = ElementFactory |
| 1399 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1400 ElementFactory.positionalParameter2('c', typeProvider.stringType), |
| 1401 ElementFactory.positionalParameter('d') |
| 1402 ]); |
| 1403 FunctionTypeImpl type = element.type; |
| 1321 List<DartType> types = type.normalParameterTypes; | 1404 List<DartType> types = type.normalParameterTypes; |
| 1322 expect(types, hasLength(0)); | 1405 expect(types, hasLength(0)); |
| 1323 } | 1406 } |
| 1324 | 1407 |
| 1408 void test_getNormalParameterTypes_noParameters() { |
| 1409 FunctionTypeImpl type = ElementFactory.functionElement('f').type; |
| 1410 List<DartType> types = type.normalParameterTypes; |
| 1411 expect(types, hasLength(0)); |
| 1412 } |
| 1413 |
| 1414 void test_getNormalParameterTypes_normalParameters() { |
| 1415 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1416 FunctionElement element = ElementFactory |
| 1417 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1418 ElementFactory.requiredParameter2('a', typeProvider.intType), |
| 1419 ElementFactory.requiredParameter('b'), |
| 1420 ElementFactory.positionalParameter2('c', typeProvider.stringType) |
| 1421 ]); |
| 1422 FunctionTypeImpl type = element.type; |
| 1423 List<DartType> types = type.normalParameterTypes; |
| 1424 expect(types, hasLength(2)); |
| 1425 expect(types[0], typeProvider.intType); |
| 1426 expect(types[1], DynamicTypeImpl.instance); |
| 1427 } |
| 1428 |
| 1429 void test_getOptionalParameterTypes_noOptionalParameters() { |
| 1430 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1431 FunctionElement element = ElementFactory |
| 1432 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1433 ElementFactory.requiredParameter2('a', typeProvider.intType), |
| 1434 ElementFactory.requiredParameter('b'), |
| 1435 ElementFactory.namedParameter2('c', typeProvider.stringType), |
| 1436 ElementFactory.namedParameter('d') |
| 1437 ]); |
| 1438 FunctionTypeImpl type = element.type; |
| 1439 List<DartType> types = type.optionalParameterTypes; |
| 1440 expect(types, hasLength(0)); |
| 1441 } |
| 1442 |
| 1443 void test_getOptionalParameterTypes_noParameters() { |
| 1444 FunctionTypeImpl type = ElementFactory.functionElement('f').type; |
| 1445 List<DartType> types = type.optionalParameterTypes; |
| 1446 expect(types, hasLength(0)); |
| 1447 } |
| 1448 |
| 1449 void test_getOptionalParameterTypes_optionalParameters() { |
| 1450 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 1451 FunctionElement element = ElementFactory |
| 1452 .functionElementWithParameters('f', VoidTypeImpl.instance, [ |
| 1453 ElementFactory.requiredParameter2('a', typeProvider.intType), |
| 1454 ElementFactory.requiredParameter('b'), |
| 1455 ElementFactory.positionalParameter2('c', typeProvider.stringType), |
| 1456 ElementFactory.positionalParameter('d') |
| 1457 ]); |
| 1458 FunctionTypeImpl type = element.type; |
| 1459 List<DartType> types = type.optionalParameterTypes; |
| 1460 expect(types, hasLength(2)); |
| 1461 expect(types[0], typeProvider.stringType); |
| 1462 expect(types[1], DynamicTypeImpl.instance); |
| 1463 } |
| 1464 |
| 1325 void test_getReturnType() { | 1465 void test_getReturnType() { |
| 1326 DartType expectedReturnType = VoidTypeImpl.instance; | 1466 DartType expectedReturnType = VoidTypeImpl.instance; |
| 1327 FunctionElementImpl functionElement = | 1467 FunctionElementImpl functionElement = |
| 1328 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); | 1468 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); |
| 1329 functionElement.returnType = expectedReturnType; | 1469 functionElement.returnType = expectedReturnType; |
| 1330 FunctionTypeImpl type = new FunctionTypeImpl(functionElement); | 1470 FunctionTypeImpl type = new FunctionTypeImpl(functionElement); |
| 1331 DartType returnType = type.returnType; | 1471 DartType returnType = type.returnType; |
| 1332 expect(returnType, expectedReturnType); | 1472 expect(returnType, expectedReturnType); |
| 1333 } | 1473 } |
| 1334 | 1474 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 ElementFactory.functionTypeAliasElement('f'); | 1999 ElementFactory.functionTypeAliasElement('f'); |
| 1860 FunctionTypeAliasElementImpl g = | 2000 FunctionTypeAliasElementImpl g = |
| 1861 ElementFactory.functionTypeAliasElement('g'); | 2001 ElementFactory.functionTypeAliasElement('g'); |
| 1862 f.typeParameters = [ElementFactory.typeParameterElement('T')]; | 2002 f.typeParameters = [ElementFactory.typeParameterElement('T')]; |
| 1863 f.parameters = [ElementFactory.positionalParameter2('x', g.type)]; | 2003 f.parameters = [ElementFactory.positionalParameter2('x', g.type)]; |
| 1864 FunctionTypeImpl paramType = f.type.optionalParameterTypes[0]; | 2004 FunctionTypeImpl paramType = f.type.optionalParameterTypes[0]; |
| 1865 expect(paramType.prunedTypedefs, hasLength(1)); | 2005 expect(paramType.prunedTypedefs, hasLength(1)); |
| 1866 expect(paramType.prunedTypedefs[0], same(f)); | 2006 expect(paramType.prunedTypedefs[0], same(f)); |
| 1867 } | 2007 } |
| 1868 | 2008 |
| 2009 void test_resolveToBound() { |
| 2010 FunctionElementImpl f = ElementFactory.functionElement('f'); |
| 2011 FunctionTypeImpl type = f.type; |
| 2012 |
| 2013 // Returns this. |
| 2014 expect(type.resolveToBound(null), same(type)); |
| 2015 } |
| 2016 |
| 1869 void test_returnType_pruned_no_type_arguments() { | 2017 void test_returnType_pruned_no_type_arguments() { |
| 1870 FunctionTypeAliasElementImpl f = | 2018 FunctionTypeAliasElementImpl f = |
| 1871 ElementFactory.functionTypeAliasElement('f'); | 2019 ElementFactory.functionTypeAliasElement('f'); |
| 1872 FunctionTypeAliasElementImpl g = | 2020 FunctionTypeAliasElementImpl g = |
| 1873 ElementFactory.functionTypeAliasElement('g'); | 2021 ElementFactory.functionTypeAliasElement('g'); |
| 1874 f.returnType = g.type; | 2022 f.returnType = g.type; |
| 1875 FunctionTypeImpl paramType = f.type.returnType; | 2023 FunctionTypeImpl paramType = f.type.returnType; |
| 1876 expect(paramType.prunedTypedefs, hasLength(1)); | 2024 expect(paramType.prunedTypedefs, hasLength(1)); |
| 1877 expect(paramType.prunedTypedefs[0], same(f)); | 2025 expect(paramType.prunedTypedefs[0], same(f)); |
| 1878 } | 2026 } |
| 1879 | 2027 |
| 1880 void test_returnType_pruned_with_type_arguments() { | 2028 void test_returnType_pruned_with_type_arguments() { |
| 1881 FunctionTypeAliasElementImpl f = | 2029 FunctionTypeAliasElementImpl f = |
| 1882 ElementFactory.functionTypeAliasElement('f'); | 2030 ElementFactory.functionTypeAliasElement('f'); |
| 1883 FunctionTypeAliasElementImpl g = | 2031 FunctionTypeAliasElementImpl g = |
| 1884 ElementFactory.functionTypeAliasElement('g'); | 2032 ElementFactory.functionTypeAliasElement('g'); |
| 1885 f.typeParameters = [ElementFactory.typeParameterElement('T')]; | 2033 f.typeParameters = [ElementFactory.typeParameterElement('T')]; |
| 1886 f.returnType = g.type; | 2034 f.returnType = g.type; |
| 1887 FunctionTypeImpl paramType = f.type.returnType; | 2035 FunctionTypeImpl paramType = f.type.returnType; |
| 1888 expect(paramType.prunedTypedefs, hasLength(1)); | 2036 expect(paramType.prunedTypedefs, hasLength(1)); |
| 1889 expect(paramType.prunedTypedefs[0], same(f)); | 2037 expect(paramType.prunedTypedefs[0], same(f)); |
| 1890 } | 2038 } |
| 1891 | 2039 |
| 1892 void test_setTypeArguments() { | |
| 1893 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); | |
| 1894 MethodElementImpl methodElement = | |
| 1895 new MethodElementImpl.forNode(AstFactory.identifier3("m")); | |
| 1896 enclosingClass.methods = <MethodElement>[methodElement]; | |
| 1897 FunctionTypeImpl type = new FunctionTypeImpl(methodElement); | |
| 1898 DartType expectedType = enclosingClass.typeParameters[0].type; | |
| 1899 type.typeArguments = <DartType>[expectedType]; | |
| 1900 List<DartType> arguments = type.typeArguments; | |
| 1901 expect(arguments, hasLength(1)); | |
| 1902 expect(arguments[0], expectedType); | |
| 1903 } | |
| 1904 | |
| 1905 void test_substitute2_equal() { | 2040 void test_substitute2_equal() { |
| 1906 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); | 2041 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); |
| 1907 TypeParameterType parameterType = definingClass.typeParameters[0].type; | 2042 TypeParameterType parameterType = definingClass.typeParameters[0].type; |
| 1908 MethodElementImpl functionElement = | 2043 MethodElementImpl functionElement = |
| 1909 new MethodElementImpl.forNode(AstFactory.identifier3("m")); | 2044 new MethodElementImpl.forNode(AstFactory.identifier3("m")); |
| 1910 String namedParameterName = "c"; | 2045 String namedParameterName = "c"; |
| 1911 functionElement.parameters = <ParameterElement>[ | 2046 functionElement.parameters = <ParameterElement>[ |
| 1912 ElementFactory.requiredParameter2("a", parameterType), | 2047 ElementFactory.requiredParameter2("a", parameterType), |
| 1913 ElementFactory.positionalParameter2("b", parameterType), | 2048 ElementFactory.positionalParameter2("b", parameterType), |
| 1914 ElementFactory.namedParameter2(namedParameterName, parameterType) | 2049 ElementFactory.namedParameter2(namedParameterName, parameterType) |
| 1915 ]; | 2050 ]; |
| 1916 functionElement.returnType = parameterType; | 2051 functionElement.returnType = parameterType; |
| 1917 definingClass.methods = <MethodElement>[functionElement]; | 2052 definingClass.methods = <MethodElement>[functionElement]; |
| 1918 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 2053 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| 1919 functionType.typeArguments = <DartType>[parameterType]; | |
| 1920 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( | 2054 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( |
| 1921 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); | 2055 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); |
| 1922 FunctionType result = functionType.substitute2( | 2056 FunctionType result = functionType |
| 1923 <DartType>[argumentType], <DartType>[parameterType]); | 2057 .substitute2(<DartType>[argumentType], <DartType>[parameterType]); |
| 1924 expect(result.returnType, argumentType); | 2058 expect(result.returnType, argumentType); |
| 1925 List<DartType> normalParameters = result.normalParameterTypes; | 2059 List<DartType> normalParameters = result.normalParameterTypes; |
| 1926 expect(normalParameters, hasLength(1)); | 2060 expect(normalParameters, hasLength(1)); |
| 1927 expect(normalParameters[0], argumentType); | 2061 expect(normalParameters[0], argumentType); |
| 1928 List<DartType> optionalParameters = result.optionalParameterTypes; | 2062 List<DartType> optionalParameters = result.optionalParameterTypes; |
| 1929 expect(optionalParameters, hasLength(1)); | 2063 expect(optionalParameters, hasLength(1)); |
| 1930 expect(optionalParameters[0], argumentType); | 2064 expect(optionalParameters[0], argumentType); |
| 1931 Map<String, DartType> namedParameters = result.namedParameterTypes; | 2065 Map<String, DartType> namedParameters = result.namedParameterTypes; |
| 1932 expect(namedParameters, hasLength(1)); | 2066 expect(namedParameters, hasLength(1)); |
| 1933 expect(namedParameters[namedParameterName], argumentType); | 2067 expect(namedParameters[namedParameterName], argumentType); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1949 ElementFactory.requiredParameter2("a", normalParameterType), | 2083 ElementFactory.requiredParameter2("a", normalParameterType), |
| 1950 ElementFactory.positionalParameter2("b", optionalParameterType), | 2084 ElementFactory.positionalParameter2("b", optionalParameterType), |
| 1951 ElementFactory.namedParameter2(namedParameterName, namedParameterType) | 2085 ElementFactory.namedParameter2(namedParameterName, namedParameterType) |
| 1952 ]; | 2086 ]; |
| 1953 functionElement.returnType = returnType; | 2087 functionElement.returnType = returnType; |
| 1954 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 2088 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| 1955 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( | 2089 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( |
| 1956 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); | 2090 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); |
| 1957 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl( | 2091 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl( |
| 1958 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); | 2092 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); |
| 1959 FunctionType result = functionType.substitute2( | 2093 FunctionType result = functionType |
| 1960 <DartType>[argumentType], <DartType>[parameterType]); | 2094 .substitute2(<DartType>[argumentType], <DartType>[parameterType]); |
| 1961 expect(result.returnType, returnType); | 2095 expect(result.returnType, returnType); |
| 1962 List<DartType> normalParameters = result.normalParameterTypes; | 2096 List<DartType> normalParameters = result.normalParameterTypes; |
| 1963 expect(normalParameters, hasLength(1)); | 2097 expect(normalParameters, hasLength(1)); |
| 1964 expect(normalParameters[0], normalParameterType); | 2098 expect(normalParameters[0], normalParameterType); |
| 1965 List<DartType> optionalParameters = result.optionalParameterTypes; | 2099 List<DartType> optionalParameters = result.optionalParameterTypes; |
| 1966 expect(optionalParameters, hasLength(1)); | 2100 expect(optionalParameters, hasLength(1)); |
| 1967 expect(optionalParameters[0], optionalParameterType); | 2101 expect(optionalParameters[0], optionalParameterType); |
| 1968 Map<String, DartType> namedParameters = result.namedParameterTypes; | 2102 Map<String, DartType> namedParameters = result.namedParameterTypes; |
| 1969 expect(namedParameters, hasLength(1)); | 2103 expect(namedParameters, hasLength(1)); |
| 1970 expect(namedParameters[namedParameterName], namedParameterType); | 2104 expect(namedParameters[namedParameterName], namedParameterType); |
| 1971 } | 2105 } |
| 1972 | 2106 |
| 1973 void test_toString_recursive() { | 2107 void test_toString_recursive() { |
| 1974 FunctionTypeAliasElementImpl t = | 2108 FunctionTypeAliasElementImpl t = |
| 1975 ElementFactory.functionTypeAliasElement("t"); | 2109 ElementFactory.functionTypeAliasElement("t"); |
| 1976 FunctionTypeAliasElementImpl s = | 2110 FunctionTypeAliasElementImpl s = |
| 1977 ElementFactory.functionTypeAliasElement("s"); | 2111 ElementFactory.functionTypeAliasElement("s"); |
| 1978 t.returnType = s.type; | 2112 t.returnType = s.type; |
| 1979 s.returnType = t.type; | 2113 s.returnType = t.type; |
| 1980 expect(t.type.toString(), '() \u2192 () \u2192 ...'); | 2114 expect(t.type.toString(), '() \u2192 () \u2192 ...'); |
| 1981 } | 2115 } |
| 1982 | 2116 |
| 1983 void test_toString_recursive_via_interface_type() { | 2117 void test_toString_recursive_via_interface_type() { |
| 1984 FunctionTypeAliasElementImpl f = | 2118 FunctionTypeAliasElementImpl f = |
| 1985 ElementFactory.functionTypeAliasElement('f'); | 2119 ElementFactory.functionTypeAliasElement('f'); |
| 1986 ClassElementImpl c = ElementFactory.classElement2('C', ['T']); | 2120 ClassElementImpl c = ElementFactory.classElement2('C', ['T']); |
| 1987 f.returnType = c.type.substitute4([f.type]); | 2121 f.returnType = c.type.instantiate([f.type]); |
| 1988 expect(f.type.toString(), '() \u2192 C<...>'); | 2122 expect(f.type.toString(), '() \u2192 C<...>'); |
| 1989 } | 2123 } |
| 2124 |
| 2125 void test_typeParameters_genericLocalFunction_genericMethod_genericClass() { |
| 2126 // |
| 2127 // class C<S> { |
| 2128 // Object m<T>() { |
| 2129 // U f<U>() => null; |
| 2130 // } |
| 2131 // } |
| 2132 // |
| 2133 ClassElementImpl classElement = |
| 2134 ElementFactory.classElement('C', null, ['S']); |
| 2135 MethodElementImpl method = new MethodElementImpl('m', 0); |
| 2136 method.enclosingElement = classElement; |
| 2137 method.returnType = ElementFactory.objectType; |
| 2138 method.typeParameters = ElementFactory.typeParameters(['T']); |
| 2139 method.type = new FunctionTypeImpl(method); |
| 2140 FunctionElementImpl function = ElementFactory.functionElement('f'); |
| 2141 function.enclosingElement = method; |
| 2142 function.typeParameters = ElementFactory.typeParameters(['U']); |
| 2143 function.returnType = function.typeParameters[0].type; |
| 2144 function.type = new FunctionTypeImpl(function); |
| 2145 |
| 2146 List<TypeParameterElement> inheritedParameters = <TypeParameterElement>[]; |
| 2147 inheritedParameters.addAll(method.typeParameters); |
| 2148 inheritedParameters.addAll(classElement.typeParameters); |
| 2149 expect(function.type.typeArguments, |
| 2150 unorderedEquals(_toTypes(inheritedParameters))); |
| 2151 expect(function.type.typeFormals, unorderedEquals(function.typeParameters)); |
| 2152 expect(function.type.typeParameters, unorderedEquals(inheritedParameters)); |
| 2153 } |
| 2154 |
| 2155 void test_typeParameters_genericMethod_genericClass() { |
| 2156 // |
| 2157 // class C<S> { |
| 2158 // Object m<T>() => null; |
| 2159 // } |
| 2160 // |
| 2161 ClassElementImpl classElement = |
| 2162 ElementFactory.classElement('C', null, ['S']); |
| 2163 MethodElementImpl method = new MethodElementImpl('m', 0); |
| 2164 method.enclosingElement = classElement; |
| 2165 method.returnType = ElementFactory.objectType; |
| 2166 method.typeParameters = ElementFactory.typeParameters(['T']); |
| 2167 method.type = new FunctionTypeImpl(method); |
| 2168 |
| 2169 expect(method.type.typeArguments, |
| 2170 unorderedEquals(_toTypes(classElement.typeParameters))); |
| 2171 expect(method.type.typeFormals, unorderedEquals(method.typeParameters)); |
| 2172 expect(method.type.typeParameters, |
| 2173 unorderedEquals(classElement.typeParameters)); |
| 2174 } |
| 2175 |
| 2176 void test_typeParameters_genericMethod_simpleClass() { |
| 2177 // |
| 2178 // class C<S> { |
| 2179 // Object m<T>() => null; |
| 2180 // } |
| 2181 // |
| 2182 ClassElementImpl classElement = ElementFactory.classElement2('C'); |
| 2183 MethodElementImpl method = new MethodElementImpl('m', 0); |
| 2184 method.enclosingElement = classElement; |
| 2185 method.returnType = ElementFactory.objectType; |
| 2186 method.typeParameters = ElementFactory.typeParameters(['T']); |
| 2187 method.type = new FunctionTypeImpl(method); |
| 2188 |
| 2189 expect(method.type.typeArguments, |
| 2190 unorderedEquals(_toTypes(classElement.typeParameters))); |
| 2191 expect(method.type.typeFormals, unorderedEquals(method.typeParameters)); |
| 2192 expect(method.type.typeParameters, |
| 2193 unorderedEquals(classElement.typeParameters)); |
| 2194 } |
| 2195 |
| 2196 void test_typeParameters_genericTopLevelFunction() { |
| 2197 // |
| 2198 // Object f<T>() => null; |
| 2199 // |
| 2200 FunctionElementImpl function = ElementFactory.functionElement('f'); |
| 2201 function.returnType = ElementFactory.objectType; |
| 2202 function.typeParameters = ElementFactory.typeParameters(['T']); |
| 2203 function.type = new FunctionTypeImpl(function); |
| 2204 |
| 2205 expect(function.type.typeArguments, isEmpty); |
| 2206 expect(function.type.typeFormals, unorderedEquals(function.typeParameters)); |
| 2207 expect(function.type.typeParameters, isEmpty); |
| 2208 } |
| 2209 |
| 2210 void test_typeParameters_simpleMethod_genericClass() { |
| 2211 // |
| 2212 // class C<S> { |
| 2213 // Object m<T>() => null; |
| 2214 // } |
| 2215 // |
| 2216 ClassElementImpl classElement = |
| 2217 ElementFactory.classElement('C', null, ['S']); |
| 2218 MethodElementImpl method = new MethodElementImpl('m', 0); |
| 2219 method.enclosingElement = classElement; |
| 2220 method.typeParameters = ElementFactory.typeParameters(['T']); |
| 2221 method.returnType = ElementFactory.objectType; |
| 2222 method.type = new FunctionTypeImpl(method); |
| 2223 |
| 2224 expect(method.type.typeArguments, |
| 2225 unorderedEquals(_toTypes(classElement.typeParameters))); |
| 2226 expect(method.type.typeFormals, unorderedEquals(method.typeParameters)); |
| 2227 expect(method.type.typeParameters, |
| 2228 unorderedEquals(classElement.typeParameters)); |
| 2229 } |
| 2230 |
| 2231 void test_typeParameters_simpleMethod_simpleClass() { |
| 2232 // |
| 2233 // class C<S> { |
| 2234 // Object m<T>() => null; |
| 2235 // } |
| 2236 // |
| 2237 ClassElementImpl classElement = ElementFactory.classElement2('C'); |
| 2238 MethodElementImpl method = new MethodElementImpl('m', 0); |
| 2239 method.enclosingElement = classElement; |
| 2240 method.typeParameters = ElementFactory.typeParameters(['T']); |
| 2241 method.returnType = ElementFactory.objectType; |
| 2242 method.type = new FunctionTypeImpl(method); |
| 2243 |
| 2244 expect(method.type.typeArguments, |
| 2245 unorderedEquals(_toTypes(classElement.typeParameters))); |
| 2246 expect(method.type.typeFormals, unorderedEquals(method.typeParameters)); |
| 2247 expect(method.type.typeParameters, |
| 2248 unorderedEquals(classElement.typeParameters)); |
| 2249 } |
| 2250 |
| 2251 void test_withTypeArguments() { |
| 2252 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); |
| 2253 MethodElementImpl methodElement = |
| 2254 new MethodElementImpl.forNode(AstFactory.identifier3("m")); |
| 2255 enclosingClass.methods = <MethodElement>[methodElement]; |
| 2256 FunctionTypeImpl type = new FunctionTypeImpl(methodElement); |
| 2257 DartType expectedType = enclosingClass.typeParameters[0].type; |
| 2258 List<DartType> arguments = type.typeArguments; |
| 2259 expect(arguments, hasLength(1)); |
| 2260 expect(arguments[0], expectedType); |
| 2261 } |
| 2262 |
| 2263 Iterable<DartType> _toTypes(List<TypeParameterElement> typeParameters) { |
| 2264 return typeParameters.map((TypeParameterElement element) => element.type); |
| 2265 } |
| 1990 } | 2266 } |
| 1991 | 2267 |
| 1992 @reflectiveTest | |
| 1993 class HtmlElementImplTest extends EngineTestCase { | |
| 1994 void test_equals_differentSource() { | |
| 1995 AnalysisContext context = createAnalysisContext(); | |
| 1996 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html"); | |
| 1997 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html"); | |
| 1998 expect(elementA == elementB, isFalse); | |
| 1999 } | |
| 2000 | |
| 2001 void test_equals_null() { | |
| 2002 AnalysisContext context = createAnalysisContext(); | |
| 2003 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); | |
| 2004 expect(element == null, isFalse); | |
| 2005 } | |
| 2006 | |
| 2007 void test_equals_sameSource() { | |
| 2008 AnalysisContext context = createAnalysisContext(); | |
| 2009 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html"); | |
| 2010 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html"); | |
| 2011 expect(elementA == elementB, isTrue); | |
| 2012 } | |
| 2013 | |
| 2014 void test_equals_self() { | |
| 2015 AnalysisContext context = createAnalysisContext(); | |
| 2016 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); | |
| 2017 expect(element == element, isTrue); | |
| 2018 } | |
| 2019 } | |
| 2020 | |
| 2021 @reflectiveTest | 2268 @reflectiveTest |
| 2022 class InterfaceTypeImplTest extends EngineTestCase { | 2269 class InterfaceTypeImplTest extends EngineTestCase { |
| 2023 /** | 2270 /** |
| 2024 * The type provider used to access the types. | 2271 * The type provider used to access the types. |
| 2025 */ | 2272 */ |
| 2026 TestTypeProvider _typeProvider; | 2273 TestTypeProvider _typeProvider; |
| 2027 | 2274 |
| 2028 @override | 2275 @override |
| 2029 void setUp() { | 2276 void setUp() { |
| 2277 super.setUp(); |
| 2030 _typeProvider = new TestTypeProvider(); | 2278 _typeProvider = new TestTypeProvider(); |
| 2031 } | 2279 } |
| 2032 | 2280 |
| 2033 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() { | 2281 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() { |
| 2034 // | 2282 // |
| 2035 // Object | 2283 // Object |
| 2036 // | | 2284 // | |
| 2037 // A | 2285 // A |
| 2038 // / \ | 2286 // / \ |
| 2039 // B C | 2287 // B C |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2419 expect(typeA.getGetter(getterName), same(getterG)); | 2667 expect(typeA.getGetter(getterName), same(getterG)); |
| 2420 } | 2668 } |
| 2421 | 2669 |
| 2422 void test_getGetter_parameterized() { | 2670 void test_getGetter_parameterized() { |
| 2423 // | 2671 // |
| 2424 // class A<E> { E get g {} } | 2672 // class A<E> { E get g {} } |
| 2425 // | 2673 // |
| 2426 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2674 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2427 DartType typeE = classA.type.typeArguments[0]; | 2675 DartType typeE = classA.type.typeArguments[0]; |
| 2428 String getterName = "g"; | 2676 String getterName = "g"; |
| 2429 PropertyAccessorElement getterG = | 2677 PropertyAccessorElementImpl getterG = |
| 2430 ElementFactory.getterElement(getterName, false, typeE); | 2678 ElementFactory.getterElement(getterName, false, typeE); |
| 2431 classA.accessors = <PropertyAccessorElement>[getterG]; | 2679 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 2432 (getterG.type as FunctionTypeImpl).typeArguments = | 2680 getterG.type = new FunctionTypeImpl(getterG); |
| 2433 classA.type.typeArguments; | |
| 2434 // | 2681 // |
| 2435 // A<I> | 2682 // A<I> |
| 2436 // | 2683 // |
| 2437 InterfaceType typeI = ElementFactory.classElement2("I").type; | 2684 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2438 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); | 2685 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 2439 typeAI.typeArguments = <DartType>[typeI]; | 2686 typeAI.typeArguments = <DartType>[typeI]; |
| 2440 PropertyAccessorElement getter = typeAI.getGetter(getterName); | 2687 PropertyAccessorElement getter = typeAI.getGetter(getterName); |
| 2441 expect(getter, isNotNull); | 2688 expect(getter, isNotNull); |
| 2442 FunctionType getterType = getter.type; | 2689 FunctionType getterType = getter.type; |
| 2443 expect(getterType.returnType, same(typeI)); | 2690 expect(getterType.returnType, same(typeI)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 InterfaceType typeI = ElementFactory.classElement2("I").type; | 2736 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2490 InterfaceTypeImpl typeBI = new InterfaceTypeImpl(classB); | 2737 InterfaceTypeImpl typeBI = new InterfaceTypeImpl(classB); |
| 2491 typeBI.typeArguments = <DartType>[typeI]; | 2738 typeBI.typeArguments = <DartType>[typeI]; |
| 2492 List<InterfaceType> interfaces = typeBI.interfaces; | 2739 List<InterfaceType> interfaces = typeBI.interfaces; |
| 2493 expect(interfaces, hasLength(1)); | 2740 expect(interfaces, hasLength(1)); |
| 2494 InterfaceType result = interfaces[0]; | 2741 InterfaceType result = interfaces[0]; |
| 2495 expect(result.element, same(classA)); | 2742 expect(result.element, same(classA)); |
| 2496 expect(result.typeArguments[0], same(typeI)); | 2743 expect(result.typeArguments[0], same(typeI)); |
| 2497 } | 2744 } |
| 2498 | 2745 |
| 2499 void test_getLeastUpperBound_directInterfaceCase() { | |
| 2500 // | |
| 2501 // class A | |
| 2502 // class B implements A | |
| 2503 // class C implements B | |
| 2504 // | |
| 2505 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2506 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2507 ClassElementImpl classC = ElementFactory.classElement2("C"); | |
| 2508 InterfaceType typeA = classA.type; | |
| 2509 InterfaceType typeB = classB.type; | |
| 2510 InterfaceType typeC = classC.type; | |
| 2511 classB.interfaces = <InterfaceType>[typeA]; | |
| 2512 classC.interfaces = <InterfaceType>[typeB]; | |
| 2513 expect(typeB.getLeastUpperBound(typeC), typeB); | |
| 2514 expect(typeC.getLeastUpperBound(typeB), typeB); | |
| 2515 } | |
| 2516 | |
| 2517 void test_getLeastUpperBound_directSubclassCase() { | |
| 2518 // | |
| 2519 // class A | |
| 2520 // class B extends A | |
| 2521 // class C extends B | |
| 2522 // | |
| 2523 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2524 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | |
| 2525 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | |
| 2526 InterfaceType typeB = classB.type; | |
| 2527 InterfaceType typeC = classC.type; | |
| 2528 expect(typeB.getLeastUpperBound(typeC), typeB); | |
| 2529 expect(typeC.getLeastUpperBound(typeB), typeB); | |
| 2530 } | |
| 2531 | |
| 2532 void test_getLeastUpperBound_functionType() { | |
| 2533 DartType interfaceType = ElementFactory.classElement2("A").type; | |
| 2534 FunctionTypeImpl functionType = new FunctionTypeImpl( | |
| 2535 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))); | |
| 2536 expect(interfaceType.getLeastUpperBound(functionType), isNull); | |
| 2537 } | |
| 2538 | |
| 2539 void test_getLeastUpperBound_mixinCase() { | |
| 2540 // | |
| 2541 // class A | |
| 2542 // class B extends A | |
| 2543 // class C extends A | |
| 2544 // class D extends B with M, N, O, P | |
| 2545 // | |
| 2546 ClassElement classA = ElementFactory.classElement2("A"); | |
| 2547 ClassElement classB = ElementFactory.classElement("B", classA.type); | |
| 2548 ClassElement classC = ElementFactory.classElement("C", classA.type); | |
| 2549 ClassElementImpl classD = ElementFactory.classElement("D", classB.type); | |
| 2550 InterfaceType typeA = classA.type; | |
| 2551 InterfaceType typeC = classC.type; | |
| 2552 InterfaceType typeD = classD.type; | |
| 2553 classD.mixins = <InterfaceType>[ | |
| 2554 ElementFactory.classElement2("M").type, | |
| 2555 ElementFactory.classElement2("N").type, | |
| 2556 ElementFactory.classElement2("O").type, | |
| 2557 ElementFactory.classElement2("P").type | |
| 2558 ]; | |
| 2559 expect(typeD.getLeastUpperBound(typeC), typeA); | |
| 2560 expect(typeC.getLeastUpperBound(typeD), typeA); | |
| 2561 } | |
| 2562 | |
| 2563 void test_getLeastUpperBound_null() { | |
| 2564 DartType interfaceType = ElementFactory.classElement2("A").type; | |
| 2565 expect(interfaceType.getLeastUpperBound(null), isNull); | |
| 2566 } | |
| 2567 | |
| 2568 void test_getLeastUpperBound_object() { | |
| 2569 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2570 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2571 InterfaceType typeA = classA.type; | |
| 2572 InterfaceType typeB = classB.type; | |
| 2573 DartType typeObject = typeA.element.supertype; | |
| 2574 // assert that object does not have a super type | |
| 2575 expect((typeObject.element as ClassElement).supertype, isNull); | |
| 2576 // assert that both A and B have the same super type of Object | |
| 2577 expect(typeB.element.supertype, typeObject); | |
| 2578 // finally, assert that the only least upper bound of A and B is Object | |
| 2579 expect(typeA.getLeastUpperBound(typeB), typeObject); | |
| 2580 } | |
| 2581 | |
| 2582 void test_getLeastUpperBound_self() { | |
| 2583 ClassElement classA = ElementFactory.classElement2("A"); | |
| 2584 InterfaceType typeA = classA.type; | |
| 2585 expect(typeA.getLeastUpperBound(typeA), typeA); | |
| 2586 } | |
| 2587 | |
| 2588 void test_getLeastUpperBound_sharedSuperclass1() { | |
| 2589 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2590 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | |
| 2591 ClassElementImpl classC = ElementFactory.classElement("C", classA.type); | |
| 2592 InterfaceType typeA = classA.type; | |
| 2593 InterfaceType typeB = classB.type; | |
| 2594 InterfaceType typeC = classC.type; | |
| 2595 expect(typeB.getLeastUpperBound(typeC), typeA); | |
| 2596 expect(typeC.getLeastUpperBound(typeB), typeA); | |
| 2597 } | |
| 2598 | |
| 2599 void test_getLeastUpperBound_sharedSuperclass2() { | |
| 2600 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2601 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | |
| 2602 ClassElementImpl classC = ElementFactory.classElement("C", classA.type); | |
| 2603 ClassElementImpl classD = ElementFactory.classElement("D", classC.type); | |
| 2604 InterfaceType typeA = classA.type; | |
| 2605 InterfaceType typeB = classB.type; | |
| 2606 InterfaceType typeD = classD.type; | |
| 2607 expect(typeB.getLeastUpperBound(typeD), typeA); | |
| 2608 expect(typeD.getLeastUpperBound(typeB), typeA); | |
| 2609 } | |
| 2610 | |
| 2611 void test_getLeastUpperBound_sharedSuperclass3() { | |
| 2612 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2613 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | |
| 2614 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | |
| 2615 ClassElementImpl classD = ElementFactory.classElement("D", classB.type); | |
| 2616 InterfaceType typeB = classB.type; | |
| 2617 InterfaceType typeC = classC.type; | |
| 2618 InterfaceType typeD = classD.type; | |
| 2619 expect(typeC.getLeastUpperBound(typeD), typeB); | |
| 2620 expect(typeD.getLeastUpperBound(typeC), typeB); | |
| 2621 } | |
| 2622 | |
| 2623 void test_getLeastUpperBound_sharedSuperclass4() { | |
| 2624 ClassElement classA = ElementFactory.classElement2("A"); | |
| 2625 ClassElement classA2 = ElementFactory.classElement2("A2"); | |
| 2626 ClassElement classA3 = ElementFactory.classElement2("A3"); | |
| 2627 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | |
| 2628 ClassElementImpl classC = ElementFactory.classElement("C", classA.type); | |
| 2629 InterfaceType typeA = classA.type; | |
| 2630 InterfaceType typeA2 = classA2.type; | |
| 2631 InterfaceType typeA3 = classA3.type; | |
| 2632 InterfaceType typeB = classB.type; | |
| 2633 InterfaceType typeC = classC.type; | |
| 2634 classB.interfaces = <InterfaceType>[typeA2]; | |
| 2635 classC.interfaces = <InterfaceType>[typeA3]; | |
| 2636 expect(typeB.getLeastUpperBound(typeC), typeA); | |
| 2637 expect(typeC.getLeastUpperBound(typeB), typeA); | |
| 2638 } | |
| 2639 | |
| 2640 void test_getLeastUpperBound_sharedSuperinterface1() { | |
| 2641 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2642 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2643 ClassElementImpl classC = ElementFactory.classElement2("C"); | |
| 2644 InterfaceType typeA = classA.type; | |
| 2645 InterfaceType typeB = classB.type; | |
| 2646 InterfaceType typeC = classC.type; | |
| 2647 classB.interfaces = <InterfaceType>[typeA]; | |
| 2648 classC.interfaces = <InterfaceType>[typeA]; | |
| 2649 expect(typeB.getLeastUpperBound(typeC), typeA); | |
| 2650 expect(typeC.getLeastUpperBound(typeB), typeA); | |
| 2651 } | |
| 2652 | |
| 2653 void test_getLeastUpperBound_sharedSuperinterface2() { | |
| 2654 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2655 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2656 ClassElementImpl classC = ElementFactory.classElement2("C"); | |
| 2657 ClassElementImpl classD = ElementFactory.classElement2("D"); | |
| 2658 InterfaceType typeA = classA.type; | |
| 2659 InterfaceType typeB = classB.type; | |
| 2660 InterfaceType typeC = classC.type; | |
| 2661 InterfaceType typeD = classD.type; | |
| 2662 classB.interfaces = <InterfaceType>[typeA]; | |
| 2663 classC.interfaces = <InterfaceType>[typeA]; | |
| 2664 classD.interfaces = <InterfaceType>[typeC]; | |
| 2665 expect(typeB.getLeastUpperBound(typeD), typeA); | |
| 2666 expect(typeD.getLeastUpperBound(typeB), typeA); | |
| 2667 } | |
| 2668 | |
| 2669 void test_getLeastUpperBound_sharedSuperinterface3() { | |
| 2670 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
| 2671 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2672 ClassElementImpl classC = ElementFactory.classElement2("C"); | |
| 2673 ClassElementImpl classD = ElementFactory.classElement2("D"); | |
| 2674 InterfaceType typeA = classA.type; | |
| 2675 InterfaceType typeB = classB.type; | |
| 2676 InterfaceType typeC = classC.type; | |
| 2677 InterfaceType typeD = classD.type; | |
| 2678 classB.interfaces = <InterfaceType>[typeA]; | |
| 2679 classC.interfaces = <InterfaceType>[typeB]; | |
| 2680 classD.interfaces = <InterfaceType>[typeB]; | |
| 2681 expect(typeC.getLeastUpperBound(typeD), typeB); | |
| 2682 expect(typeD.getLeastUpperBound(typeC), typeB); | |
| 2683 } | |
| 2684 | |
| 2685 void test_getLeastUpperBound_sharedSuperinterface4() { | |
| 2686 ClassElement classA = ElementFactory.classElement2("A"); | |
| 2687 ClassElement classA2 = ElementFactory.classElement2("A2"); | |
| 2688 ClassElement classA3 = ElementFactory.classElement2("A3"); | |
| 2689 ClassElementImpl classB = ElementFactory.classElement2("B"); | |
| 2690 ClassElementImpl classC = ElementFactory.classElement2("C"); | |
| 2691 InterfaceType typeA = classA.type; | |
| 2692 InterfaceType typeA2 = classA2.type; | |
| 2693 InterfaceType typeA3 = classA3.type; | |
| 2694 InterfaceType typeB = classB.type; | |
| 2695 InterfaceType typeC = classC.type; | |
| 2696 classB.interfaces = <InterfaceType>[typeA, typeA2]; | |
| 2697 classC.interfaces = <InterfaceType>[typeA, typeA3]; | |
| 2698 expect(typeB.getLeastUpperBound(typeC), typeA); | |
| 2699 expect(typeC.getLeastUpperBound(typeB), typeA); | |
| 2700 } | |
| 2701 | |
| 2702 void test_getLeastUpperBound_twoComparables() { | |
| 2703 InterfaceType string = _typeProvider.stringType; | |
| 2704 InterfaceType num = _typeProvider.numType; | |
| 2705 expect(string.getLeastUpperBound(num), _typeProvider.objectType); | |
| 2706 } | |
| 2707 | |
| 2708 void test_getLeastUpperBound_typeParameters_different() { | |
| 2709 // | |
| 2710 // class List<int> | |
| 2711 // class List<double> | |
| 2712 // | |
| 2713 InterfaceType listType = _typeProvider.listType; | |
| 2714 InterfaceType intType = _typeProvider.intType; | |
| 2715 InterfaceType doubleType = _typeProvider.doubleType; | |
| 2716 InterfaceType listOfIntType = listType.substitute4(<DartType>[intType]); | |
| 2717 InterfaceType listOfDoubleType = | |
| 2718 listType.substitute4(<DartType>[doubleType]); | |
| 2719 expect(listOfIntType.getLeastUpperBound(listOfDoubleType), | |
| 2720 _typeProvider.objectType); | |
| 2721 } | |
| 2722 | |
| 2723 void test_getLeastUpperBound_typeParameters_same() { | |
| 2724 // | |
| 2725 // List<int> | |
| 2726 // List<int> | |
| 2727 // | |
| 2728 InterfaceType listType = _typeProvider.listType; | |
| 2729 InterfaceType intType = _typeProvider.intType; | |
| 2730 InterfaceType listOfIntType = listType.substitute4(<DartType>[intType]); | |
| 2731 expect(listOfIntType.getLeastUpperBound(listOfIntType), listOfIntType); | |
| 2732 } | |
| 2733 | |
| 2734 void test_getMethod_implemented() { | 2746 void test_getMethod_implemented() { |
| 2735 // | 2747 // |
| 2736 // class A { m() {} } | 2748 // class A { m() {} } |
| 2737 // | 2749 // |
| 2738 ClassElementImpl classA = ElementFactory.classElement2("A"); | 2750 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 2739 String methodName = "m"; | 2751 String methodName = "m"; |
| 2740 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null); | 2752 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null); |
| 2741 classA.methods = <MethodElement>[methodM]; | 2753 classA.methods = <MethodElement>[methodM]; |
| 2742 InterfaceType typeA = classA.type; | 2754 InterfaceType typeA = classA.type; |
| 2743 expect(typeA.getMethod(methodName), same(methodM)); | 2755 expect(typeA.getMethod(methodName), same(methodM)); |
| 2744 } | 2756 } |
| 2745 | 2757 |
| 2746 void test_getMethod_parameterized() { | 2758 void test_getMethod_parameterized_doesNotUseTypeParameter() { |
| 2759 // |
| 2760 // class A<E> { void m() {} } |
| 2761 // class B {} |
| 2762 // |
| 2763 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2764 InterfaceType typeB = ElementFactory.classElement2("B").type; |
| 2765 DartType typeE = classA.type.typeArguments[0]; |
| 2766 String methodName = "m"; |
| 2767 MethodElementImpl methodM = |
| 2768 ElementFactory.methodElement(methodName, typeB, []); |
| 2769 classA.methods = <MethodElement>[methodM]; |
| 2770 methodM.type = new FunctionTypeImpl(methodM); |
| 2771 // |
| 2772 // A<I> |
| 2773 // |
| 2774 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2775 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 2776 typeAI.typeArguments = <DartType>[typeI]; |
| 2777 MethodElement method = typeAI.getMethod(methodName); |
| 2778 expect(method, isNotNull); |
| 2779 FunctionType methodType = method.type; |
| 2780 expect(methodType.typeParameters, [same(typeE.element)]); |
| 2781 expect(methodType.typeArguments, [same(typeI)]); |
| 2782 } |
| 2783 |
| 2784 void test_getMethod_parameterized_flushCached_whenVersionChanges() { |
| 2747 // | 2785 // |
| 2748 // class A<E> { E m(E p) {} } | 2786 // class A<E> { E m(E p) {} } |
| 2749 // | 2787 // |
| 2788 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2789 DartType typeE = classA.type.typeArguments[0]; |
| 2790 String methodName = "m"; |
| 2791 MethodElementImpl methodM = |
| 2792 ElementFactory.methodElement(methodName, typeE, [typeE]); |
| 2793 classA.methods = <MethodElement>[methodM]; |
| 2794 methodM.type = new FunctionTypeImpl(methodM); |
| 2795 // |
| 2796 // A<I> |
| 2797 // |
| 2798 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2799 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 2800 typeAI.typeArguments = <DartType>[typeI]; |
| 2801 // Methods list is cached. |
| 2802 MethodElement method = typeAI.methods.single; |
| 2803 expect(typeAI.methods.single, same(method)); |
| 2804 // Methods list is flushed on version change. |
| 2805 classA.version++; |
| 2806 expect(typeAI.methods.single, isNot(same(method))); |
| 2807 } |
| 2808 |
| 2809 void test_getMethod_parameterized_usesTypeParameter() { |
| 2810 // |
| 2811 // class A<E> { E m(E p) {} } |
| 2812 // |
| 2750 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2813 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2751 DartType typeE = classA.type.typeArguments[0]; | 2814 DartType typeE = classA.type.typeArguments[0]; |
| 2752 String methodName = "m"; | 2815 String methodName = "m"; |
| 2753 MethodElementImpl methodM = | 2816 MethodElementImpl methodM = |
| 2754 ElementFactory.methodElement(methodName, typeE, [typeE]); | 2817 ElementFactory.methodElement(methodName, typeE, [typeE]); |
| 2755 classA.methods = <MethodElement>[methodM]; | 2818 classA.methods = <MethodElement>[methodM]; |
| 2756 (methodM.type as FunctionTypeImpl).typeArguments = | 2819 methodM.type = new FunctionTypeImpl(methodM); |
| 2757 classA.type.typeArguments; | |
| 2758 // | 2820 // |
| 2759 // A<I> | 2821 // A<I> |
| 2760 // | 2822 // |
| 2761 InterfaceType typeI = ElementFactory.classElement2("I").type; | 2823 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2762 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); | 2824 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 2763 typeAI.typeArguments = <DartType>[typeI]; | 2825 typeAI.typeArguments = <DartType>[typeI]; |
| 2764 MethodElement method = typeAI.getMethod(methodName); | 2826 MethodElement method = typeAI.getMethod(methodName); |
| 2765 expect(method, isNotNull); | 2827 expect(method, isNotNull); |
| 2766 FunctionType methodType = method.type; | 2828 FunctionType methodType = method.type; |
| 2829 expect(methodType.typeParameters, [same(typeE.element)]); |
| 2830 expect(methodType.typeArguments, [same(typeI)]); |
| 2767 expect(methodType.returnType, same(typeI)); | 2831 expect(methodType.returnType, same(typeI)); |
| 2768 List<DartType> parameterTypes = methodType.normalParameterTypes; | 2832 List<DartType> parameterTypes = methodType.normalParameterTypes; |
| 2769 expect(parameterTypes, hasLength(1)); | 2833 expect(parameterTypes, hasLength(1)); |
| 2770 expect(parameterTypes[0], same(typeI)); | 2834 expect(parameterTypes[0], same(typeI)); |
| 2771 } | 2835 } |
| 2772 | 2836 |
| 2773 void test_getMethod_unimplemented() { | 2837 void test_getMethod_unimplemented() { |
| 2774 // | 2838 // |
| 2775 // class A {} | 2839 // class A {} |
| 2776 // | 2840 // |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 expect(typeA.getSetter(setterName), same(setterS)); | 2915 expect(typeA.getSetter(setterName), same(setterS)); |
| 2852 } | 2916 } |
| 2853 | 2917 |
| 2854 void test_getSetter_parameterized() { | 2918 void test_getSetter_parameterized() { |
| 2855 // | 2919 // |
| 2856 // class A<E> { set s(E p) {} } | 2920 // class A<E> { set s(E p) {} } |
| 2857 // | 2921 // |
| 2858 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2922 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2859 DartType typeE = classA.type.typeArguments[0]; | 2923 DartType typeE = classA.type.typeArguments[0]; |
| 2860 String setterName = "s"; | 2924 String setterName = "s"; |
| 2861 PropertyAccessorElement setterS = | 2925 PropertyAccessorElementImpl setterS = |
| 2862 ElementFactory.setterElement(setterName, false, typeE); | 2926 ElementFactory.setterElement(setterName, false, typeE); |
| 2863 classA.accessors = <PropertyAccessorElement>[setterS]; | 2927 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 2864 (setterS.type as FunctionTypeImpl).typeArguments = | 2928 setterS.type = new FunctionTypeImpl(setterS); |
| 2865 classA.type.typeArguments; | |
| 2866 // | 2929 // |
| 2867 // A<I> | 2930 // A<I> |
| 2868 // | 2931 // |
| 2869 InterfaceType typeI = ElementFactory.classElement2("I").type; | 2932 InterfaceType typeI = ElementFactory.classElement2("I").type; |
| 2870 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); | 2933 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 2871 typeAI.typeArguments = <DartType>[typeI]; | 2934 typeAI.typeArguments = <DartType>[typeI]; |
| 2872 PropertyAccessorElement setter = typeAI.getSetter(setterName); | 2935 PropertyAccessorElement setter = typeAI.getSetter(setterName); |
| 2873 expect(setter, isNotNull); | 2936 expect(setter, isNotNull); |
| 2874 FunctionType setterType = setter.type; | 2937 FunctionType setterType = setter.type; |
| 2875 List<DartType> parameterTypes = setterType.normalParameterTypes; | 2938 List<DartType> parameterTypes = setterType.normalParameterTypes; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 void test_isMoreSpecificThan_dynamic() { | 3082 void test_isMoreSpecificThan_dynamic() { |
| 3020 InterfaceType type = ElementFactory.classElement2("A").type; | 3083 InterfaceType type = ElementFactory.classElement2("A").type; |
| 3021 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); | 3084 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); |
| 3022 } | 3085 } |
| 3023 | 3086 |
| 3024 void test_isMoreSpecificThan_generic() { | 3087 void test_isMoreSpecificThan_generic() { |
| 3025 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 3088 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 3026 ClassElement classB = ElementFactory.classElement2("B"); | 3089 ClassElement classB = ElementFactory.classElement2("B"); |
| 3027 DartType dynamicType = DynamicTypeImpl.instance; | 3090 DartType dynamicType = DynamicTypeImpl.instance; |
| 3028 InterfaceType typeAOfDynamic = | 3091 InterfaceType typeAOfDynamic = |
| 3029 classA.type.substitute4(<DartType>[dynamicType]); | 3092 classA.type.instantiate(<DartType>[dynamicType]); |
| 3030 InterfaceType typeAOfB = classA.type.substitute4(<DartType>[classB.type]); | 3093 InterfaceType typeAOfB = classA.type.instantiate(<DartType>[classB.type]); |
| 3031 expect(typeAOfDynamic.isMoreSpecificThan(typeAOfB), isFalse); | 3094 expect(typeAOfDynamic.isMoreSpecificThan(typeAOfB), isFalse); |
| 3032 expect(typeAOfB.isMoreSpecificThan(typeAOfDynamic), isTrue); | 3095 expect(typeAOfB.isMoreSpecificThan(typeAOfDynamic), isTrue); |
| 3033 } | 3096 } |
| 3034 | 3097 |
| 3035 void test_isMoreSpecificThan_self() { | 3098 void test_isMoreSpecificThan_self() { |
| 3036 InterfaceType type = ElementFactory.classElement2("A").type; | 3099 InterfaceType type = ElementFactory.classElement2("A").type; |
| 3037 expect(type.isMoreSpecificThan(type), isTrue); | 3100 expect(type.isMoreSpecificThan(type), isTrue); |
| 3038 } | 3101 } |
| 3039 | 3102 |
| 3040 void test_isMoreSpecificThan_transitive_interface() { | 3103 void test_isMoreSpecificThan_transitive_interface() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 FunctionType functionType = ElementFactory | 3220 FunctionType functionType = ElementFactory |
| 3158 .functionElement5("f", <ClassElement>[stringType.element]).type; | 3221 .functionElement5("f", <ClassElement>[stringType.element]).type; |
| 3159 expect(classA.type.isSubtypeOf(functionType), isTrue); | 3222 expect(classA.type.isSubtypeOf(functionType), isTrue); |
| 3160 } | 3223 } |
| 3161 | 3224 |
| 3162 void test_isSubtypeOf_generic() { | 3225 void test_isSubtypeOf_generic() { |
| 3163 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 3226 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 3164 ClassElement classB = ElementFactory.classElement2("B"); | 3227 ClassElement classB = ElementFactory.classElement2("B"); |
| 3165 DartType dynamicType = DynamicTypeImpl.instance; | 3228 DartType dynamicType = DynamicTypeImpl.instance; |
| 3166 InterfaceType typeAOfDynamic = | 3229 InterfaceType typeAOfDynamic = |
| 3167 classA.type.substitute4(<DartType>[dynamicType]); | 3230 classA.type.instantiate(<DartType>[dynamicType]); |
| 3168 InterfaceType typeAOfB = classA.type.substitute4(<DartType>[classB.type]); | 3231 InterfaceType typeAOfB = classA.type.instantiate(<DartType>[classB.type]); |
| 3169 expect(typeAOfDynamic.isSubtypeOf(typeAOfB), isTrue); | 3232 expect(typeAOfDynamic.isSubtypeOf(typeAOfB), isTrue); |
| 3170 expect(typeAOfB.isSubtypeOf(typeAOfDynamic), isTrue); | 3233 expect(typeAOfB.isSubtypeOf(typeAOfDynamic), isTrue); |
| 3171 } | 3234 } |
| 3172 | 3235 |
| 3173 void test_isSubtypeOf_interface() { | 3236 void test_isSubtypeOf_interface() { |
| 3174 ClassElement classA = ElementFactory.classElement2("A"); | 3237 ClassElement classA = ElementFactory.classElement2("A"); |
| 3175 ClassElement classB = ElementFactory.classElement("B", classA.type); | 3238 ClassElement classB = ElementFactory.classElement("B", classA.type); |
| 3176 ClassElementImpl classC = ElementFactory.classElement2("C"); | 3239 ClassElementImpl classC = ElementFactory.classElement2("C"); |
| 3177 InterfaceType typeObject = classA.supertype; | 3240 InterfaceType typeObject = classA.supertype; |
| 3178 InterfaceType typeA = classA.type; | 3241 InterfaceType typeA = classA.type; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 expect(typeA.isSubtypeOf(typeC), isFalse); | 3307 expect(typeA.isSubtypeOf(typeC), isFalse); |
| 3245 } | 3308 } |
| 3246 | 3309 |
| 3247 void test_isSubtypeOf_typeArguments() { | 3310 void test_isSubtypeOf_typeArguments() { |
| 3248 DartType dynamicType = DynamicTypeImpl.instance; | 3311 DartType dynamicType = DynamicTypeImpl.instance; |
| 3249 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 3312 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 3250 ClassElement classI = ElementFactory.classElement2("I"); | 3313 ClassElement classI = ElementFactory.classElement2("I"); |
| 3251 ClassElement classJ = ElementFactory.classElement("J", classI.type); | 3314 ClassElement classJ = ElementFactory.classElement("J", classI.type); |
| 3252 ClassElement classK = ElementFactory.classElement2("K"); | 3315 ClassElement classK = ElementFactory.classElement2("K"); |
| 3253 InterfaceType typeA = classA.type; | 3316 InterfaceType typeA = classA.type; |
| 3254 InterfaceType typeA_dynamic = typeA.substitute4(<DartType>[dynamicType]); | 3317 InterfaceType typeA_dynamic = typeA.instantiate(<DartType>[dynamicType]); |
| 3255 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); | 3318 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA); |
| 3256 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl(classA); | 3319 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl(classA); |
| 3257 InterfaceTypeImpl typeAK = new InterfaceTypeImpl(classA); | 3320 InterfaceTypeImpl typeAK = new InterfaceTypeImpl(classA); |
| 3258 typeAI.typeArguments = <DartType>[classI.type]; | 3321 typeAI.typeArguments = <DartType>[classI.type]; |
| 3259 typeAJ.typeArguments = <DartType>[classJ.type]; | 3322 typeAJ.typeArguments = <DartType>[classJ.type]; |
| 3260 typeAK.typeArguments = <DartType>[classK.type]; | 3323 typeAK.typeArguments = <DartType>[classK.type]; |
| 3261 // A<J> <: A<I> since J <: I | 3324 // A<J> <: A<I> since J <: I |
| 3262 expect(typeAJ.isSubtypeOf(typeAI), isTrue); | 3325 expect(typeAJ.isSubtypeOf(typeAI), isTrue); |
| 3263 expect(typeAI.isSubtypeOf(typeAJ), isFalse); | 3326 expect(typeAI.isSubtypeOf(typeAJ), isFalse); |
| 3264 // A<I> <: A<I> since I <: I | 3327 // A<I> <: A<I> since I <: I |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3516 // | 3579 // |
| 3517 // class A<E> { E m(E p) {} } | 3580 // class A<E> { E m(E p) {} } |
| 3518 // class B<F> extends A<F> {} | 3581 // class B<F> extends A<F> {} |
| 3519 // | 3582 // |
| 3520 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 3583 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 3521 DartType typeE = classA.type.typeArguments[0]; | 3584 DartType typeE = classA.type.typeArguments[0]; |
| 3522 String methodName = "m"; | 3585 String methodName = "m"; |
| 3523 MethodElementImpl methodM = | 3586 MethodElementImpl methodM = |
| 3524 ElementFactory.methodElement(methodName, typeE, [typeE]); | 3587 ElementFactory.methodElement(methodName, typeE, [typeE]); |
| 3525 classA.methods = <MethodElement>[methodM]; | 3588 classA.methods = <MethodElement>[methodM]; |
| 3526 (methodM.type as FunctionTypeImpl).typeArguments = | 3589 methodM.type = new FunctionTypeImpl(methodM); |
| 3527 classA.type.typeArguments; | |
| 3528 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); | 3590 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); |
| 3529 InterfaceType typeB = classB.type; | 3591 InterfaceType typeB = classB.type; |
| 3530 InterfaceTypeImpl typeAF = new InterfaceTypeImpl(classA); | 3592 InterfaceTypeImpl typeAF = new InterfaceTypeImpl(classA); |
| 3531 typeAF.typeArguments = <DartType>[typeB.typeArguments[0]]; | 3593 typeAF.typeArguments = <DartType>[typeB.typeArguments[0]]; |
| 3532 classB.supertype = typeAF; | 3594 classB.supertype = typeAF; |
| 3533 LibraryElementImpl library = | 3595 LibraryElementImpl library = |
| 3534 ElementFactory.library(createAnalysisContext(), "lib"); | 3596 ElementFactory.library(createAnalysisContext(), "lib"); |
| 3535 CompilationUnitElement unit = library.definingCompilationUnit; | 3597 CompilationUnitElement unit = library.definingCompilationUnit; |
| 3536 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA]; | 3598 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA]; |
| 3537 // | 3599 // |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3663 // | 3725 // |
| 3664 ClassElementImpl classA = ElementFactory.classElement2("A"); | 3726 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 3665 InterfaceType typeA = classA.type; | 3727 InterfaceType typeA = classA.type; |
| 3666 LibraryElementImpl library = | 3728 LibraryElementImpl library = |
| 3667 ElementFactory.library(createAnalysisContext(), "lib"); | 3729 ElementFactory.library(createAnalysisContext(), "lib"); |
| 3668 CompilationUnitElement unit = library.definingCompilationUnit; | 3730 CompilationUnitElement unit = library.definingCompilationUnit; |
| 3669 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA]; | 3731 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA]; |
| 3670 expect(typeA.lookUpSetter("s", library), isNull); | 3732 expect(typeA.lookUpSetter("s", library), isNull); |
| 3671 } | 3733 } |
| 3672 | 3734 |
| 3735 void test_resolveToBound() { |
| 3736 InterfaceTypeImpl type = |
| 3737 ElementFactory.classElement2("A").type as InterfaceTypeImpl; |
| 3738 |
| 3739 // Returns this. |
| 3740 expect(type.resolveToBound(null), same(type)); |
| 3741 } |
| 3742 |
| 3673 void test_setTypeArguments() { | 3743 void test_setTypeArguments() { |
| 3674 InterfaceTypeImpl type = | 3744 InterfaceTypeImpl type = |
| 3675 ElementFactory.classElement2("A").type as InterfaceTypeImpl; | 3745 ElementFactory.classElement2("A").type as InterfaceTypeImpl; |
| 3676 List<DartType> typeArguments = <DartType>[ | 3746 List<DartType> typeArguments = <DartType>[ |
| 3677 ElementFactory.classElement2("B").type, | 3747 ElementFactory.classElement2("B").type, |
| 3678 ElementFactory.classElement2("C").type | 3748 ElementFactory.classElement2("C").type |
| 3679 ]; | 3749 ]; |
| 3680 type.typeArguments = typeArguments; | 3750 type.typeArguments = typeArguments; |
| 3681 expect(type.typeArguments, typeArguments); | 3751 expect(type.typeArguments, typeArguments); |
| 3682 } | 3752 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3793 CompilationUnitElement unitLib = library.definingCompilationUnit; | 3863 CompilationUnitElement unitLib = library.definingCompilationUnit; |
| 3794 CompilationUnitElementImpl unitA = | 3864 CompilationUnitElementImpl unitA = |
| 3795 ElementFactory.compilationUnit("unit_a.dart", unitLib.source); | 3865 ElementFactory.compilationUnit("unit_a.dart", unitLib.source); |
| 3796 CompilationUnitElementImpl unitB = | 3866 CompilationUnitElementImpl unitB = |
| 3797 ElementFactory.compilationUnit("unit_b.dart", unitLib.source); | 3867 ElementFactory.compilationUnit("unit_b.dart", unitLib.source); |
| 3798 library.parts = <CompilationUnitElement>[unitA, unitB]; | 3868 library.parts = <CompilationUnitElement>[unitA, unitB]; |
| 3799 expect(library.units, | 3869 expect(library.units, |
| 3800 unorderedEquals(<CompilationUnitElement>[unitLib, unitA, unitB])); | 3870 unorderedEquals(<CompilationUnitElement>[unitLib, unitA, unitB])); |
| 3801 } | 3871 } |
| 3802 | 3872 |
| 3803 void test_getVisibleLibraries_cycle() { | 3873 void test_invalidateLibraryCycles_withHandle() { |
| 3804 AnalysisContext context = createAnalysisContext(); | |
| 3805 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3806 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | |
| 3807 libraryA.imports = <ImportElementImpl>[ | |
| 3808 ElementFactory.importFor(library, null) | |
| 3809 ]; | |
| 3810 library.imports = <ImportElementImpl>[ | |
| 3811 ElementFactory.importFor(libraryA, null) | |
| 3812 ]; | |
| 3813 List<LibraryElement> libraries = library.visibleLibraries; | |
| 3814 expect(libraries, unorderedEquals(<LibraryElement>[library, libraryA])); | |
| 3815 } | |
| 3816 | |
| 3817 void test_getVisibleLibraries_directExports() { | |
| 3818 AnalysisContext context = createAnalysisContext(); | |
| 3819 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3820 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | |
| 3821 library.exports = <ExportElementImpl>[ElementFactory.exportFor(libraryA)]; | |
| 3822 List<LibraryElement> libraries = library.visibleLibraries; | |
| 3823 expect(libraries, unorderedEquals(<LibraryElement>[library])); | |
| 3824 } | |
| 3825 | |
| 3826 void test_getVisibleLibraries_directImports() { | |
| 3827 AnalysisContext context = createAnalysisContext(); | |
| 3828 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3829 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | |
| 3830 library.imports = <ImportElementImpl>[ | |
| 3831 ElementFactory.importFor(libraryA, null) | |
| 3832 ]; | |
| 3833 List<LibraryElement> libraries = library.visibleLibraries; | |
| 3834 expect(libraries, unorderedEquals(<LibraryElement>[library, libraryA])); | |
| 3835 } | |
| 3836 | |
| 3837 void test_getVisibleLibraries_indirectExports() { | |
| 3838 AnalysisContext context = createAnalysisContext(); | |
| 3839 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3840 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | |
| 3841 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA"); | |
| 3842 libraryA.exports = <ExportElementImpl>[ElementFactory.exportFor(libraryAA)]; | |
| 3843 library.imports = <ImportElementImpl>[ | |
| 3844 ElementFactory.importFor(libraryA, null) | |
| 3845 ]; | |
| 3846 List<LibraryElement> libraries = library.visibleLibraries; | |
| 3847 expect(libraries, | |
| 3848 unorderedEquals(<LibraryElement>[library, libraryA, libraryAA])); | |
| 3849 } | |
| 3850 | |
| 3851 void test_getVisibleLibraries_indirectImports() { | |
| 3852 AnalysisContext context = createAnalysisContext(); | |
| 3853 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3854 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | |
| 3855 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA"); | |
| 3856 LibraryElementImpl libraryB = ElementFactory.library(context, "B"); | |
| 3857 libraryA.imports = <ImportElementImpl>[ | |
| 3858 ElementFactory.importFor(libraryAA, null) | |
| 3859 ]; | |
| 3860 library.imports = <ImportElementImpl>[ | |
| 3861 ElementFactory.importFor(libraryA, null), | |
| 3862 ElementFactory.importFor(libraryB, null) | |
| 3863 ]; | |
| 3864 List<LibraryElement> libraries = library.visibleLibraries; | |
| 3865 expect( | |
| 3866 libraries, | |
| 3867 unorderedEquals( | |
| 3868 <LibraryElement>[library, libraryA, libraryAA, libraryB])); | |
| 3869 } | |
| 3870 | |
| 3871 void test_getVisibleLibraries_noImports() { | |
| 3872 AnalysisContext context = createAnalysisContext(); | |
| 3873 LibraryElementImpl library = ElementFactory.library(context, "app"); | |
| 3874 expect( | |
| 3875 library.visibleLibraries, unorderedEquals(<LibraryElement>[library])); | |
| 3876 } | |
| 3877 | |
| 3878 void test_isUpToDate() { | |
| 3879 AnalysisContext context = createAnalysisContext(); | 3874 AnalysisContext context = createAnalysisContext(); |
| 3880 context.sourceFactory = new SourceFactory([]); | 3875 context.sourceFactory = new SourceFactory([]); |
| 3881 LibraryElement library = ElementFactory.library(context, "foo"); | 3876 LibraryElementImpl library = ElementFactory.library(context, "foo"); |
| 3882 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); | 3877 LibraryElementImpl importedLibrary = ElementFactory.library(context, "bar"); |
| 3883 // Assert that we are not up to date if the target has an old time stamp. | 3878 ElementLocation location = new ElementLocationImpl.con2(''); |
| 3884 expect(library.isUpToDate(0), isFalse); | 3879 TestElementResynthesizer resynthesizer = |
| 3885 // Assert that we are up to date with a target modification time in the | 3880 new TestElementResynthesizer(context, {location: importedLibrary}); |
| 3886 // future. | 3881 LibraryElement importedLibraryHandle = |
| 3887 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue); | 3882 new LibraryElementHandle(resynthesizer, location); |
| 3883 ImportElementImpl import = |
| 3884 ElementFactory.importFor(importedLibraryHandle, null); |
| 3885 library.imports = <ImportElement>[import]; |
| 3886 library.libraryCycle; // Force computation of the cycle. |
| 3887 |
| 3888 library.invalidateLibraryCycles(); |
| 3888 } | 3889 } |
| 3889 | 3890 |
| 3890 void test_setImports() { | 3891 void test_setImports() { |
| 3891 AnalysisContext context = createAnalysisContext(); | 3892 AnalysisContext context = createAnalysisContext(); |
| 3892 LibraryElementImpl library = new LibraryElementImpl.forNode( | 3893 LibraryElementImpl library = new LibraryElementImpl.forNode( |
| 3893 context, AstFactory.libraryIdentifier2(["l1"])); | 3894 context, AstFactory.libraryIdentifier2(["l1"])); |
| 3894 List<ImportElementImpl> expectedImports = [ | 3895 List<ImportElementImpl> expectedImports = [ |
| 3895 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), | 3896 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), |
| 3896 ElementFactory.importFor(ElementFactory.library(context, "l3"), null) | 3897 ElementFactory.importFor(ElementFactory.library(context, "l3"), null) |
| 3897 ]; | 3898 ]; |
| 3898 library.imports = expectedImports; | 3899 library.imports = expectedImports; |
| 3899 List<ImportElement> actualImports = library.imports; | 3900 List<ImportElement> actualImports = library.imports; |
| 3900 expect(actualImports, hasLength(expectedImports.length)); | 3901 expect(actualImports, hasLength(expectedImports.length)); |
| 3901 for (int i = 0; i < actualImports.length; i++) { | 3902 for (int i = 0; i < actualImports.length; i++) { |
| 3902 expect(actualImports[i], same(expectedImports[i])); | 3903 expect(actualImports[i], same(expectedImports[i])); |
| 3903 } | 3904 } |
| 3904 } | 3905 } |
| 3905 } | 3906 } |
| 3906 | 3907 |
| 3907 @reflectiveTest | 3908 @reflectiveTest |
| 3909 class LocalVariableElementImplTest extends EngineTestCase { |
| 3910 void test_computeNode_declaredIdentifier() { |
| 3911 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3912 AnalysisContext context = contextHelper.context; |
| 3913 Source source = contextHelper.addSource( |
| 3914 "/test.dart", |
| 3915 r''' |
| 3916 main() { |
| 3917 for (int v in <int>[1, 2, 3]) {} |
| 3918 }'''); |
| 3919 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3920 FunctionElement mainElement = libraryElement.units[0].functions[0]; |
| 3921 LocalVariableElement element = mainElement.localVariables[0]; |
| 3922 DeclaredIdentifier node = element.computeNode() as DeclaredIdentifier; |
| 3923 expect(node, isNotNull); |
| 3924 expect(node.identifier.name, 'v'); |
| 3925 expect(node.element, same(element)); |
| 3926 } |
| 3927 |
| 3928 void test_computeNode_variableDeclaration() { |
| 3929 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3930 AnalysisContext context = contextHelper.context; |
| 3931 Source source = contextHelper.addSource( |
| 3932 "/test.dart", |
| 3933 r''' |
| 3934 main() { |
| 3935 int v = 0; |
| 3936 }'''); |
| 3937 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3938 FunctionElement mainElement = libraryElement.units[0].functions[0]; |
| 3939 LocalVariableElement element = mainElement.localVariables[0]; |
| 3940 VariableDeclaration node = element.computeNode() as VariableDeclaration; |
| 3941 expect(node, isNotNull); |
| 3942 expect(node.name.name, 'v'); |
| 3943 expect(node.element, same(element)); |
| 3944 } |
| 3945 } |
| 3946 |
| 3947 @reflectiveTest |
| 3908 class MethodElementImplTest extends EngineTestCase { | 3948 class MethodElementImplTest extends EngineTestCase { |
| 3909 void test_computeNode() { | 3949 void test_computeNode() { |
| 3910 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3950 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3911 AnalysisContext context = contextHelper.context; | 3951 AnalysisContext context = contextHelper.context; |
| 3912 Source source = contextHelper.addSource( | 3952 Source source = contextHelper.addSource( |
| 3913 "/test.dart", | 3953 "/test.dart", |
| 3914 r''' | 3954 r''' |
| 3915 abstract class A { | 3955 abstract class A { |
| 3916 String m1() => null; | 3956 String m1() => null; |
| 3917 m2(); | 3957 m2(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3969 expect(m2Node, isNotNull); | 4009 expect(m2Node, isNotNull); |
| 3970 expect(m2Node.name.name, "m2"); | 4010 expect(m2Node.name.name, "m2"); |
| 3971 expect(m2Node.element, same(m2Element)); | 4011 expect(m2Node.element, same(m2Element)); |
| 3972 } | 4012 } |
| 3973 } | 4013 } |
| 3974 } | 4014 } |
| 3975 | 4015 |
| 3976 @reflectiveTest | 4016 @reflectiveTest |
| 3977 class MultiplyDefinedElementImplTest extends EngineTestCase { | 4017 class MultiplyDefinedElementImplTest extends EngineTestCase { |
| 3978 void test_fromElements_conflicting() { | 4018 void test_fromElements_conflicting() { |
| 3979 Element firstElement = ElementFactory.localVariableElement2("xx"); | 4019 TopLevelVariableElement firstElement = |
| 3980 Element secondElement = ElementFactory.localVariableElement2("yy"); | 4020 ElementFactory.topLevelVariableElement2('xx'); |
| 4021 TopLevelVariableElement secondElement = |
| 4022 ElementFactory.topLevelVariableElement2('yy'); |
| 4023 _addToLibrary([firstElement, secondElement]); |
| 3981 Element result = MultiplyDefinedElementImpl.fromElements( | 4024 Element result = MultiplyDefinedElementImpl.fromElements( |
| 3982 null, firstElement, secondElement); | 4025 null, firstElement, secondElement); |
| 3983 EngineTestCase.assertInstanceOf( | 4026 EngineTestCase.assertInstanceOf( |
| 3984 (obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, result); | 4027 (obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, result); |
| 3985 List<Element> elements = | 4028 List<Element> elements = |
| 3986 (result as MultiplyDefinedElement).conflictingElements; | 4029 (result as MultiplyDefinedElement).conflictingElements; |
| 3987 expect(elements, hasLength(2)); | 4030 expect(elements, hasLength(2)); |
| 3988 for (int i = 0; i < elements.length; i++) { | 4031 for (int i = 0; i < elements.length; i++) { |
| 3989 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, | 4032 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement, |
| 3990 LocalVariableElement, elements[i]); | 4033 TopLevelVariableElement, elements[i]); |
| 3991 } | 4034 } |
| 3992 } | 4035 } |
| 3993 | 4036 |
| 3994 void test_fromElements_multiple() { | 4037 void test_fromElements_multiple() { |
| 3995 Element firstElement = ElementFactory.localVariableElement2("xx"); | 4038 TopLevelVariableElement firstElement = |
| 3996 Element secondElement = ElementFactory.localVariableElement2("yy"); | 4039 ElementFactory.topLevelVariableElement2('xx'); |
| 3997 Element thirdElement = ElementFactory.localVariableElement2("zz"); | 4040 TopLevelVariableElement secondElement = |
| 4041 ElementFactory.topLevelVariableElement2('yy'); |
| 4042 TopLevelVariableElement thirdElement = |
| 4043 ElementFactory.topLevelVariableElement2('zz'); |
| 4044 _addToLibrary([firstElement, secondElement, thirdElement]); |
| 3998 Element result = MultiplyDefinedElementImpl.fromElements( | 4045 Element result = MultiplyDefinedElementImpl.fromElements( |
| 3999 null, | 4046 null, |
| 4000 MultiplyDefinedElementImpl.fromElements( | 4047 MultiplyDefinedElementImpl.fromElements( |
| 4001 null, firstElement, secondElement), | 4048 null, firstElement, secondElement), |
| 4002 thirdElement); | 4049 thirdElement); |
| 4003 EngineTestCase.assertInstanceOf( | 4050 EngineTestCase.assertInstanceOf( |
| 4004 (obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, result); | 4051 (obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, result); |
| 4005 List<Element> elements = | 4052 List<Element> elements = |
| 4006 (result as MultiplyDefinedElement).conflictingElements; | 4053 (result as MultiplyDefinedElement).conflictingElements; |
| 4007 expect(elements, hasLength(3)); | 4054 expect(elements, hasLength(3)); |
| 4008 for (int i = 0; i < elements.length; i++) { | 4055 for (int i = 0; i < elements.length; i++) { |
| 4009 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, | 4056 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement, |
| 4010 LocalVariableElement, elements[i]); | 4057 TopLevelVariableElement, elements[i]); |
| 4011 } | 4058 } |
| 4012 } | 4059 } |
| 4013 | 4060 |
| 4014 void test_fromElements_nonConflicting() { | 4061 void test_fromElements_nonConflicting() { |
| 4015 Element element = ElementFactory.localVariableElement2("xx"); | 4062 TopLevelVariableElement element = |
| 4063 ElementFactory.topLevelVariableElement2('xx'); |
| 4064 _addToLibrary([element]); |
| 4016 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), | 4065 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), |
| 4017 same(element)); | 4066 same(element)); |
| 4018 } | 4067 } |
| 4068 |
| 4069 void _addToLibrary(List<TopLevelVariableElement> variables) { |
| 4070 CompilationUnitElementImpl compilationUnit = |
| 4071 ElementFactory.compilationUnit('lib.dart'); |
| 4072 LibraryElementImpl library = ElementFactory.library(null, 'lib'); |
| 4073 library.definingCompilationUnit = compilationUnit; |
| 4074 compilationUnit.topLevelVariables = variables; |
| 4075 } |
| 4019 } | 4076 } |
| 4020 | 4077 |
| 4021 @reflectiveTest | 4078 @reflectiveTest |
| 4022 class ParameterElementImplTest extends EngineTestCase { | 4079 class ParameterElementImplTest extends EngineTestCase { |
| 4023 void test_computeNode_DefaultFormalParameter() { | 4080 void test_computeNode_DefaultFormalParameter() { |
| 4024 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 4081 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 4025 AnalysisContext context = contextHelper.context; | 4082 AnalysisContext context = contextHelper.context; |
| 4026 Source source = contextHelper.addSource( | 4083 Source source = contextHelper.addSource( |
| 4027 "/test.dart", | 4084 "/test.dart", |
| 4028 r''' | 4085 r''' |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 ParameterElement element = unitElement.functions[0].parameters[0]; | 4161 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 4105 SimpleFormalParameter node = element.computeNode(); | 4162 SimpleFormalParameter node = element.computeNode(); |
| 4106 expect(node, isNotNull); | 4163 expect(node, isNotNull); |
| 4107 expect(node.identifier.name, 'p'); | 4164 expect(node.identifier.name, 'p'); |
| 4108 expect(node.element, same(element)); | 4165 expect(node.element, same(element)); |
| 4109 } | 4166 } |
| 4110 } | 4167 } |
| 4111 } | 4168 } |
| 4112 | 4169 |
| 4113 @reflectiveTest | 4170 @reflectiveTest |
| 4171 class PropertyAccessorElementImplTest extends EngineTestCase { |
| 4172 void test_matchesHandle_getter() { |
| 4173 CompilationUnitElementImpl compilationUnitElement = |
| 4174 ElementFactory.compilationUnit('foo.dart'); |
| 4175 ElementFactory.library(null, '') |
| 4176 ..definingCompilationUnit = compilationUnitElement; |
| 4177 PropertyAccessorElementImpl element = |
| 4178 ElementFactory.getterElement('x', true, DynamicTypeImpl.instance); |
| 4179 compilationUnitElement.accessors = <PropertyAccessorElement>[element]; |
| 4180 PropertyAccessorElementHandle handle = |
| 4181 new PropertyAccessorElementHandle(null, element.location); |
| 4182 expect(element.hashCode, handle.hashCode); |
| 4183 expect(element == handle, isTrue); |
| 4184 expect(handle == element, isTrue); |
| 4185 } |
| 4186 |
| 4187 void test_matchesHandle_setter() { |
| 4188 CompilationUnitElementImpl compilationUnitElement = |
| 4189 ElementFactory.compilationUnit('foo.dart'); |
| 4190 ElementFactory.library(null, '') |
| 4191 ..definingCompilationUnit = compilationUnitElement; |
| 4192 PropertyAccessorElementImpl element = |
| 4193 ElementFactory.setterElement('x', true, DynamicTypeImpl.instance); |
| 4194 compilationUnitElement.accessors = <PropertyAccessorElement>[element]; |
| 4195 PropertyAccessorElementHandle handle = |
| 4196 new PropertyAccessorElementHandle(null, element.location); |
| 4197 expect(element.hashCode, handle.hashCode); |
| 4198 expect(element == handle, isTrue); |
| 4199 expect(handle == element, isTrue); |
| 4200 } |
| 4201 } |
| 4202 |
| 4203 class TestElementResynthesizer extends ElementResynthesizer { |
| 4204 Map<ElementLocation, Element> locationMap; |
| 4205 |
| 4206 TestElementResynthesizer(AnalysisContext context, this.locationMap) |
| 4207 : super(context); |
| 4208 |
| 4209 @override |
| 4210 Element getElement(ElementLocation location) { |
| 4211 return locationMap[location]; |
| 4212 } |
| 4213 } |
| 4214 |
| 4215 @reflectiveTest |
| 4216 class TopLevelVariableElementImplTest extends ResolverTestCase { |
| 4217 void test_computeConstantValue() { |
| 4218 addNamedSource( |
| 4219 '/a.dart', |
| 4220 r''' |
| 4221 const int C = 42; |
| 4222 '''); |
| 4223 Source source = addSource(r''' |
| 4224 import 'a.dart'; |
| 4225 main() { |
| 4226 print(C); |
| 4227 } |
| 4228 '''); |
| 4229 LibraryElement library = resolve2(source); |
| 4230 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 4231 FunctionDeclaration main = unit.declarations[0]; |
| 4232 BlockFunctionBody body = main.functionExpression.body; |
| 4233 ExpressionStatement statement = body.block.statements[0]; |
| 4234 MethodInvocation invocation = statement.expression; |
| 4235 SimpleIdentifier argument = invocation.argumentList.arguments[0]; |
| 4236 PropertyAccessorElementImpl getter = argument.bestElement; |
| 4237 TopLevelVariableElement constant = getter.variable; |
| 4238 expect(constant.constantValue, isNull); |
| 4239 DartObject value = constant.computeConstantValue(); |
| 4240 expect(value, isNotNull); |
| 4241 expect(value.toIntValue(), 42); |
| 4242 expect(constant.constantValue, value); |
| 4243 } |
| 4244 } |
| 4245 |
| 4246 @reflectiveTest |
| 4114 class TypeParameterTypeImplTest extends EngineTestCase { | 4247 class TypeParameterTypeImplTest extends EngineTestCase { |
| 4115 void test_creation() { | 4248 void test_creation() { |
| 4116 expect( | 4249 expect( |
| 4117 new TypeParameterTypeImpl( | 4250 new TypeParameterTypeImpl( |
| 4118 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), | 4251 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), |
| 4119 isNotNull); | 4252 isNotNull); |
| 4120 } | 4253 } |
| 4121 | 4254 |
| 4122 void test_getElement() { | 4255 void test_getElement() { |
| 4123 TypeParameterElementImpl element = | 4256 TypeParameterElementImpl element = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4135 } | 4268 } |
| 4136 | 4269 |
| 4137 void test_isMoreSpecificThan_typeArguments_object() { | 4270 void test_isMoreSpecificThan_typeArguments_object() { |
| 4138 TypeParameterElementImpl element = | 4271 TypeParameterElementImpl element = |
| 4139 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); | 4272 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| 4140 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 4273 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 4141 // E << Object | 4274 // E << Object |
| 4142 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); | 4275 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); |
| 4143 } | 4276 } |
| 4144 | 4277 |
| 4145 void test_isMoreSpecificThan_typeArguments_resursive() { | 4278 void test_isMoreSpecificThan_typeArguments_recursive() { |
| 4146 ClassElementImpl classS = ElementFactory.classElement2("A"); | 4279 ClassElementImpl classS = ElementFactory.classElement2("A"); |
| 4147 TypeParameterElementImpl typeParameterU = | 4280 TypeParameterElementImpl typeParameterU = |
| 4148 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); | 4281 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); |
| 4149 TypeParameterTypeImpl typeParameterTypeU = | 4282 TypeParameterTypeImpl typeParameterTypeU = |
| 4150 new TypeParameterTypeImpl(typeParameterU); | 4283 new TypeParameterTypeImpl(typeParameterU); |
| 4151 TypeParameterElementImpl typeParameterT = | 4284 TypeParameterElementImpl typeParameterT = |
| 4152 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); | 4285 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); |
| 4153 TypeParameterTypeImpl typeParameterTypeT = | 4286 TypeParameterTypeImpl typeParameterTypeT = |
| 4154 new TypeParameterTypeImpl(typeParameterT); | 4287 new TypeParameterTypeImpl(typeParameterT); |
| 4155 typeParameterT.bound = typeParameterTypeU; | 4288 typeParameterT.bound = typeParameterTypeU; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 TypeParameterElementImpl typeParameterT = | 4340 TypeParameterElementImpl typeParameterT = |
| 4208 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); | 4341 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); |
| 4209 typeParameterT.bound = classS.type; | 4342 typeParameterT.bound = classS.type; |
| 4210 TypeParameterTypeImpl typeParameterTypeT = | 4343 TypeParameterTypeImpl typeParameterTypeT = |
| 4211 new TypeParameterTypeImpl(typeParameterT); | 4344 new TypeParameterTypeImpl(typeParameterT); |
| 4212 // <T extends S> | 4345 // <T extends S> |
| 4213 // T << S | 4346 // T << S |
| 4214 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); | 4347 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); |
| 4215 } | 4348 } |
| 4216 | 4349 |
| 4350 void test_resolveToBound_bound() { |
| 4351 ClassElementImpl classS = ElementFactory.classElement2("A"); |
| 4352 TypeParameterElementImpl element = |
| 4353 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| 4354 element.bound = classS.type; |
| 4355 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 4356 expect(type.resolveToBound(null), same(classS.type)); |
| 4357 } |
| 4358 |
| 4359 void test_resolveToBound_nestedBound() { |
| 4360 ClassElementImpl classS = ElementFactory.classElement2("A"); |
| 4361 TypeParameterElementImpl elementE = |
| 4362 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| 4363 elementE.bound = classS.type; |
| 4364 TypeParameterTypeImpl typeE = new TypeParameterTypeImpl(elementE); |
| 4365 TypeParameterElementImpl elementF = |
| 4366 new TypeParameterElementImpl.forNode(AstFactory.identifier3("F")); |
| 4367 elementF.bound = typeE; |
| 4368 TypeParameterTypeImpl typeF = new TypeParameterTypeImpl(elementE); |
| 4369 expect(typeF.resolveToBound(null), same(classS.type)); |
| 4370 } |
| 4371 |
| 4372 void test_resolveToBound_unbound() { |
| 4373 TypeParameterTypeImpl type = new TypeParameterTypeImpl( |
| 4374 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); |
| 4375 // Returns whatever type is passed to resolveToBound(). |
| 4376 expect(type.resolveToBound(VoidTypeImpl.instance), |
| 4377 same(VoidTypeImpl.instance)); |
| 4378 } |
| 4379 |
| 4217 void test_substitute_equal() { | 4380 void test_substitute_equal() { |
| 4218 TypeParameterElementImpl element = | 4381 TypeParameterElementImpl element = |
| 4219 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); | 4382 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| 4220 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 4383 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 4221 InterfaceTypeImpl argument = new InterfaceTypeImpl( | 4384 InterfaceTypeImpl argument = new InterfaceTypeImpl( |
| 4222 new ClassElementImpl.forNode(AstFactory.identifier3("A"))); | 4385 new ClassElementImpl.forNode(AstFactory.identifier3("A"))); |
| 4223 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); | 4386 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); |
| 4224 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]), | 4387 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]), |
| 4225 same(argument)); | 4388 same(argument)); |
| 4226 } | 4389 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4266 expect(_voidType.isSubtypeOf(DynamicTypeImpl.instance), isTrue); | 4429 expect(_voidType.isSubtypeOf(DynamicTypeImpl.instance), isTrue); |
| 4267 } | 4430 } |
| 4268 | 4431 |
| 4269 void test_isSubtypeOf_void_void() { | 4432 void test_isSubtypeOf_void_void() { |
| 4270 expect(_voidType.isSubtypeOf(_voidType), isTrue); | 4433 expect(_voidType.isSubtypeOf(_voidType), isTrue); |
| 4271 } | 4434 } |
| 4272 | 4435 |
| 4273 void test_isVoid() { | 4436 void test_isVoid() { |
| 4274 expect(_voidType.isVoid, isTrue); | 4437 expect(_voidType.isVoid, isTrue); |
| 4275 } | 4438 } |
| 4439 |
| 4440 void test_resolveToBound() { |
| 4441 // Returns this. |
| 4442 expect(_voidType.resolveToBound(null), same(_voidType)); |
| 4443 } |
| 4276 } | 4444 } |
| 4277 | 4445 |
| 4278 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4279 extends InterfaceTypeImpl { | 4447 extends InterfaceTypeImpl { |
| 4280 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4281 : super(arg0); | 4449 : super(arg0); |
| 4282 | 4450 |
| 4283 @override | 4451 @override |
| 4284 bool get isDartCoreFunction => true; | 4452 bool get isDartCoreFunction => true; |
| 4285 } | 4453 } |
| OLD | NEW |