| 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.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/element_resolver.dart'; | 11 import 'package:analyzer/src/generated/element_resolver.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
| 14 import 'package:analyzer/src/generated/java_core.dart'; | 14 import 'package:analyzer/src/generated/java_core.dart'; |
| 15 import 'package:analyzer/src/generated/java_engine.dart'; | 15 import 'package:analyzer/src/generated/java_engine.dart'; |
| 16 import 'package:analyzer/src/generated/java_engine_io.dart'; | 16 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 17 import 'package:analyzer/src/generated/java_io.dart'; | 17 import 'package:analyzer/src/generated/java_io.dart'; |
| 18 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 18 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 19 import 'package:analyzer/src/generated/resolver.dart'; | 19 import 'package:analyzer/src/generated/resolver.dart'; |
| 20 import 'package:analyzer/src/generated/scanner.dart'; | 20 import 'package:analyzer/src/generated/scanner.dart'; |
| 21 import 'package:analyzer/src/generated/sdk.dart'; | 21 import 'package:analyzer/src/generated/sdk.dart'; |
| 22 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 22 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
| 23 import 'package:analyzer/src/generated/source_io.dart'; | 23 import 'package:analyzer/src/generated/source_io.dart'; |
| 24 import 'package:analyzer/src/generated/static_type_analyzer.dart'; | 24 import 'package:analyzer/src/generated/static_type_analyzer.dart'; |
| 25 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 25 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 26 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 26 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 27 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 27 import 'package:analyzer/src/generated/utilities_dart.dart'; | 28 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 28 import 'package:unittest/unittest.dart'; | 29 import 'package:unittest/unittest.dart'; |
| 29 | 30 |
| 30 import '../reflective_tests.dart'; | 31 import '../reflective_tests.dart'; |
| 31 import 'test_support.dart'; | 32 import 'test_support.dart'; |
| 32 | 33 |
| 33 | 34 |
| 34 main() { | 35 main() { |
| 35 groupSep = ' | '; | 36 groupSep = ' | '; |
| (...skipping 11072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11108 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 11109 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 11109 _definingCompilationUnit.types = <ClassElement>[classA, classB]; | 11110 _definingCompilationUnit.types = <ClassElement>[classA, classB]; |
| 11110 HashSet<ClassElement> subtypesOfA = | 11111 HashSet<ClassElement> subtypesOfA = |
| 11111 _subtypeManager.computeAllSubtypes(classA); | 11112 _subtypeManager.computeAllSubtypes(classA); |
| 11112 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); | 11113 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); |
| 11113 expect(subtypesOfA, hasLength(1)); | 11114 expect(subtypesOfA, hasLength(1)); |
| 11114 expect(arraySubtypesOfA, unorderedEquals([classB])); | 11115 expect(arraySubtypesOfA, unorderedEquals([classB])); |
| 11115 } | 11116 } |
| 11116 } | 11117 } |
| 11117 | 11118 |
| 11118 /** | |
| 11119 * Instances of the class `TestTypeProvider` implement a type provider that can
be used by | |
| 11120 * tests without creating the element model for the core library. | |
| 11121 */ | |
| 11122 class TestTypeProvider implements TypeProvider { | |
| 11123 /** | |
| 11124 * The type representing the built-in type 'bool'. | |
| 11125 */ | |
| 11126 InterfaceType _boolType; | |
| 11127 | 11119 |
| 11128 /** | |
| 11129 * The type representing the type 'bottom'. | |
| 11130 */ | |
| 11131 DartType _bottomType; | |
| 11132 | |
| 11133 /** | |
| 11134 * The type representing the built-in type 'double'. | |
| 11135 */ | |
| 11136 InterfaceType _doubleType; | |
| 11137 | |
| 11138 /** | |
| 11139 * The type representing the built-in type 'deprecated'. | |
| 11140 */ | |
| 11141 InterfaceType _deprecatedType; | |
| 11142 | |
| 11143 /** | |
| 11144 * The type representing the built-in type 'dynamic'. | |
| 11145 */ | |
| 11146 DartType _dynamicType; | |
| 11147 | |
| 11148 /** | |
| 11149 * The type representing the built-in type 'Function'. | |
| 11150 */ | |
| 11151 InterfaceType _functionType; | |
| 11152 | |
| 11153 /** | |
| 11154 * The type representing the built-in type 'int'. | |
| 11155 */ | |
| 11156 InterfaceType _intType; | |
| 11157 | |
| 11158 /** | |
| 11159 * The type representing the built-in type 'Iterable'. | |
| 11160 */ | |
| 11161 InterfaceType _iterableType; | |
| 11162 | |
| 11163 /** | |
| 11164 * The type representing the built-in type 'Iterator'. | |
| 11165 */ | |
| 11166 InterfaceType _iteratorType; | |
| 11167 | |
| 11168 /** | |
| 11169 * The type representing the built-in type 'List'. | |
| 11170 */ | |
| 11171 InterfaceType _listType; | |
| 11172 | |
| 11173 /** | |
| 11174 * The type representing the built-in type 'Map'. | |
| 11175 */ | |
| 11176 InterfaceType _mapType; | |
| 11177 | |
| 11178 /** | |
| 11179 * The type representing the built-in type 'Null'. | |
| 11180 */ | |
| 11181 InterfaceType _nullType; | |
| 11182 | |
| 11183 /** | |
| 11184 * The type representing the built-in type 'num'. | |
| 11185 */ | |
| 11186 InterfaceType _numType; | |
| 11187 | |
| 11188 /** | |
| 11189 * The type representing the built-in type 'Object'. | |
| 11190 */ | |
| 11191 InterfaceType _objectType; | |
| 11192 | |
| 11193 /** | |
| 11194 * The type representing the built-in type 'StackTrace'. | |
| 11195 */ | |
| 11196 InterfaceType _stackTraceType; | |
| 11197 | |
| 11198 /** | |
| 11199 * The type representing the built-in type 'String'. | |
| 11200 */ | |
| 11201 InterfaceType _stringType; | |
| 11202 | |
| 11203 /** | |
| 11204 * The type representing the built-in type 'Symbol'. | |
| 11205 */ | |
| 11206 InterfaceType _symbolType; | |
| 11207 | |
| 11208 /** | |
| 11209 * The type representing the built-in type 'Type'. | |
| 11210 */ | |
| 11211 InterfaceType _typeType; | |
| 11212 | |
| 11213 /** | |
| 11214 * The type representing typenames that can't be resolved. | |
| 11215 */ | |
| 11216 DartType _undefinedType; | |
| 11217 | |
| 11218 @override | |
| 11219 InterfaceType get boolType { | |
| 11220 if (_boolType == null) { | |
| 11221 ClassElementImpl boolElement = ElementFactory.classElement2("bool"); | |
| 11222 _boolType = boolElement.type; | |
| 11223 ConstructorElementImpl fromEnvironment = | |
| 11224 ElementFactory.constructorElement(boolElement, "fromEnvironment", true
); | |
| 11225 fromEnvironment.parameters = <ParameterElement>[ | |
| 11226 ElementFactory.requiredParameter2("name", stringType), | |
| 11227 ElementFactory.namedParameter2("defaultValue", _boolType)]; | |
| 11228 fromEnvironment.factory = true; | |
| 11229 boolElement.constructors = <ConstructorElement>[fromEnvironment]; | |
| 11230 } | |
| 11231 return _boolType; | |
| 11232 } | |
| 11233 | |
| 11234 @override | |
| 11235 DartType get bottomType { | |
| 11236 if (_bottomType == null) { | |
| 11237 _bottomType = BottomTypeImpl.instance; | |
| 11238 } | |
| 11239 return _bottomType; | |
| 11240 } | |
| 11241 | |
| 11242 @override | |
| 11243 InterfaceType get deprecatedType { | |
| 11244 if (_deprecatedType == null) { | |
| 11245 ClassElementImpl deprecatedElement = | |
| 11246 ElementFactory.classElement2("Deprecated"); | |
| 11247 deprecatedElement.constructors = <ConstructorElement>[ | |
| 11248 ElementFactory.constructorElement(deprecatedElement, null, true, [stri
ngType])]; | |
| 11249 _deprecatedType = deprecatedElement.type; | |
| 11250 } | |
| 11251 return _deprecatedType; | |
| 11252 } | |
| 11253 | |
| 11254 @override | |
| 11255 InterfaceType get doubleType { | |
| 11256 if (_doubleType == null) { | |
| 11257 _initializeNumericTypes(); | |
| 11258 } | |
| 11259 return _doubleType; | |
| 11260 } | |
| 11261 | |
| 11262 @override | |
| 11263 DartType get dynamicType { | |
| 11264 if (_dynamicType == null) { | |
| 11265 _dynamicType = DynamicTypeImpl.instance; | |
| 11266 } | |
| 11267 return _dynamicType; | |
| 11268 } | |
| 11269 | |
| 11270 @override | |
| 11271 InterfaceType get functionType { | |
| 11272 if (_functionType == null) { | |
| 11273 _functionType = ElementFactory.classElement2("Function").type; | |
| 11274 } | |
| 11275 return _functionType; | |
| 11276 } | |
| 11277 | |
| 11278 @override | |
| 11279 InterfaceType get intType { | |
| 11280 if (_intType == null) { | |
| 11281 _initializeNumericTypes(); | |
| 11282 } | |
| 11283 return _intType; | |
| 11284 } | |
| 11285 | |
| 11286 InterfaceType get iterableType { | |
| 11287 if (_iterableType == null) { | |
| 11288 ClassElementImpl iterableElement = | |
| 11289 ElementFactory.classElement2("Iterable", ["E"]); | |
| 11290 _iterableType = iterableElement.type; | |
| 11291 DartType eType = iterableElement.typeParameters[0].type; | |
| 11292 iterableElement.accessors = <PropertyAccessorElement>[ | |
| 11293 ElementFactory.getterElement( | |
| 11294 "iterator", | |
| 11295 false, | |
| 11296 iteratorType.substitute4(<DartType>[eType])), | |
| 11297 ElementFactory.getterElement("last", false, eType)]; | |
| 11298 _propagateTypeArguments(iterableElement); | |
| 11299 } | |
| 11300 return _iterableType; | |
| 11301 } | |
| 11302 | |
| 11303 InterfaceType get iteratorType { | |
| 11304 if (_iteratorType == null) { | |
| 11305 ClassElementImpl iteratorElement = | |
| 11306 ElementFactory.classElement2("Iterator", ["E"]); | |
| 11307 _iteratorType = iteratorElement.type; | |
| 11308 DartType eType = iteratorElement.typeParameters[0].type; | |
| 11309 iteratorElement.accessors = <PropertyAccessorElement>[ | |
| 11310 ElementFactory.getterElement("current", false, eType)]; | |
| 11311 _propagateTypeArguments(iteratorElement); | |
| 11312 } | |
| 11313 return _iteratorType; | |
| 11314 } | |
| 11315 | |
| 11316 @override | |
| 11317 InterfaceType get listType { | |
| 11318 if (_listType == null) { | |
| 11319 ClassElementImpl listElement = | |
| 11320 ElementFactory.classElement2("List", ["E"]); | |
| 11321 listElement.constructors = | |
| 11322 <ConstructorElement>[ElementFactory.constructorElement2(listElement, n
ull)]; | |
| 11323 _listType = listElement.type; | |
| 11324 DartType eType = listElement.typeParameters[0].type; | |
| 11325 InterfaceType iterableType = | |
| 11326 this.iterableType.substitute4(<DartType>[eType]); | |
| 11327 listElement.interfaces = <InterfaceType>[iterableType]; | |
| 11328 listElement.accessors = <PropertyAccessorElement>[ | |
| 11329 ElementFactory.getterElement("length", false, intType)]; | |
| 11330 listElement.methods = <MethodElement>[ | |
| 11331 ElementFactory.methodElement("[]", eType, [intType]), | |
| 11332 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e
Type]), | |
| 11333 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])]; | |
| 11334 _propagateTypeArguments(listElement); | |
| 11335 } | |
| 11336 return _listType; | |
| 11337 } | |
| 11338 | |
| 11339 @override | |
| 11340 InterfaceType get mapType { | |
| 11341 if (_mapType == null) { | |
| 11342 ClassElementImpl mapElement = | |
| 11343 ElementFactory.classElement2("Map", ["K", "V"]); | |
| 11344 _mapType = mapElement.type; | |
| 11345 DartType kType = mapElement.typeParameters[0].type; | |
| 11346 DartType vType = mapElement.typeParameters[1].type; | |
| 11347 mapElement.accessors = <PropertyAccessorElement>[ | |
| 11348 ElementFactory.getterElement("length", false, intType)]; | |
| 11349 mapElement.methods = <MethodElement>[ | |
| 11350 ElementFactory.methodElement("[]", vType, [objectType]), | |
| 11351 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [kType, vTy
pe])]; | |
| 11352 _propagateTypeArguments(mapElement); | |
| 11353 } | |
| 11354 return _mapType; | |
| 11355 } | |
| 11356 | |
| 11357 @override | |
| 11358 InterfaceType get nullType { | |
| 11359 if (_nullType == null) { | |
| 11360 _nullType = ElementFactory.classElement2("Null").type; | |
| 11361 } | |
| 11362 return _nullType; | |
| 11363 } | |
| 11364 | |
| 11365 @override | |
| 11366 InterfaceType get numType { | |
| 11367 if (_numType == null) { | |
| 11368 _initializeNumericTypes(); | |
| 11369 } | |
| 11370 return _numType; | |
| 11371 } | |
| 11372 | |
| 11373 @override | |
| 11374 InterfaceType get objectType { | |
| 11375 if (_objectType == null) { | |
| 11376 ClassElementImpl objectElement = ElementFactory.object; | |
| 11377 _objectType = objectElement.type; | |
| 11378 objectElement.constructors = | |
| 11379 <ConstructorElement>[ElementFactory.constructorElement2(objectElement,
null)]; | |
| 11380 objectElement.methods = <MethodElement>[ | |
| 11381 ElementFactory.methodElement("toString", stringType), | |
| 11382 ElementFactory.methodElement("==", boolType, [_objectType]), | |
| 11383 ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType
])]; | |
| 11384 objectElement.accessors = <PropertyAccessorElement>[ | |
| 11385 ElementFactory.getterElement("hashCode", false, intType), | |
| 11386 ElementFactory.getterElement("runtimeType", false, typeType)]; | |
| 11387 } | |
| 11388 return _objectType; | |
| 11389 } | |
| 11390 | |
| 11391 @override | |
| 11392 InterfaceType get stackTraceType { | |
| 11393 if (_stackTraceType == null) { | |
| 11394 _stackTraceType = ElementFactory.classElement2("StackTrace").type; | |
| 11395 } | |
| 11396 return _stackTraceType; | |
| 11397 } | |
| 11398 | |
| 11399 @override | |
| 11400 InterfaceType get stringType { | |
| 11401 if (_stringType == null) { | |
| 11402 _stringType = ElementFactory.classElement2("String").type; | |
| 11403 ClassElementImpl stringElement = _stringType.element as ClassElementImpl; | |
| 11404 stringElement.accessors = <PropertyAccessorElement>[ | |
| 11405 ElementFactory.getterElement("isEmpty", false, boolType), | |
| 11406 ElementFactory.getterElement("length", false, intType), | |
| 11407 ElementFactory.getterElement( | |
| 11408 "codeUnits", | |
| 11409 false, | |
| 11410 listType.substitute4(<DartType>[intType]))]; | |
| 11411 stringElement.methods = <MethodElement>[ | |
| 11412 ElementFactory.methodElement("+", _stringType, [_stringType]), | |
| 11413 ElementFactory.methodElement("toLowerCase", _stringType), | |
| 11414 ElementFactory.methodElement("toUpperCase", _stringType)]; | |
| 11415 ConstructorElementImpl fromEnvironment = | |
| 11416 ElementFactory.constructorElement(stringElement, "fromEnvironment", tr
ue); | |
| 11417 fromEnvironment.parameters = <ParameterElement>[ | |
| 11418 ElementFactory.requiredParameter2("name", stringType), | |
| 11419 ElementFactory.namedParameter2("defaultValue", _stringType)]; | |
| 11420 fromEnvironment.factory = true; | |
| 11421 stringElement.constructors = <ConstructorElement>[fromEnvironment]; | |
| 11422 } | |
| 11423 return _stringType; | |
| 11424 } | |
| 11425 | |
| 11426 @override | |
| 11427 InterfaceType get symbolType { | |
| 11428 if (_symbolType == null) { | |
| 11429 ClassElementImpl symbolClass = ElementFactory.classElement2("Symbol"); | |
| 11430 ConstructorElementImpl constructor = | |
| 11431 ElementFactory.constructorElement(symbolClass, null, true, [stringType
]); | |
| 11432 constructor.factory = true; | |
| 11433 symbolClass.constructors = <ConstructorElement>[constructor]; | |
| 11434 _symbolType = symbolClass.type; | |
| 11435 } | |
| 11436 return _symbolType; | |
| 11437 } | |
| 11438 | |
| 11439 @override | |
| 11440 InterfaceType get typeType { | |
| 11441 if (_typeType == null) { | |
| 11442 _typeType = ElementFactory.classElement2("Type").type; | |
| 11443 } | |
| 11444 return _typeType; | |
| 11445 } | |
| 11446 | |
| 11447 @override | |
| 11448 DartType get undefinedType { | |
| 11449 if (_undefinedType == null) { | |
| 11450 _undefinedType = UndefinedTypeImpl.instance; | |
| 11451 } | |
| 11452 return _undefinedType; | |
| 11453 } | |
| 11454 | |
| 11455 /** | |
| 11456 * Initialize the numeric types. They are created as a group so that we can (a
) create the right | |
| 11457 * hierarchy and (b) add members to them. | |
| 11458 */ | |
| 11459 void _initializeNumericTypes() { | |
| 11460 // | |
| 11461 // Create the type hierarchy. | |
| 11462 // | |
| 11463 ClassElementImpl numElement = ElementFactory.classElement2("num"); | |
| 11464 _numType = numElement.type; | |
| 11465 ClassElementImpl intElement = ElementFactory.classElement("int", _numType); | |
| 11466 _intType = intElement.type; | |
| 11467 ClassElementImpl doubleElement = | |
| 11468 ElementFactory.classElement("double", _numType); | |
| 11469 _doubleType = doubleElement.type; | |
| 11470 // | |
| 11471 // Force the referenced types to be cached. | |
| 11472 // | |
| 11473 objectType; | |
| 11474 boolType; | |
| 11475 stringType; | |
| 11476 // | |
| 11477 // Add the methods. | |
| 11478 // | |
| 11479 numElement.methods = <MethodElement>[ | |
| 11480 ElementFactory.methodElement("+", _numType, [_numType]), | |
| 11481 ElementFactory.methodElement("-", _numType, [_numType]), | |
| 11482 ElementFactory.methodElement("*", _numType, [_numType]), | |
| 11483 ElementFactory.methodElement("%", _numType, [_numType]), | |
| 11484 ElementFactory.methodElement("/", _doubleType, [_numType]), | |
| 11485 ElementFactory.methodElement("~/", _numType, [_numType]), | |
| 11486 ElementFactory.methodElement("-", _numType), | |
| 11487 ElementFactory.methodElement("remainder", _numType, [_numType]), | |
| 11488 ElementFactory.methodElement("<", _boolType, [_numType]), | |
| 11489 ElementFactory.methodElement("<=", _boolType, [_numType]), | |
| 11490 ElementFactory.methodElement(">", _boolType, [_numType]), | |
| 11491 ElementFactory.methodElement(">=", _boolType, [_numType]), | |
| 11492 ElementFactory.methodElement("==", _boolType, [_objectType]), | |
| 11493 ElementFactory.methodElement("isNaN", _boolType), | |
| 11494 ElementFactory.methodElement("isNegative", _boolType), | |
| 11495 ElementFactory.methodElement("isInfinite", _boolType), | |
| 11496 ElementFactory.methodElement("abs", _numType), | |
| 11497 ElementFactory.methodElement("floor", _numType), | |
| 11498 ElementFactory.methodElement("ceil", _numType), | |
| 11499 ElementFactory.methodElement("round", _numType), | |
| 11500 ElementFactory.methodElement("truncate", _numType), | |
| 11501 ElementFactory.methodElement("toInt", _intType), | |
| 11502 ElementFactory.methodElement("toDouble", _doubleType), | |
| 11503 ElementFactory.methodElement("toStringAsFixed", _stringType, [_intType])
, | |
| 11504 ElementFactory.methodElement("toStringAsExponential", _stringType, [_int
Type]), | |
| 11505 ElementFactory.methodElement("toStringAsPrecision", _stringType, [_intTy
pe]), | |
| 11506 ElementFactory.methodElement("toRadixString", _stringType, [_intType])]; | |
| 11507 intElement.methods = <MethodElement>[ | |
| 11508 ElementFactory.methodElement("&", _intType, [_intType]), | |
| 11509 ElementFactory.methodElement("|", _intType, [_intType]), | |
| 11510 ElementFactory.methodElement("^", _intType, [_intType]), | |
| 11511 ElementFactory.methodElement("~", _intType), | |
| 11512 ElementFactory.methodElement("<<", _intType, [_intType]), | |
| 11513 ElementFactory.methodElement(">>", _intType, [_intType]), | |
| 11514 ElementFactory.methodElement("-", _intType), | |
| 11515 ElementFactory.methodElement("abs", _intType), | |
| 11516 ElementFactory.methodElement("round", _intType), | |
| 11517 ElementFactory.methodElement("floor", _intType), | |
| 11518 ElementFactory.methodElement("ceil", _intType), | |
| 11519 ElementFactory.methodElement("truncate", _intType), | |
| 11520 ElementFactory.methodElement("toString", _stringType)]; | |
| 11521 ConstructorElementImpl fromEnvironment = | |
| 11522 ElementFactory.constructorElement(intElement, "fromEnvironment", true); | |
| 11523 fromEnvironment.parameters = <ParameterElement>[ | |
| 11524 ElementFactory.requiredParameter2("name", stringType), | |
| 11525 ElementFactory.namedParameter2("defaultValue", _intType)]; | |
| 11526 fromEnvironment.factory = true; | |
| 11527 intElement.constructors = <ConstructorElement>[fromEnvironment]; | |
| 11528 List<FieldElement> fields = <FieldElement>[ | |
| 11529 ElementFactory.fieldElement("NAN", true, false, true, _doubleType), | |
| 11530 ElementFactory.fieldElement("INFINITY", true, false, true, _doubleType), | |
| 11531 ElementFactory.fieldElement( | |
| 11532 "NEGATIVE_INFINITY", | |
| 11533 true, | |
| 11534 false, | |
| 11535 true, | |
| 11536 _doubleType), | |
| 11537 ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleTy
pe), | |
| 11538 ElementFactory.fieldElement("MAX_FINITE", true, false, true, _doubleType
)]; | |
| 11539 doubleElement.fields = fields; | |
| 11540 int fieldCount = fields.length; | |
| 11541 List<PropertyAccessorElement> accessors = | |
| 11542 new List<PropertyAccessorElement>(fieldCount); | |
| 11543 for (int i = 0; i < fieldCount; i++) { | |
| 11544 accessors[i] = fields[i].getter; | |
| 11545 } | |
| 11546 doubleElement.accessors = accessors; | |
| 11547 doubleElement.methods = <MethodElement>[ | |
| 11548 ElementFactory.methodElement("remainder", _doubleType, [_numType]), | |
| 11549 ElementFactory.methodElement("+", _doubleType, [_numType]), | |
| 11550 ElementFactory.methodElement("-", _doubleType, [_numType]), | |
| 11551 ElementFactory.methodElement("*", _doubleType, [_numType]), | |
| 11552 ElementFactory.methodElement("%", _doubleType, [_numType]), | |
| 11553 ElementFactory.methodElement("/", _doubleType, [_numType]), | |
| 11554 ElementFactory.methodElement("~/", _doubleType, [_numType]), | |
| 11555 ElementFactory.methodElement("-", _doubleType), | |
| 11556 ElementFactory.methodElement("abs", _doubleType), | |
| 11557 ElementFactory.methodElement("round", _doubleType), | |
| 11558 ElementFactory.methodElement("floor", _doubleType), | |
| 11559 ElementFactory.methodElement("ceil", _doubleType), | |
| 11560 ElementFactory.methodElement("truncate", _doubleType), | |
| 11561 ElementFactory.methodElement("toString", _stringType)]; | |
| 11562 } | |
| 11563 | |
| 11564 /** | |
| 11565 * Given a class element representing a class with type parameters, propagate
those type | |
| 11566 * parameters to all of the accessors, methods and constructors defined for th
e class. | |
| 11567 * | |
| 11568 * @param classElement the element representing the class with type parameters | |
| 11569 */ | |
| 11570 void _propagateTypeArguments(ClassElementImpl classElement) { | |
| 11571 List<DartType> typeArguments = | |
| 11572 TypeParameterTypeImpl.getTypes(classElement.typeParameters); | |
| 11573 for (PropertyAccessorElement accessor in classElement.accessors) { | |
| 11574 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl; | |
| 11575 functionType.typeArguments = typeArguments; | |
| 11576 } | |
| 11577 for (MethodElement method in classElement.methods) { | |
| 11578 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; | |
| 11579 functionType.typeArguments = typeArguments; | |
| 11580 } | |
| 11581 for (ConstructorElement constructor in classElement.constructors) { | |
| 11582 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; | |
| 11583 functionType.typeArguments = typeArguments; | |
| 11584 } | |
| 11585 } | |
| 11586 } | |
| 11587 | 11120 |
| 11588 @reflectiveTest | 11121 @reflectiveTest |
| 11589 class TypeOverrideManagerTest extends EngineTestCase { | 11122 class TypeOverrideManagerTest extends EngineTestCase { |
| 11590 void test_exitScope_noScopes() { | 11123 void test_exitScope_noScopes() { |
| 11591 TypeOverrideManager manager = new TypeOverrideManager(); | 11124 TypeOverrideManager manager = new TypeOverrideManager(); |
| 11592 try { | 11125 try { |
| 11593 manager.exitScope(); | 11126 manager.exitScope(); |
| 11594 fail("Expected IllegalStateException"); | 11127 fail("Expected IllegalStateException"); |
| 11595 } on IllegalStateException catch (exception) { | 11128 } on IllegalStateException catch (exception) { |
| 11596 // Expected | 11129 // Expected |
| (...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13811 // check propagated type | 13344 // check propagated type |
| 13812 FunctionType propagatedType = node.propagatedType as FunctionType; | 13345 FunctionType propagatedType = node.propagatedType as FunctionType; |
| 13813 expect(propagatedType.returnType, test.typeProvider.stringType); | 13346 expect(propagatedType.returnType, test.typeProvider.stringType); |
| 13814 } on AnalysisException catch (e, stackTrace) { | 13347 } on AnalysisException catch (e, stackTrace) { |
| 13815 thrownException[0] = new CaughtException(e, stackTrace); | 13348 thrownException[0] = new CaughtException(e, stackTrace); |
| 13816 } | 13349 } |
| 13817 } | 13350 } |
| 13818 return null; | 13351 return null; |
| 13819 } | 13352 } |
| 13820 } | 13353 } |
| OLD | NEW |