| 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 analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 futureElement.constructors = <ConstructorElement>[futureConstructor]; | 190 futureElement.constructors = <ConstructorElement>[futureConstructor]; |
| 191 // Future then(onValue(T value), { Function onError }); | 191 // Future then(onValue(T value), { Function onError }); |
| 192 TypeDefiningElement futureThenR = DynamicElementImpl.instance; | 192 TypeDefiningElement futureThenR = DynamicElementImpl.instance; |
| 193 if (context.analysisOptions.strongMode) { | 193 if (context.analysisOptions.strongMode) { |
| 194 futureThenR = ElementFactory.typeParameterWithType('R'); | 194 futureThenR = ElementFactory.typeParameterWithType('R'); |
| 195 } | 195 } |
| 196 FunctionElementImpl thenOnValue = ElementFactory.functionElement3( | 196 FunctionElementImpl thenOnValue = ElementFactory.functionElement3( |
| 197 'onValue', futureThenR, [futureElement.typeParameters[0]], null); | 197 'onValue', futureThenR, [futureElement.typeParameters[0]], null); |
| 198 | 198 |
| 199 DartType futureRType = futureElement.type.substitute4([futureThenR.type]); | 199 DartType futureRType = futureElement.type.substitute4([futureThenR.type]); |
| 200 MethodElementImpl thenMethod = ElementFactory.methodElementWithParameters( | 200 MethodElementImpl thenMethod = ElementFactory |
| 201 futureElement, "then", futureRType, [ | 201 .methodElementWithParameters(futureElement, "then", futureRType, [ |
| 202 ElementFactory.requiredParameter2("onValue", thenOnValue.type), | 202 ElementFactory.requiredParameter2("onValue", thenOnValue.type), |
| 203 ElementFactory.namedParameter2("onError", provider.functionType) | 203 ElementFactory.namedParameter2("onError", provider.functionType) |
| 204 ]); | 204 ]); |
| 205 if (!futureThenR.type.isDynamic) { | 205 if (!futureThenR.type.isDynamic) { |
| 206 thenMethod.typeParameters = [futureThenR]; | 206 thenMethod.typeParameters = [futureThenR]; |
| 207 } | 207 } |
| 208 thenOnValue.enclosingElement = thenMethod; | 208 thenOnValue.enclosingElement = thenMethod; |
| 209 thenOnValue.type = new FunctionTypeImpl(thenOnValue); | 209 thenOnValue.type = new FunctionTypeImpl(thenOnValue); |
| 210 (thenMethod.parameters[0] as ParameterElementImpl).type = thenOnValue.type; | 210 (thenMethod.parameters[0] as ParameterElementImpl).type = thenOnValue.type; |
| 211 thenMethod.type = new FunctionTypeImpl(thenMethod); | 211 thenMethod.type = new FunctionTypeImpl(thenMethod); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 ElementFactory.getterElement("context2D", false, context2dElement.type) | 280 ElementFactory.getterElement("context2D", false, context2dElement.type) |
| 281 ]; | 281 ]; |
| 282 canvasElement.fields = canvasElement.accessors | 282 canvasElement.fields = canvasElement.accessors |
| 283 .map((PropertyAccessorElement accessor) => accessor.variable) | 283 .map((PropertyAccessorElement accessor) => accessor.variable) |
| 284 .toList(); | 284 .toList(); |
| 285 ClassElementImpl documentElement = | 285 ClassElementImpl documentElement = |
| 286 ElementFactory.classElement("Document", elementType); | 286 ElementFactory.classElement("Document", elementType); |
| 287 ClassElementImpl htmlDocumentElement = | 287 ClassElementImpl htmlDocumentElement = |
| 288 ElementFactory.classElement("HtmlDocument", documentElement.type); | 288 ElementFactory.classElement("HtmlDocument", documentElement.type); |
| 289 htmlDocumentElement.methods = <MethodElement>[ | 289 htmlDocumentElement.methods = <MethodElement>[ |
| 290 ElementFactory.methodElement( | 290 ElementFactory |
| 291 "query", elementType, <DartType>[provider.stringType]) | 291 .methodElement("query", elementType, <DartType>[provider.stringType]) |
| 292 ]; | 292 ]; |
| 293 htmlUnit.types = <ClassElement>[ | 293 htmlUnit.types = <ClassElement>[ |
| 294 ElementFactory.classElement("AnchorElement", elementType), | 294 ElementFactory.classElement("AnchorElement", elementType), |
| 295 ElementFactory.classElement("BodyElement", elementType), | 295 ElementFactory.classElement("BodyElement", elementType), |
| 296 ElementFactory.classElement("ButtonElement", elementType), | 296 ElementFactory.classElement("ButtonElement", elementType), |
| 297 canvasElement, | 297 canvasElement, |
| 298 contextElement, | 298 contextElement, |
| 299 context2dElement, | 299 context2dElement, |
| 300 ElementFactory.classElement("DivElement", elementType), | 300 ElementFactory.classElement("DivElement", elementType), |
| 301 documentElement, | 301 documentElement, |
| 302 elementElement, | 302 elementElement, |
| 303 htmlDocumentElement, | 303 htmlDocumentElement, |
| 304 ElementFactory.classElement("InputElement", elementType), | 304 ElementFactory.classElement("InputElement", elementType), |
| 305 ElementFactory.classElement("SelectElement", elementType) | 305 ElementFactory.classElement("SelectElement", elementType) |
| 306 ]; | 306 ]; |
| 307 htmlUnit.functions = <FunctionElement>[ | 307 htmlUnit.functions = <FunctionElement>[ |
| 308 ElementFactory.functionElement3("query", elementElement, | 308 ElementFactory.functionElement3("query", elementElement, |
| 309 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST) | 309 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST) |
| 310 ]; | 310 ]; |
| 311 TopLevelVariableElementImpl document = ElementFactory | 311 TopLevelVariableElementImpl document = |
| 312 .topLevelVariableElement3( | 312 ElementFactory.topLevelVariableElement3( |
| 313 "document", false, true, htmlDocumentElement.type); | 313 "document", false, true, htmlDocumentElement.type); |
| 314 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document]; | 314 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document]; |
| 315 htmlUnit.accessors = <PropertyAccessorElement>[document.getter]; | 315 htmlUnit.accessors = <PropertyAccessorElement>[document.getter]; |
| 316 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode( | 316 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode( |
| 317 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"])); | 317 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"])); |
| 318 htmlLibrary.definingCompilationUnit = htmlUnit; | 318 htmlLibrary.definingCompilationUnit = htmlUnit; |
| 319 // | 319 // |
| 320 // dart:math | 320 // dart:math |
| 321 // | 321 // |
| 322 CompilationUnitElementImpl mathUnit = | 322 CompilationUnitElementImpl mathUnit = |
| (...skipping 3128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3451 } | 3451 } |
| 3452 | 3452 |
| 3453 void test_undefinedGetter_message() { | 3453 void test_undefinedGetter_message() { |
| 3454 // The implementation of HintCode.UNDEFINED_SETTER assumes that | 3454 // The implementation of HintCode.UNDEFINED_SETTER assumes that |
| 3455 // UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the | 3455 // UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the |
| 3456 // same, this verifies that assumption. | 3456 // same, this verifies that assumption. |
| 3457 expect(StaticWarningCode.UNDEFINED_GETTER.message, | 3457 expect(StaticWarningCode.UNDEFINED_GETTER.message, |
| 3458 StaticTypeWarningCode.UNDEFINED_GETTER.message); | 3458 StaticTypeWarningCode.UNDEFINED_GETTER.message); |
| 3459 } | 3459 } |
| 3460 | 3460 |
| 3461 void test_undefinedIdentifier_inComment_prefixed_prefix() { |
| 3462 Source source = addSource(r''' |
| 3463 /// [Foo.bar] |
| 3464 main() {} |
| 3465 '''); |
| 3466 computeLibrarySourceErrors(source); |
| 3467 assertErrors(source, [HintCode.UNDEFINED_IDENTIFIER]); |
| 3468 verify([source]); |
| 3469 } |
| 3470 |
| 3471 void test_undefinedIdentifier_inComment_simple() { |
| 3472 Source source = addSource(r''' |
| 3473 /// [Foo] |
| 3474 main() {} |
| 3475 '''); |
| 3476 computeLibrarySourceErrors(source); |
| 3477 assertErrors(source, [HintCode.UNDEFINED_IDENTIFIER]); |
| 3478 verify([source]); |
| 3479 } |
| 3480 |
| 3481 void test_undefinedMember_inComment_prefixed_name() { |
| 3482 Source source = addSource(r''' |
| 3483 class Foo {} |
| 3484 /// [Foo.bar] |
| 3485 main() {} |
| 3486 '''); |
| 3487 computeLibrarySourceErrors(source); |
| 3488 assertErrors(source, [HintCode.UNDEFINED_MEMBER]); |
| 3489 verify([source]); |
| 3490 } |
| 3491 |
| 3461 void test_undefinedMethod() { | 3492 void test_undefinedMethod() { |
| 3462 Source source = addSource(r''' | 3493 Source source = addSource(r''' |
| 3463 f() { | 3494 f() { |
| 3464 var a = 'str'; | 3495 var a = 'str'; |
| 3465 a.notAMethodOnString(); | 3496 a.notAMethodOnString(); |
| 3466 }'''); | 3497 }'''); |
| 3467 computeLibrarySourceErrors(source); | 3498 computeLibrarySourceErrors(source); |
| 3468 assertErrors(source, [HintCode.UNDEFINED_METHOD]); | 3499 assertErrors(source, [HintCode.UNDEFINED_METHOD]); |
| 3469 } | 3500 } |
| 3470 | 3501 |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5142 | 5173 |
| 5143 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { | 5174 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { |
| 5144 // class A {} | 5175 // class A {} |
| 5145 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5176 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5146 MemberMap mapA = | 5177 MemberMap mapA = |
| 5147 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5178 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5148 expect(mapA.size, _numOfMembersInObject); | 5179 expect(mapA.size, _numOfMembersInObject); |
| 5149 _assertNoErrors(classA); | 5180 _assertNoErrors(classA); |
| 5150 } | 5181 } |
| 5151 | 5182 |
| 5152 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_getter_method() { | 5183 void |
| 5184 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
getter_method() { |
| 5153 // class I1 { int m(); } | 5185 // class I1 { int m(); } |
| 5154 // class I2 { int get m; } | 5186 // class I2 { int get m; } |
| 5155 // class A implements I2, I1 {} | 5187 // class A implements I2, I1 {} |
| 5156 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5188 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5157 String methodName = "m"; | 5189 String methodName = "m"; |
| 5158 MethodElement methodM = | 5190 MethodElement methodM = |
| 5159 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5191 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5160 classI1.methods = <MethodElement>[methodM]; | 5192 classI1.methods = <MethodElement>[methodM]; |
| 5161 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5193 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5162 PropertyAccessorElement getter = | 5194 PropertyAccessorElement getter = |
| 5163 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 5195 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
| 5164 classI2.accessors = <PropertyAccessorElement>[getter]; | 5196 classI2.accessors = <PropertyAccessorElement>[getter]; |
| 5165 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5197 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5166 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 5198 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
| 5167 MemberMap mapA = | 5199 MemberMap mapA = |
| 5168 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5200 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5169 expect(mapA.size, _numOfMembersInObject); | 5201 expect(mapA.size, _numOfMembersInObject); |
| 5170 expect(mapA.get(methodName), isNull); | 5202 expect(mapA.get(methodName), isNull); |
| 5171 _assertErrors(classA, | 5203 _assertErrors(classA, |
| 5172 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 5204 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
| 5173 } | 5205 } |
| 5174 | 5206 |
| 5175 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_int_str() { | 5207 void |
| 5208 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
int_str() { |
| 5176 // class I1 { int m(); } | 5209 // class I1 { int m(); } |
| 5177 // class I2 { String m(); } | 5210 // class I2 { String m(); } |
| 5178 // class A implements I1, I2 {} | 5211 // class A implements I1, I2 {} |
| 5179 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5212 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5180 String methodName = "m"; | 5213 String methodName = "m"; |
| 5181 MethodElement methodM1 = | 5214 MethodElement methodM1 = |
| 5182 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 5215 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
| 5183 classI1.methods = <MethodElement>[methodM1]; | 5216 classI1.methods = <MethodElement>[methodM1]; |
| 5184 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5217 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5185 MethodElement methodM2 = ElementFactory.methodElement( | 5218 MethodElement methodM2 = ElementFactory |
| 5186 methodName, null, [_typeProvider.stringType]); | 5219 .methodElement(methodName, null, [_typeProvider.stringType]); |
| 5187 classI2.methods = <MethodElement>[methodM2]; | 5220 classI2.methods = <MethodElement>[methodM2]; |
| 5188 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5221 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5189 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5222 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5190 MemberMap mapA = | 5223 MemberMap mapA = |
| 5191 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5224 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5192 expect(mapA.size, _numOfMembersInObject); | 5225 expect(mapA.size, _numOfMembersInObject); |
| 5193 expect(mapA.get(methodName), isNull); | 5226 expect(mapA.get(methodName), isNull); |
| 5194 _assertErrors( | 5227 _assertErrors( |
| 5195 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 5228 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
| 5196 } | 5229 } |
| 5197 | 5230 |
| 5198 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_method_getter() { | 5231 void |
| 5232 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
method_getter() { |
| 5199 // class I1 { int m(); } | 5233 // class I1 { int m(); } |
| 5200 // class I2 { int get m; } | 5234 // class I2 { int get m; } |
| 5201 // class A implements I1, I2 {} | 5235 // class A implements I1, I2 {} |
| 5202 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5236 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5203 String methodName = "m"; | 5237 String methodName = "m"; |
| 5204 MethodElement methodM = | 5238 MethodElement methodM = |
| 5205 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5239 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5206 classI1.methods = <MethodElement>[methodM]; | 5240 classI1.methods = <MethodElement>[methodM]; |
| 5207 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5241 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5208 PropertyAccessorElement getter = | 5242 PropertyAccessorElement getter = |
| 5209 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 5243 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
| 5210 classI2.accessors = <PropertyAccessorElement>[getter]; | 5244 classI2.accessors = <PropertyAccessorElement>[getter]; |
| 5211 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5245 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5212 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5246 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5213 MemberMap mapA = | 5247 MemberMap mapA = |
| 5214 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5248 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5215 expect(mapA.size, _numOfMembersInObject); | 5249 expect(mapA.size, _numOfMembersInObject); |
| 5216 expect(mapA.get(methodName), isNull); | 5250 expect(mapA.get(methodName), isNull); |
| 5217 _assertErrors(classA, | 5251 _assertErrors(classA, |
| 5218 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 5252 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
| 5219 } | 5253 } |
| 5220 | 5254 |
| 5221 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_numOfRequiredParams() { | 5255 void |
| 5256 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
numOfRequiredParams() { |
| 5222 // class I1 { dynamic m(int, [int]); } | 5257 // class I1 { dynamic m(int, [int]); } |
| 5223 // class I2 { dynamic m(int, int, int); } | 5258 // class I2 { dynamic m(int, int, int); } |
| 5224 // class A implements I1, I2 {} | 5259 // class A implements I1, I2 {} |
| 5225 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5260 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5226 String methodName = "m"; | 5261 String methodName = "m"; |
| 5227 MethodElementImpl methodM1 = | 5262 MethodElementImpl methodM1 = |
| 5228 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 5263 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 5229 ParameterElementImpl parameter1 = | 5264 ParameterElementImpl parameter1 = |
| 5230 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 5265 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 5231 parameter1.type = _typeProvider.intType; | 5266 parameter1.type = _typeProvider.intType; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5260 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5295 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5261 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5296 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5262 MemberMap mapA = | 5297 MemberMap mapA = |
| 5263 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5298 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5264 expect(mapA.size, _numOfMembersInObject); | 5299 expect(mapA.size, _numOfMembersInObject); |
| 5265 expect(mapA.get(methodName), isNull); | 5300 expect(mapA.get(methodName), isNull); |
| 5266 _assertErrors( | 5301 _assertErrors( |
| 5267 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 5302 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
| 5268 } | 5303 } |
| 5269 | 5304 |
| 5270 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_str_int() { | 5305 void |
| 5306 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
str_int() { |
| 5271 // class I1 { int m(); } | 5307 // class I1 { int m(); } |
| 5272 // class I2 { String m(); } | 5308 // class I2 { String m(); } |
| 5273 // class A implements I2, I1 {} | 5309 // class A implements I2, I1 {} |
| 5274 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5310 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5275 String methodName = "m"; | 5311 String methodName = "m"; |
| 5276 MethodElement methodM1 = ElementFactory.methodElement( | 5312 MethodElement methodM1 = ElementFactory |
| 5277 methodName, null, [_typeProvider.stringType]); | 5313 .methodElement(methodName, null, [_typeProvider.stringType]); |
| 5278 classI1.methods = <MethodElement>[methodM1]; | 5314 classI1.methods = <MethodElement>[methodM1]; |
| 5279 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5315 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5280 MethodElement methodM2 = | 5316 MethodElement methodM2 = |
| 5281 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 5317 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
| 5282 classI2.methods = <MethodElement>[methodM2]; | 5318 classI2.methods = <MethodElement>[methodM2]; |
| 5283 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5319 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5284 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 5320 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
| 5285 MemberMap mapA = | 5321 MemberMap mapA = |
| 5286 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5322 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5287 expect(mapA.size, _numOfMembersInObject); | 5323 expect(mapA.size, _numOfMembersInObject); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5369 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5405 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5370 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5406 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5371 MemberMap mapA = | 5407 MemberMap mapA = |
| 5372 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5408 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5373 expect(mapA.size, _numOfMembersInObject + 2); | 5409 expect(mapA.size, _numOfMembersInObject + 2); |
| 5374 expect(mapA.get(methodName1), same(methodM1)); | 5410 expect(mapA.get(methodName1), same(methodM1)); |
| 5375 expect(mapA.get(methodName2), same(methodM2)); | 5411 expect(mapA.get(methodName2), same(methodM2)); |
| 5376 _assertNoErrors(classA); | 5412 _assertNoErrors(classA); |
| 5377 } | 5413 } |
| 5378 | 5414 |
| 5379 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_gett
ers() { | 5415 void |
| 5416 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_gette
rs() { |
| 5380 // class I1 { int get g; } | 5417 // class I1 { int get g; } |
| 5381 // class I2 { num get g; } | 5418 // class I2 { num get g; } |
| 5382 // class A implements I1, I2 {} | 5419 // class A implements I1, I2 {} |
| 5383 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5420 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5384 String accessorName = "g"; | 5421 String accessorName = "g"; |
| 5385 PropertyAccessorElement getter1 = ElementFactory.getterElement( | 5422 PropertyAccessorElement getter1 = ElementFactory.getterElement( |
| 5386 accessorName, false, _typeProvider.intType); | 5423 accessorName, false, _typeProvider.intType); |
| 5387 classI1.accessors = <PropertyAccessorElement>[getter1]; | 5424 classI1.accessors = <PropertyAccessorElement>[getter1]; |
| 5388 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5425 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5389 PropertyAccessorElement getter2 = ElementFactory.getterElement( | 5426 PropertyAccessorElement getter2 = ElementFactory.getterElement( |
| 5390 accessorName, false, _typeProvider.numType); | 5427 accessorName, false, _typeProvider.numType); |
| 5391 classI2.accessors = <PropertyAccessorElement>[getter2]; | 5428 classI2.accessors = <PropertyAccessorElement>[getter2]; |
| 5392 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5429 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5393 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5430 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5394 MemberMap mapA = | 5431 MemberMap mapA = |
| 5395 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5432 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5396 expect(mapA.size, _numOfMembersInObject + 1); | 5433 expect(mapA.size, _numOfMembersInObject + 1); |
| 5397 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 5434 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
| 5398 accessorName, false, _typeProvider.dynamicType); | 5435 accessorName, false, _typeProvider.dynamicType); |
| 5399 expect(mapA.get(accessorName).type, syntheticAccessor.type); | 5436 expect(mapA.get(accessorName).type, syntheticAccessor.type); |
| 5400 _assertNoErrors(classA); | 5437 _assertNoErrors(classA); |
| 5401 } | 5438 } |
| 5402 | 5439 |
| 5403 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_meth
ods() { | 5440 void |
| 5441 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_metho
ds() { |
| 5404 // class I1 { dynamic m(int); } | 5442 // class I1 { dynamic m(int); } |
| 5405 // class I2 { dynamic m(num); } | 5443 // class I2 { dynamic m(num); } |
| 5406 // class A implements I1, I2 {} | 5444 // class A implements I1, I2 {} |
| 5407 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5445 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5408 String methodName = "m"; | 5446 String methodName = "m"; |
| 5409 MethodElementImpl methodM1 = | 5447 MethodElementImpl methodM1 = |
| 5410 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 5448 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 5411 ParameterElementImpl parameter1 = | 5449 ParameterElementImpl parameter1 = |
| 5412 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 5450 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 5413 parameter1.type = _typeProvider.intType; | 5451 parameter1.type = _typeProvider.intType; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5427 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5465 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5428 MemberMap mapA = | 5466 MemberMap mapA = |
| 5429 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5467 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5430 expect(mapA.size, _numOfMembersInObject + 1); | 5468 expect(mapA.size, _numOfMembersInObject + 1); |
| 5431 MethodElement syntheticMethod = ElementFactory.methodElement( | 5469 MethodElement syntheticMethod = ElementFactory.methodElement( |
| 5432 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 5470 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
| 5433 expect(mapA.get(methodName).type, syntheticMethod.type); | 5471 expect(mapA.get(methodName).type, syntheticMethod.type); |
| 5434 _assertNoErrors(classA); | 5472 _assertNoErrors(classA); |
| 5435 } | 5473 } |
| 5436 | 5474 |
| 5437 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_sett
ers() { | 5475 void |
| 5476 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_sette
rs() { |
| 5438 // class I1 { set s(int); } | 5477 // class I1 { set s(int); } |
| 5439 // class I2 { set s(num); } | 5478 // class I2 { set s(num); } |
| 5440 // class A implements I1, I2 {} | 5479 // class A implements I1, I2 {} |
| 5441 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5480 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5442 String accessorName = "s"; | 5481 String accessorName = "s"; |
| 5443 PropertyAccessorElement setter1 = ElementFactory.setterElement( | 5482 PropertyAccessorElement setter1 = ElementFactory.setterElement( |
| 5444 accessorName, false, _typeProvider.intType); | 5483 accessorName, false, _typeProvider.intType); |
| 5445 classI1.accessors = <PropertyAccessorElement>[setter1]; | 5484 classI1.accessors = <PropertyAccessorElement>[setter1]; |
| 5446 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5485 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5447 PropertyAccessorElement setter2 = ElementFactory.setterElement( | 5486 PropertyAccessorElement setter2 = ElementFactory.setterElement( |
| 5448 accessorName, false, _typeProvider.numType); | 5487 accessorName, false, _typeProvider.numType); |
| 5449 classI2.accessors = <PropertyAccessorElement>[setter2]; | 5488 classI2.accessors = <PropertyAccessorElement>[setter2]; |
| 5450 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5489 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5451 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5490 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5452 MemberMap mapA = | 5491 MemberMap mapA = |
| 5453 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5492 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5454 expect(mapA.size, _numOfMembersInObject + 1); | 5493 expect(mapA.size, _numOfMembersInObject + 1); |
| 5455 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 5494 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
| 5456 .setterElement(accessorName, false, _typeProvider.dynamicType); | 5495 .setterElement(accessorName, false, _typeProvider.dynamicType); |
| 5457 syntheticAccessor.returnType = _typeProvider.dynamicType; | 5496 syntheticAccessor.returnType = _typeProvider.dynamicType; |
| 5458 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); | 5497 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); |
| 5459 _assertNoErrors(classA); | 5498 _assertNoErrors(classA); |
| 5460 } | 5499 } |
| 5461 | 5500 |
| 5462 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_gett
ers() { | 5501 void |
| 5502 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_gette
rs() { |
| 5463 // class A {} | 5503 // class A {} |
| 5464 // class B extends A {} | 5504 // class B extends A {} |
| 5465 // class C extends B {} | 5505 // class C extends B {} |
| 5466 // class I1 { A get g; } | 5506 // class I1 { A get g; } |
| 5467 // class I2 { B get g; } | 5507 // class I2 { B get g; } |
| 5468 // class I3 { C get g; } | 5508 // class I3 { C get g; } |
| 5469 // class D implements I1, I2, I3 {} | 5509 // class D implements I1, I2, I3 {} |
| 5470 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5510 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5471 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5511 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 5472 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5512 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5491 ]; | 5531 ]; |
| 5492 MemberMap mapD = | 5532 MemberMap mapD = |
| 5493 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5533 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 5494 expect(mapD.size, _numOfMembersInObject + 1); | 5534 expect(mapD.size, _numOfMembersInObject + 1); |
| 5495 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 5535 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
| 5496 accessorName, false, _typeProvider.dynamicType); | 5536 accessorName, false, _typeProvider.dynamicType); |
| 5497 expect(mapD.get(accessorName).type, syntheticAccessor.type); | 5537 expect(mapD.get(accessorName).type, syntheticAccessor.type); |
| 5498 _assertNoErrors(classD); | 5538 _assertNoErrors(classD); |
| 5499 } | 5539 } |
| 5500 | 5540 |
| 5501 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_meth
ods() { | 5541 void |
| 5542 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_metho
ds() { |
| 5502 // class A {} | 5543 // class A {} |
| 5503 // class B extends A {} | 5544 // class B extends A {} |
| 5504 // class C extends B {} | 5545 // class C extends B {} |
| 5505 // class I1 { dynamic m(A a); } | 5546 // class I1 { dynamic m(A a); } |
| 5506 // class I2 { dynamic m(B b); } | 5547 // class I2 { dynamic m(B b); } |
| 5507 // class I3 { dynamic m(C c); } | 5548 // class I3 { dynamic m(C c); } |
| 5508 // class D implements I1, I2, I3 {} | 5549 // class D implements I1, I2, I3 {} |
| 5509 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5550 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5510 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5551 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 5511 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5552 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5545 ]; | 5586 ]; |
| 5546 MemberMap mapD = | 5587 MemberMap mapD = |
| 5547 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5588 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 5548 expect(mapD.size, _numOfMembersInObject + 1); | 5589 expect(mapD.size, _numOfMembersInObject + 1); |
| 5549 MethodElement syntheticMethod = ElementFactory.methodElement( | 5590 MethodElement syntheticMethod = ElementFactory.methodElement( |
| 5550 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 5591 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
| 5551 expect(mapD.get(methodName).type, syntheticMethod.type); | 5592 expect(mapD.get(methodName).type, syntheticMethod.type); |
| 5552 _assertNoErrors(classD); | 5593 _assertNoErrors(classD); |
| 5553 } | 5594 } |
| 5554 | 5595 |
| 5555 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_sett
ers() { | 5596 void |
| 5597 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_sette
rs() { |
| 5556 // class A {} | 5598 // class A {} |
| 5557 // class B extends A {} | 5599 // class B extends A {} |
| 5558 // class C extends B {} | 5600 // class C extends B {} |
| 5559 // class I1 { set s(A); } | 5601 // class I1 { set s(A); } |
| 5560 // class I2 { set s(B); } | 5602 // class I2 { set s(B); } |
| 5561 // class I3 { set s(C); } | 5603 // class I3 { set s(C); } |
| 5562 // class D implements I1, I2, I3 {} | 5604 // class D implements I1, I2, I3 {} |
| 5563 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5605 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5564 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5606 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 5565 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5607 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5585 MemberMap mapD = | 5627 MemberMap mapD = |
| 5586 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5628 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 5587 expect(mapD.size, _numOfMembersInObject + 1); | 5629 expect(mapD.size, _numOfMembersInObject + 1); |
| 5588 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 5630 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
| 5589 .setterElement(accessorName, false, _typeProvider.dynamicType); | 5631 .setterElement(accessorName, false, _typeProvider.dynamicType); |
| 5590 syntheticAccessor.returnType = _typeProvider.dynamicType; | 5632 syntheticAccessor.returnType = _typeProvider.dynamicType; |
| 5591 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); | 5633 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); |
| 5592 _assertNoErrors(classD); | 5634 _assertNoErrors(classD); |
| 5593 } | 5635 } |
| 5594 | 5636 |
| 5595 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods()
{ | 5637 void |
| 5638 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() { |
| 5596 // class I1 { int m(); } | 5639 // class I1 { int m(); } |
| 5597 // class I2 { int m([int]); } | 5640 // class I2 { int m([int]); } |
| 5598 // class A implements I1, I2 {} | 5641 // class A implements I1, I2 {} |
| 5599 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5642 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5600 String methodName = "m"; | 5643 String methodName = "m"; |
| 5601 MethodElement methodM1 = | 5644 MethodElement methodM1 = |
| 5602 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5645 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5603 classI1.methods = <MethodElement>[methodM1]; | 5646 classI1.methods = <MethodElement>[methodM1]; |
| 5604 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5647 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 5605 MethodElementImpl methodM2 = | 5648 MethodElementImpl methodM2 = |
| 5606 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5649 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5607 ParameterElementImpl parameter1 = | 5650 ParameterElementImpl parameter1 = |
| 5608 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 5651 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 5609 parameter1.type = _typeProvider.intType; | 5652 parameter1.type = _typeProvider.intType; |
| 5610 parameter1.parameterKind = ParameterKind.POSITIONAL; | 5653 parameter1.parameterKind = ParameterKind.POSITIONAL; |
| 5611 methodM2.parameters = <ParameterElement>[parameter1]; | 5654 methodM2.parameters = <ParameterElement>[parameter1]; |
| 5612 classI2.methods = <MethodElement>[methodM2]; | 5655 classI2.methods = <MethodElement>[methodM2]; |
| 5613 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5656 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 5614 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5657 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 5615 MemberMap mapA = | 5658 MemberMap mapA = |
| 5616 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5659 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5617 expect(mapA.size, _numOfMembersInObject + 1); | 5660 expect(mapA.size, _numOfMembersInObject + 1); |
| 5618 expect(mapA.get(methodName), same(methodM2)); | 5661 expect(mapA.get(methodName), same(methodM2)); |
| 5619 _assertNoErrors(classA); | 5662 _assertNoErrors(classA); |
| 5620 } | 5663 } |
| 5621 | 5664 |
| 5622 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods()
{ | 5665 void |
| 5666 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() { |
| 5623 // class I1 { int m(); } | 5667 // class I1 { int m(); } |
| 5624 // class I2 { int m([int]); } | 5668 // class I2 { int m([int]); } |
| 5625 // class I3 { int m([int, int]); } | 5669 // class I3 { int m([int, int]); } |
| 5626 // class A implements I1, I2, I3 {} | 5670 // class A implements I1, I2, I3 {} |
| 5627 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5671 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5628 String methodName = "m"; | 5672 String methodName = "m"; |
| 5629 MethodElementImpl methodM1 = | 5673 MethodElementImpl methodM1 = |
| 5630 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5674 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5631 classI1.methods = <MethodElement>[methodM1]; | 5675 classI1.methods = <MethodElement>[methodM1]; |
| 5632 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5676 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5657 classI2.type, | 5701 classI2.type, |
| 5658 classI3.type | 5702 classI3.type |
| 5659 ]; | 5703 ]; |
| 5660 MemberMap mapA = | 5704 MemberMap mapA = |
| 5661 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5705 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 5662 expect(mapA.size, _numOfMembersInObject + 1); | 5706 expect(mapA.size, _numOfMembersInObject + 1); |
| 5663 expect(mapA.get(methodName), same(methodM3)); | 5707 expect(mapA.get(methodName), same(methodM3)); |
| 5664 _assertNoErrors(classA); | 5708 _assertNoErrors(classA); |
| 5665 } | 5709 } |
| 5666 | 5710 |
| 5667 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods()
{ | 5711 void |
| 5712 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() { |
| 5668 // class I1 { int m(); } | 5713 // class I1 { int m(); } |
| 5669 // class I2 { int m(); } | 5714 // class I2 { int m(); } |
| 5670 // class I3 { int m([int]); } | 5715 // class I3 { int m([int]); } |
| 5671 // class I4 { int m([int, int]); } | 5716 // class I4 { int m([int, int]); } |
| 5672 // class A implements I1, I2, I3, I4 {} | 5717 // class A implements I1, I2, I3, I4 {} |
| 5673 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5718 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 5674 String methodName = "m"; | 5719 String methodName = "m"; |
| 5675 MethodElement methodM1 = | 5720 MethodElement methodM1 = |
| 5676 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5721 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 5677 classI1.methods = <MethodElement>[methodM1]; | 5722 classI1.methods = <MethodElement>[methodM1]; |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6907 } | 6952 } |
| 6908 f(var a) { | 6953 f(var a) { |
| 6909 if(a is A) { | 6954 if(a is A) { |
| 6910 return a.b; | 6955 return a.b; |
| 6911 } | 6956 } |
| 6912 }'''); | 6957 }'''); |
| 6913 computeLibrarySourceErrors(source); | 6958 computeLibrarySourceErrors(source); |
| 6914 assertNoErrors(source); | 6959 assertNoErrors(source); |
| 6915 } | 6960 } |
| 6916 | 6961 |
| 6962 void test_undefinedIdentifier_inComment_empty() { |
| 6963 Source source = addSource(r''' |
| 6964 /// [] |
| 6965 main() {} |
| 6966 '''); |
| 6967 computeLibrarySourceErrors(source); |
| 6968 assertNoErrors(source); |
| 6969 verify([source]); |
| 6970 } |
| 6971 |
| 6972 void fail_undefinedIdentifier_inComment_inCode() { |
| 6973 Source source = addSource(r''' |
| 6974 /// Validate that every `a[i] == b[i]`. |
| 6975 main(a, b) {} |
| 6976 '''); |
| 6977 computeLibrarySourceErrors(source); |
| 6978 assertNoErrors(source); |
| 6979 verify([source]); |
| 6980 } |
| 6981 |
| 6982 void test_undefinedIdentifier_inComment_prefixed() { |
| 6983 Source source = addSource(r''' |
| 6984 class Foo { |
| 6985 bar() {} |
| 6986 get baz => null; |
| 6987 } |
| 6988 /// [Foo.bar] and [Foo.baz] |
| 6989 main() {} |
| 6990 '''); |
| 6991 computeLibrarySourceErrors(source); |
| 6992 assertNoErrors(source); |
| 6993 verify([source]); |
| 6994 } |
| 6995 |
| 6996 void test_undefinedIdentifier_inComment_simple() { |
| 6997 Source source = addSource(r''' |
| 6998 class Foo {} |
| 6999 /// [Foo] |
| 7000 main() {} |
| 7001 '''); |
| 7002 computeLibrarySourceErrors(source); |
| 7003 assertNoErrors(source); |
| 7004 verify([source]); |
| 7005 } |
| 7006 |
| 6917 void test_undefinedMethod_assignmentExpression_inSubtype() { | 7007 void test_undefinedMethod_assignmentExpression_inSubtype() { |
| 6918 Source source = addSource(r''' | 7008 Source source = addSource(r''' |
| 6919 class A {} | 7009 class A {} |
| 6920 class B extends A { | 7010 class B extends A { |
| 6921 operator +(B b) {return new B();} | 7011 operator +(B b) {return new B();} |
| 6922 } | 7012 } |
| 6923 f(var a, var a2) { | 7013 f(var a, var a2) { |
| 6924 a = new A(); | 7014 a = new A(); |
| 6925 a2 = new A(); | 7015 a2 = new A(); |
| 6926 a += a2; | 7016 a += a2; |
| (...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9359 expect(classes, hasLength(1)); | 9449 expect(classes, hasLength(1)); |
| 9360 List<ElementAnnotation> annotations = classes[0].metadata; | 9450 List<ElementAnnotation> annotations = classes[0].metadata; |
| 9361 expect(annotations, hasLength(1)); | 9451 expect(annotations, hasLength(1)); |
| 9362 assertNoErrors(source); | 9452 assertNoErrors(source); |
| 9363 verify([source]); | 9453 verify([source]); |
| 9364 CompilationUnit unit = resolveCompilationUnit(source, library); | 9454 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 9365 NodeList<CompilationUnitMember> declarations = unit.declarations; | 9455 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 9366 expect(declarations, hasLength(2)); | 9456 expect(declarations, hasLength(2)); |
| 9367 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) | 9457 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) |
| 9368 .variables | 9458 .variables |
| 9369 .variables[0].name.staticElement; | 9459 .variables[0] |
| 9460 .name |
| 9461 .staticElement; |
| 9370 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, | 9462 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, |
| 9371 PropertyInducingElement, expectedElement); | 9463 PropertyInducingElement, expectedElement); |
| 9372 expectedElement = (expectedElement as PropertyInducingElement).getter; | 9464 expectedElement = (expectedElement as PropertyInducingElement).getter; |
| 9373 Element actualElement = | 9465 Element actualElement = |
| 9374 (declarations[1] as ClassDeclaration).metadata[0].name.staticElement; | 9466 (declarations[1] as ClassDeclaration).metadata[0].name.staticElement; |
| 9375 expect(actualElement, same(expectedElement)); | 9467 expect(actualElement, same(expectedElement)); |
| 9376 } | 9468 } |
| 9377 | 9469 |
| 9378 void test_metadata_field() { | 9470 void test_metadata_field() { |
| 9379 Source source = addSource(r''' | 9471 Source source = addSource(r''' |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9550 expect(aliases, hasLength(1)); | 9642 expect(aliases, hasLength(1)); |
| 9551 List<ElementAnnotation> annotations = aliases[0].metadata; | 9643 List<ElementAnnotation> annotations = aliases[0].metadata; |
| 9552 expect(annotations, hasLength(1)); | 9644 expect(annotations, hasLength(1)); |
| 9553 assertNoErrors(source); | 9645 assertNoErrors(source); |
| 9554 verify([source]); | 9646 verify([source]); |
| 9555 CompilationUnit unit = resolveCompilationUnit(source, library); | 9647 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 9556 NodeList<CompilationUnitMember> declarations = unit.declarations; | 9648 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 9557 expect(declarations, hasLength(2)); | 9649 expect(declarations, hasLength(2)); |
| 9558 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) | 9650 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) |
| 9559 .variables | 9651 .variables |
| 9560 .variables[0].name.staticElement; | 9652 .variables[0] |
| 9653 .name |
| 9654 .staticElement; |
| 9561 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, | 9655 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, |
| 9562 PropertyInducingElement, expectedElement); | 9656 PropertyInducingElement, expectedElement); |
| 9563 expectedElement = (expectedElement as PropertyInducingElement).getter; | 9657 expectedElement = (expectedElement as PropertyInducingElement).getter; |
| 9564 Element actualElement = | 9658 Element actualElement = |
| 9565 (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement; | 9659 (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement; |
| 9566 expect(actualElement, same(expectedElement)); | 9660 expect(actualElement, same(expectedElement)); |
| 9567 } | 9661 } |
| 9568 | 9662 |
| 9569 void test_method_fromMixin() { | 9663 void test_method_fromMixin() { |
| 9570 Source source = addSource(r''' | 9664 Source source = addSource(r''' |
| (...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11773 } | 11867 } |
| 11774 | 11868 |
| 11775 /** | 11869 /** |
| 11776 * Strong mode static analyzer downwards inference tests | 11870 * Strong mode static analyzer downwards inference tests |
| 11777 */ | 11871 */ |
| 11778 @reflectiveTest | 11872 @reflectiveTest |
| 11779 class StrongModeDownwardsInferenceTest extends ResolverTestCase { | 11873 class StrongModeDownwardsInferenceTest extends ResolverTestCase { |
| 11780 TypeAssertions _assertions; | 11874 TypeAssertions _assertions; |
| 11781 AsserterBuilder<Element, DartType> _hasElement; | 11875 AsserterBuilder<Element, DartType> _hasElement; |
| 11782 AsserterBuilder<DartType, DartType> _isType; | 11876 AsserterBuilder<DartType, DartType> _isType; |
| 11783 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, | 11877 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, DartType> |
| 11784 DartType> _isFunction2Of; | 11878 _isFunction2Of; |
| 11785 AsserterBuilderBuilder<Asserter<DartType>, List<Asserter<DartType>>, | 11879 AsserterBuilderBuilder<Asserter<DartType>, List<Asserter<DartType>>, DartType> |
| 11786 DartType> _isInstantiationOf; | 11880 _isInstantiationOf; |
| 11787 Asserter<DartType> _isInt; | 11881 Asserter<DartType> _isInt; |
| 11788 Asserter<DartType> _isNum; | 11882 Asserter<DartType> _isNum; |
| 11789 Asserter<DartType> _isString; | 11883 Asserter<DartType> _isString; |
| 11790 Asserter<DartType> _isDynamic; | 11884 Asserter<DartType> _isDynamic; |
| 11791 AsserterBuilder<Asserter<DartType>, InterfaceType> _isListOf; | 11885 AsserterBuilder<Asserter<DartType>, InterfaceType> _isListOf; |
| 11792 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, | 11886 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, InterfaceType> |
| 11793 InterfaceType> _isMapOf; | 11887 _isMapOf; |
| 11794 | 11888 |
| 11795 @override | 11889 @override |
| 11796 void setUp() { | 11890 void setUp() { |
| 11797 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 11891 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 11798 options.strongMode = true; | 11892 options.strongMode = true; |
| 11799 resetWithOptions(options); | 11893 resetWithOptions(options); |
| 11800 _assertions = new TypeAssertions(typeProvider); | 11894 _assertions = new TypeAssertions(typeProvider); |
| 11801 _isType = _assertions.isType; | 11895 _isType = _assertions.isType; |
| 11802 _hasElement = _assertions.hasElement; | 11896 _hasElement = _assertions.hasElement; |
| 11803 _isInstantiationOf = _assertions.isInstantiationOf; | 11897 _isInstantiationOf = _assertions.isInstantiationOf; |
| (...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14014 import 'lib.dart'; | 14108 import 'lib.dart'; |
| 14015 class B extends A { | 14109 class B extends A { |
| 14016 m() { | 14110 m() { |
| 14017 return v; // marker | 14111 return v; // marker |
| 14018 } | 14112 } |
| 14019 }'''; | 14113 }'''; |
| 14020 _assertTypeOfMarkedExpression( | 14114 _assertTypeOfMarkedExpression( |
| 14021 code, typeProvider.dynamicType, typeProvider.intType); | 14115 code, typeProvider.dynamicType, typeProvider.intType); |
| 14022 } | 14116 } |
| 14023 | 14117 |
| 14024 void test_finalPropertyInducingVariable_classMember_instance_propagatedTarget(
) { | 14118 void |
| 14119 test_finalPropertyInducingVariable_classMember_instance_propagatedTarget()
{ |
| 14025 addNamedSource( | 14120 addNamedSource( |
| 14026 "/lib.dart", | 14121 "/lib.dart", |
| 14027 r''' | 14122 r''' |
| 14028 class A { | 14123 class A { |
| 14029 final v = 0; | 14124 final v = 0; |
| 14030 }'''); | 14125 }'''); |
| 14031 String code = r''' | 14126 String code = r''' |
| 14032 import 'lib.dart'; | 14127 import 'lib.dart'; |
| 14033 f(p) { | 14128 f(p) { |
| 14034 if (p is A) { | 14129 if (p is A) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14233 FormalParameter kParameter = EngineTestCase.findNode( | 14328 FormalParameter kParameter = EngineTestCase.findNode( |
| 14234 unit, code, "k, ", (node) => node is SimpleFormalParameter); | 14329 unit, code, "k, ", (node) => node is SimpleFormalParameter); |
| 14235 expect(kParameter.identifier.propagatedType, same(intType)); | 14330 expect(kParameter.identifier.propagatedType, same(intType)); |
| 14236 // v | 14331 // v |
| 14237 DartType stringType = typeProvider.stringType; | 14332 DartType stringType = typeProvider.stringType; |
| 14238 FormalParameter vParameter = EngineTestCase.findNode( | 14333 FormalParameter vParameter = EngineTestCase.findNode( |
| 14239 unit, code, "v)", (node) => node is SimpleFormalParameter); | 14334 unit, code, "v)", (node) => node is SimpleFormalParameter); |
| 14240 expect(vParameter.identifier.propagatedType, same(stringType)); | 14335 expect(vParameter.identifier.propagatedType, same(stringType)); |
| 14241 } | 14336 } |
| 14242 | 14337 |
| 14243 void test_functionExpression_asInvocationArgument_functionExpressionInvocation
() { | 14338 void |
| 14339 test_functionExpression_asInvocationArgument_functionExpressionInvocation(
) { |
| 14244 String code = r''' | 14340 String code = r''' |
| 14245 main() { | 14341 main() { |
| 14246 (f(String value)) {} ((v) { | 14342 (f(String value)) {} ((v) { |
| 14247 v; | 14343 v; |
| 14248 }); | 14344 }); |
| 14249 }'''; | 14345 }'''; |
| 14250 Source source = addSource(code); | 14346 Source source = addSource(code); |
| 14251 LibraryElement library = resolve2(source); | 14347 LibraryElement library = resolve2(source); |
| 14252 assertNoErrors(source); | 14348 assertNoErrors(source); |
| 14253 verify([source]); | 14349 verify([source]); |
| (...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16111 | 16207 |
| 16112 void _resolveTestUnit(String code) { | 16208 void _resolveTestUnit(String code) { |
| 16113 testCode = code; | 16209 testCode = code; |
| 16114 testSource = addSource(testCode); | 16210 testSource = addSource(testCode); |
| 16115 LibraryElement library = resolve2(testSource); | 16211 LibraryElement library = resolve2(testSource); |
| 16116 assertNoErrors(testSource); | 16212 assertNoErrors(testSource); |
| 16117 verify([testSource]); | 16213 verify([testSource]); |
| 16118 testUnit = resolveCompilationUnit(testSource, library); | 16214 testUnit = resolveCompilationUnit(testSource, library); |
| 16119 } | 16215 } |
| 16120 } | 16216 } |
| OLD | NEW |