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 | 200 MethodElementImpl thenMethod = ElementFactory.methodElementWithParameters( |
201 .methodElementWithParameters(futureElement, "then", futureRType, [ | 201 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 30 matching lines...) Expand all Loading... |
242 | 242 |
243 FunctionElementImpl listenParamFunction = parameterTypes[0].element; | 243 FunctionElementImpl listenParamFunction = parameterTypes[0].element; |
244 listenParamFunction.enclosingElement = listenMethod; | 244 listenParamFunction.enclosingElement = listenMethod; |
245 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction); | 245 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction); |
246 ParameterElementImpl listenParam = listenMethod.parameters[0]; | 246 ParameterElementImpl listenParam = listenMethod.parameters[0]; |
247 listenParam.type = listenParamFunction.type; | 247 listenParam.type = listenParamFunction.type; |
248 | 248 |
249 asyncUnit.types = <ClassElement>[ | 249 asyncUnit.types = <ClassElement>[ |
250 completerElement, | 250 completerElement, |
251 futureElement, | 251 futureElement, |
252 streamElement | 252 streamElement, |
| 253 streamSubscriptionElement |
253 ]; | 254 ]; |
254 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( | 255 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( |
255 coreContext, AstFactory.libraryIdentifier2(["dart", "async"])); | 256 coreContext, AstFactory.libraryIdentifier2(["dart", "async"])); |
256 asyncLibrary.definingCompilationUnit = asyncUnit; | 257 asyncLibrary.definingCompilationUnit = asyncUnit; |
257 // | 258 // |
258 // dart:html | 259 // dart:html |
259 // | 260 // |
260 CompilationUnitElementImpl htmlUnit = | 261 CompilationUnitElementImpl htmlUnit = |
261 new CompilationUnitElementImpl("html_dartium.dart"); | 262 new CompilationUnitElementImpl("html_dartium.dart"); |
262 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 263 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
(...skipping 16 matching lines...) Expand all Loading... |
279 ElementFactory.getterElement("context2D", false, context2dElement.type) | 280 ElementFactory.getterElement("context2D", false, context2dElement.type) |
280 ]; | 281 ]; |
281 canvasElement.fields = canvasElement.accessors | 282 canvasElement.fields = canvasElement.accessors |
282 .map((PropertyAccessorElement accessor) => accessor.variable) | 283 .map((PropertyAccessorElement accessor) => accessor.variable) |
283 .toList(); | 284 .toList(); |
284 ClassElementImpl documentElement = | 285 ClassElementImpl documentElement = |
285 ElementFactory.classElement("Document", elementType); | 286 ElementFactory.classElement("Document", elementType); |
286 ClassElementImpl htmlDocumentElement = | 287 ClassElementImpl htmlDocumentElement = |
287 ElementFactory.classElement("HtmlDocument", documentElement.type); | 288 ElementFactory.classElement("HtmlDocument", documentElement.type); |
288 htmlDocumentElement.methods = <MethodElement>[ | 289 htmlDocumentElement.methods = <MethodElement>[ |
289 ElementFactory | 290 ElementFactory.methodElement( |
290 .methodElement("query", elementType, <DartType>[provider.stringType]) | 291 "query", elementType, <DartType>[provider.stringType]) |
291 ]; | 292 ]; |
292 htmlUnit.types = <ClassElement>[ | 293 htmlUnit.types = <ClassElement>[ |
293 ElementFactory.classElement("AnchorElement", elementType), | 294 ElementFactory.classElement("AnchorElement", elementType), |
294 ElementFactory.classElement("BodyElement", elementType), | 295 ElementFactory.classElement("BodyElement", elementType), |
295 ElementFactory.classElement("ButtonElement", elementType), | 296 ElementFactory.classElement("ButtonElement", elementType), |
296 canvasElement, | 297 canvasElement, |
297 contextElement, | 298 contextElement, |
298 context2dElement, | 299 context2dElement, |
299 ElementFactory.classElement("DivElement", elementType), | 300 ElementFactory.classElement("DivElement", elementType), |
300 documentElement, | 301 documentElement, |
301 elementElement, | 302 elementElement, |
302 htmlDocumentElement, | 303 htmlDocumentElement, |
303 ElementFactory.classElement("InputElement", elementType), | 304 ElementFactory.classElement("InputElement", elementType), |
304 ElementFactory.classElement("SelectElement", elementType) | 305 ElementFactory.classElement("SelectElement", elementType) |
305 ]; | 306 ]; |
306 htmlUnit.functions = <FunctionElement>[ | 307 htmlUnit.functions = <FunctionElement>[ |
307 ElementFactory.functionElement3("query", elementElement, | 308 ElementFactory.functionElement3("query", elementElement, |
308 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST) | 309 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST) |
309 ]; | 310 ]; |
310 TopLevelVariableElementImpl document = | 311 TopLevelVariableElementImpl document = ElementFactory |
311 ElementFactory.topLevelVariableElement3( | 312 .topLevelVariableElement3( |
312 "document", false, true, htmlDocumentElement.type); | 313 "document", false, true, htmlDocumentElement.type); |
313 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document]; | 314 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document]; |
314 htmlUnit.accessors = <PropertyAccessorElement>[document.getter]; | 315 htmlUnit.accessors = <PropertyAccessorElement>[document.getter]; |
315 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode( | 316 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode( |
316 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"])); | 317 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"])); |
317 htmlLibrary.definingCompilationUnit = htmlUnit; | 318 htmlLibrary.definingCompilationUnit = htmlUnit; |
318 // | 319 // |
319 // dart:math | 320 // dart:math |
320 // | 321 // |
321 CompilationUnitElementImpl mathUnit = | 322 CompilationUnitElementImpl mathUnit = |
(...skipping 4778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5100 | 5101 |
5101 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { | 5102 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { |
5102 // class A {} | 5103 // class A {} |
5103 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5104 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5104 MemberMap mapA = | 5105 MemberMap mapA = |
5105 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5106 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5106 expect(mapA.size, _numOfMembersInObject); | 5107 expect(mapA.size, _numOfMembersInObject); |
5107 _assertNoErrors(classA); | 5108 _assertNoErrors(classA); |
5108 } | 5109 } |
5109 | 5110 |
5110 void | 5111 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_getter_method() { |
5111 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
getter_method() { | |
5112 // class I1 { int m(); } | 5112 // class I1 { int m(); } |
5113 // class I2 { int get m; } | 5113 // class I2 { int get m; } |
5114 // class A implements I2, I1 {} | 5114 // class A implements I2, I1 {} |
5115 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5115 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5116 String methodName = "m"; | 5116 String methodName = "m"; |
5117 MethodElement methodM = | 5117 MethodElement methodM = |
5118 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5118 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5119 classI1.methods = <MethodElement>[methodM]; | 5119 classI1.methods = <MethodElement>[methodM]; |
5120 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5120 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5121 PropertyAccessorElement getter = | 5121 PropertyAccessorElement getter = |
5122 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 5122 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
5123 classI2.accessors = <PropertyAccessorElement>[getter]; | 5123 classI2.accessors = <PropertyAccessorElement>[getter]; |
5124 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5124 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5125 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 5125 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
5126 MemberMap mapA = | 5126 MemberMap mapA = |
5127 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5127 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5128 expect(mapA.size, _numOfMembersInObject); | 5128 expect(mapA.size, _numOfMembersInObject); |
5129 expect(mapA.get(methodName), isNull); | 5129 expect(mapA.get(methodName), isNull); |
5130 _assertErrors(classA, | 5130 _assertErrors(classA, |
5131 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 5131 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
5132 } | 5132 } |
5133 | 5133 |
5134 void | 5134 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_int_str() { |
5135 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
int_str() { | |
5136 // class I1 { int m(); } | 5135 // class I1 { int m(); } |
5137 // class I2 { String m(); } | 5136 // class I2 { String m(); } |
5138 // class A implements I1, I2 {} | 5137 // class A implements I1, I2 {} |
5139 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5138 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5140 String methodName = "m"; | 5139 String methodName = "m"; |
5141 MethodElement methodM1 = | 5140 MethodElement methodM1 = |
5142 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 5141 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
5143 classI1.methods = <MethodElement>[methodM1]; | 5142 classI1.methods = <MethodElement>[methodM1]; |
5144 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5143 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5145 MethodElement methodM2 = ElementFactory | 5144 MethodElement methodM2 = ElementFactory.methodElement( |
5146 .methodElement(methodName, null, [_typeProvider.stringType]); | 5145 methodName, null, [_typeProvider.stringType]); |
5147 classI2.methods = <MethodElement>[methodM2]; | 5146 classI2.methods = <MethodElement>[methodM2]; |
5148 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5147 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5149 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5148 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5150 MemberMap mapA = | 5149 MemberMap mapA = |
5151 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5150 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5152 expect(mapA.size, _numOfMembersInObject); | 5151 expect(mapA.size, _numOfMembersInObject); |
5153 expect(mapA.get(methodName), isNull); | 5152 expect(mapA.get(methodName), isNull); |
5154 _assertErrors( | 5153 _assertErrors( |
5155 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 5154 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
5156 } | 5155 } |
5157 | 5156 |
5158 void | 5157 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_method_getter() { |
5159 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
method_getter() { | |
5160 // class I1 { int m(); } | 5158 // class I1 { int m(); } |
5161 // class I2 { int get m; } | 5159 // class I2 { int get m; } |
5162 // class A implements I1, I2 {} | 5160 // class A implements I1, I2 {} |
5163 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5161 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5164 String methodName = "m"; | 5162 String methodName = "m"; |
5165 MethodElement methodM = | 5163 MethodElement methodM = |
5166 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5164 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5167 classI1.methods = <MethodElement>[methodM]; | 5165 classI1.methods = <MethodElement>[methodM]; |
5168 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5166 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5169 PropertyAccessorElement getter = | 5167 PropertyAccessorElement getter = |
5170 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 5168 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
5171 classI2.accessors = <PropertyAccessorElement>[getter]; | 5169 classI2.accessors = <PropertyAccessorElement>[getter]; |
5172 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5170 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5173 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5171 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5174 MemberMap mapA = | 5172 MemberMap mapA = |
5175 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5173 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5176 expect(mapA.size, _numOfMembersInObject); | 5174 expect(mapA.size, _numOfMembersInObject); |
5177 expect(mapA.get(methodName), isNull); | 5175 expect(mapA.get(methodName), isNull); |
5178 _assertErrors(classA, | 5176 _assertErrors(classA, |
5179 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 5177 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
5180 } | 5178 } |
5181 | 5179 |
5182 void | 5180 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_numOfRequiredParams() { |
5183 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
numOfRequiredParams() { | |
5184 // class I1 { dynamic m(int, [int]); } | 5181 // class I1 { dynamic m(int, [int]); } |
5185 // class I2 { dynamic m(int, int, int); } | 5182 // class I2 { dynamic m(int, int, int); } |
5186 // class A implements I1, I2 {} | 5183 // class A implements I1, I2 {} |
5187 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5184 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5188 String methodName = "m"; | 5185 String methodName = "m"; |
5189 MethodElementImpl methodM1 = | 5186 MethodElementImpl methodM1 = |
5190 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 5187 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
5191 ParameterElementImpl parameter1 = | 5188 ParameterElementImpl parameter1 = |
5192 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 5189 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
5193 parameter1.type = _typeProvider.intType; | 5190 parameter1.type = _typeProvider.intType; |
(...skipping 28 matching lines...) Expand all Loading... |
5222 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5219 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5223 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5220 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5224 MemberMap mapA = | 5221 MemberMap mapA = |
5225 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5222 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5226 expect(mapA.size, _numOfMembersInObject); | 5223 expect(mapA.size, _numOfMembersInObject); |
5227 expect(mapA.get(methodName), isNull); | 5224 expect(mapA.get(methodName), isNull); |
5228 _assertErrors( | 5225 _assertErrors( |
5229 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 5226 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
5230 } | 5227 } |
5231 | 5228 |
5232 void | 5229 void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance
_str_int() { |
5233 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
str_int() { | |
5234 // class I1 { int m(); } | 5230 // class I1 { int m(); } |
5235 // class I2 { String m(); } | 5231 // class I2 { String m(); } |
5236 // class A implements I2, I1 {} | 5232 // class A implements I2, I1 {} |
5237 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5233 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5238 String methodName = "m"; | 5234 String methodName = "m"; |
5239 MethodElement methodM1 = ElementFactory | 5235 MethodElement methodM1 = ElementFactory.methodElement( |
5240 .methodElement(methodName, null, [_typeProvider.stringType]); | 5236 methodName, null, [_typeProvider.stringType]); |
5241 classI1.methods = <MethodElement>[methodM1]; | 5237 classI1.methods = <MethodElement>[methodM1]; |
5242 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5238 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5243 MethodElement methodM2 = | 5239 MethodElement methodM2 = |
5244 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 5240 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
5245 classI2.methods = <MethodElement>[methodM2]; | 5241 classI2.methods = <MethodElement>[methodM2]; |
5246 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5242 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5247 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 5243 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
5248 MemberMap mapA = | 5244 MemberMap mapA = |
5249 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5245 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5250 expect(mapA.size, _numOfMembersInObject); | 5246 expect(mapA.size, _numOfMembersInObject); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5332 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5328 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5333 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5329 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5334 MemberMap mapA = | 5330 MemberMap mapA = |
5335 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5331 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5336 expect(mapA.size, _numOfMembersInObject + 2); | 5332 expect(mapA.size, _numOfMembersInObject + 2); |
5337 expect(mapA.get(methodName1), same(methodM1)); | 5333 expect(mapA.get(methodName1), same(methodM1)); |
5338 expect(mapA.get(methodName2), same(methodM2)); | 5334 expect(mapA.get(methodName2), same(methodM2)); |
5339 _assertNoErrors(classA); | 5335 _assertNoErrors(classA); |
5340 } | 5336 } |
5341 | 5337 |
5342 void | 5338 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_gett
ers() { |
5343 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_gette
rs() { | |
5344 // class I1 { int get g; } | 5339 // class I1 { int get g; } |
5345 // class I2 { num get g; } | 5340 // class I2 { num get g; } |
5346 // class A implements I1, I2 {} | 5341 // class A implements I1, I2 {} |
5347 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5342 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5348 String accessorName = "g"; | 5343 String accessorName = "g"; |
5349 PropertyAccessorElement getter1 = ElementFactory.getterElement( | 5344 PropertyAccessorElement getter1 = ElementFactory.getterElement( |
5350 accessorName, false, _typeProvider.intType); | 5345 accessorName, false, _typeProvider.intType); |
5351 classI1.accessors = <PropertyAccessorElement>[getter1]; | 5346 classI1.accessors = <PropertyAccessorElement>[getter1]; |
5352 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5347 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5353 PropertyAccessorElement getter2 = ElementFactory.getterElement( | 5348 PropertyAccessorElement getter2 = ElementFactory.getterElement( |
5354 accessorName, false, _typeProvider.numType); | 5349 accessorName, false, _typeProvider.numType); |
5355 classI2.accessors = <PropertyAccessorElement>[getter2]; | 5350 classI2.accessors = <PropertyAccessorElement>[getter2]; |
5356 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5351 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5357 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5352 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5358 MemberMap mapA = | 5353 MemberMap mapA = |
5359 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5354 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5360 expect(mapA.size, _numOfMembersInObject + 1); | 5355 expect(mapA.size, _numOfMembersInObject + 1); |
5361 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 5356 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
5362 accessorName, false, _typeProvider.dynamicType); | 5357 accessorName, false, _typeProvider.dynamicType); |
5363 expect(mapA.get(accessorName).type, syntheticAccessor.type); | 5358 expect(mapA.get(accessorName).type, syntheticAccessor.type); |
5364 _assertNoErrors(classA); | 5359 _assertNoErrors(classA); |
5365 } | 5360 } |
5366 | 5361 |
5367 void | 5362 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_meth
ods() { |
5368 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_metho
ds() { | |
5369 // class I1 { dynamic m(int); } | 5363 // class I1 { dynamic m(int); } |
5370 // class I2 { dynamic m(num); } | 5364 // class I2 { dynamic m(num); } |
5371 // class A implements I1, I2 {} | 5365 // class A implements I1, I2 {} |
5372 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5366 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5373 String methodName = "m"; | 5367 String methodName = "m"; |
5374 MethodElementImpl methodM1 = | 5368 MethodElementImpl methodM1 = |
5375 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 5369 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
5376 ParameterElementImpl parameter1 = | 5370 ParameterElementImpl parameter1 = |
5377 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 5371 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
5378 parameter1.type = _typeProvider.intType; | 5372 parameter1.type = _typeProvider.intType; |
(...skipping 13 matching lines...) Expand all Loading... |
5392 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5386 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5393 MemberMap mapA = | 5387 MemberMap mapA = |
5394 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5388 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5395 expect(mapA.size, _numOfMembersInObject + 1); | 5389 expect(mapA.size, _numOfMembersInObject + 1); |
5396 MethodElement syntheticMethod = ElementFactory.methodElement( | 5390 MethodElement syntheticMethod = ElementFactory.methodElement( |
5397 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 5391 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
5398 expect(mapA.get(methodName).type, syntheticMethod.type); | 5392 expect(mapA.get(methodName).type, syntheticMethod.type); |
5399 _assertNoErrors(classA); | 5393 _assertNoErrors(classA); |
5400 } | 5394 } |
5401 | 5395 |
5402 void | 5396 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_sett
ers() { |
5403 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_sette
rs() { | |
5404 // class I1 { set s(int); } | 5397 // class I1 { set s(int); } |
5405 // class I2 { set s(num); } | 5398 // class I2 { set s(num); } |
5406 // class A implements I1, I2 {} | 5399 // class A implements I1, I2 {} |
5407 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5400 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5408 String accessorName = "s"; | 5401 String accessorName = "s"; |
5409 PropertyAccessorElement setter1 = ElementFactory.setterElement( | 5402 PropertyAccessorElement setter1 = ElementFactory.setterElement( |
5410 accessorName, false, _typeProvider.intType); | 5403 accessorName, false, _typeProvider.intType); |
5411 classI1.accessors = <PropertyAccessorElement>[setter1]; | 5404 classI1.accessors = <PropertyAccessorElement>[setter1]; |
5412 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5405 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5413 PropertyAccessorElement setter2 = ElementFactory.setterElement( | 5406 PropertyAccessorElement setter2 = ElementFactory.setterElement( |
5414 accessorName, false, _typeProvider.numType); | 5407 accessorName, false, _typeProvider.numType); |
5415 classI2.accessors = <PropertyAccessorElement>[setter2]; | 5408 classI2.accessors = <PropertyAccessorElement>[setter2]; |
5416 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5409 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5417 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5410 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5418 MemberMap mapA = | 5411 MemberMap mapA = |
5419 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5412 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5420 expect(mapA.size, _numOfMembersInObject + 1); | 5413 expect(mapA.size, _numOfMembersInObject + 1); |
5421 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 5414 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
5422 .setterElement(accessorName, false, _typeProvider.dynamicType); | 5415 .setterElement(accessorName, false, _typeProvider.dynamicType); |
5423 syntheticAccessor.returnType = _typeProvider.dynamicType; | 5416 syntheticAccessor.returnType = _typeProvider.dynamicType; |
5424 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); | 5417 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); |
5425 _assertNoErrors(classA); | 5418 _assertNoErrors(classA); |
5426 } | 5419 } |
5427 | 5420 |
5428 void | 5421 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_gett
ers() { |
5429 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_gette
rs() { | |
5430 // class A {} | 5422 // class A {} |
5431 // class B extends A {} | 5423 // class B extends A {} |
5432 // class C extends B {} | 5424 // class C extends B {} |
5433 // class I1 { A get g; } | 5425 // class I1 { A get g; } |
5434 // class I2 { B get g; } | 5426 // class I2 { B get g; } |
5435 // class I3 { C get g; } | 5427 // class I3 { C get g; } |
5436 // class D implements I1, I2, I3 {} | 5428 // class D implements I1, I2, I3 {} |
5437 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5429 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5438 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5430 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
5439 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5431 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
(...skipping 18 matching lines...) Expand all Loading... |
5458 ]; | 5450 ]; |
5459 MemberMap mapD = | 5451 MemberMap mapD = |
5460 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5452 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
5461 expect(mapD.size, _numOfMembersInObject + 1); | 5453 expect(mapD.size, _numOfMembersInObject + 1); |
5462 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 5454 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
5463 accessorName, false, _typeProvider.dynamicType); | 5455 accessorName, false, _typeProvider.dynamicType); |
5464 expect(mapD.get(accessorName).type, syntheticAccessor.type); | 5456 expect(mapD.get(accessorName).type, syntheticAccessor.type); |
5465 _assertNoErrors(classD); | 5457 _assertNoErrors(classD); |
5466 } | 5458 } |
5467 | 5459 |
5468 void | 5460 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_meth
ods() { |
5469 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_metho
ds() { | |
5470 // class A {} | 5461 // class A {} |
5471 // class B extends A {} | 5462 // class B extends A {} |
5472 // class C extends B {} | 5463 // class C extends B {} |
5473 // class I1 { dynamic m(A a); } | 5464 // class I1 { dynamic m(A a); } |
5474 // class I2 { dynamic m(B b); } | 5465 // class I2 { dynamic m(B b); } |
5475 // class I3 { dynamic m(C c); } | 5466 // class I3 { dynamic m(C c); } |
5476 // class D implements I1, I2, I3 {} | 5467 // class D implements I1, I2, I3 {} |
5477 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5468 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5478 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5469 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
5479 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5470 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5513 ]; | 5504 ]; |
5514 MemberMap mapD = | 5505 MemberMap mapD = |
5515 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5506 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
5516 expect(mapD.size, _numOfMembersInObject + 1); | 5507 expect(mapD.size, _numOfMembersInObject + 1); |
5517 MethodElement syntheticMethod = ElementFactory.methodElement( | 5508 MethodElement syntheticMethod = ElementFactory.methodElement( |
5518 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 5509 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
5519 expect(mapD.get(methodName).type, syntheticMethod.type); | 5510 expect(mapD.get(methodName).type, syntheticMethod.type); |
5520 _assertNoErrors(classD); | 5511 _assertNoErrors(classD); |
5521 } | 5512 } |
5522 | 5513 |
5523 void | 5514 void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_sett
ers() { |
5524 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_sette
rs() { | |
5525 // class A {} | 5515 // class A {} |
5526 // class B extends A {} | 5516 // class B extends A {} |
5527 // class C extends B {} | 5517 // class C extends B {} |
5528 // class I1 { set s(A); } | 5518 // class I1 { set s(A); } |
5529 // class I2 { set s(B); } | 5519 // class I2 { set s(B); } |
5530 // class I3 { set s(C); } | 5520 // class I3 { set s(C); } |
5531 // class D implements I1, I2, I3 {} | 5521 // class D implements I1, I2, I3 {} |
5532 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5522 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5533 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 5523 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
5534 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 5524 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
(...skipping 19 matching lines...) Expand all Loading... |
5554 MemberMap mapD = | 5544 MemberMap mapD = |
5555 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 5545 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
5556 expect(mapD.size, _numOfMembersInObject + 1); | 5546 expect(mapD.size, _numOfMembersInObject + 1); |
5557 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 5547 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
5558 .setterElement(accessorName, false, _typeProvider.dynamicType); | 5548 .setterElement(accessorName, false, _typeProvider.dynamicType); |
5559 syntheticAccessor.returnType = _typeProvider.dynamicType; | 5549 syntheticAccessor.returnType = _typeProvider.dynamicType; |
5560 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); | 5550 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); |
5561 _assertNoErrors(classD); | 5551 _assertNoErrors(classD); |
5562 } | 5552 } |
5563 | 5553 |
5564 void | 5554 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods()
{ |
5565 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() { | |
5566 // class I1 { int m(); } | 5555 // class I1 { int m(); } |
5567 // class I2 { int m([int]); } | 5556 // class I2 { int m([int]); } |
5568 // class A implements I1, I2 {} | 5557 // class A implements I1, I2 {} |
5569 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5558 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5570 String methodName = "m"; | 5559 String methodName = "m"; |
5571 MethodElement methodM1 = | 5560 MethodElement methodM1 = |
5572 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5561 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5573 classI1.methods = <MethodElement>[methodM1]; | 5562 classI1.methods = <MethodElement>[methodM1]; |
5574 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5563 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
5575 MethodElementImpl methodM2 = | 5564 MethodElementImpl methodM2 = |
5576 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5565 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5577 ParameterElementImpl parameter1 = | 5566 ParameterElementImpl parameter1 = |
5578 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 5567 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
5579 parameter1.type = _typeProvider.intType; | 5568 parameter1.type = _typeProvider.intType; |
5580 parameter1.parameterKind = ParameterKind.POSITIONAL; | 5569 parameter1.parameterKind = ParameterKind.POSITIONAL; |
5581 methodM2.parameters = <ParameterElement>[parameter1]; | 5570 methodM2.parameters = <ParameterElement>[parameter1]; |
5582 classI2.methods = <MethodElement>[methodM2]; | 5571 classI2.methods = <MethodElement>[methodM2]; |
5583 ClassElementImpl classA = ElementFactory.classElement2("A"); | 5572 ClassElementImpl classA = ElementFactory.classElement2("A"); |
5584 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 5573 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
5585 MemberMap mapA = | 5574 MemberMap mapA = |
5586 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5575 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5587 expect(mapA.size, _numOfMembersInObject + 1); | 5576 expect(mapA.size, _numOfMembersInObject + 1); |
5588 expect(mapA.get(methodName), same(methodM2)); | 5577 expect(mapA.get(methodName), same(methodM2)); |
5589 _assertNoErrors(classA); | 5578 _assertNoErrors(classA); |
5590 } | 5579 } |
5591 | 5580 |
5592 void | 5581 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods()
{ |
5593 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() { | |
5594 // class I1 { int m(); } | 5582 // class I1 { int m(); } |
5595 // class I2 { int m([int]); } | 5583 // class I2 { int m([int]); } |
5596 // class I3 { int m([int, int]); } | 5584 // class I3 { int m([int, int]); } |
5597 // class A implements I1, I2, I3 {} | 5585 // class A implements I1, I2, I3 {} |
5598 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5586 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5599 String methodName = "m"; | 5587 String methodName = "m"; |
5600 MethodElementImpl methodM1 = | 5588 MethodElementImpl methodM1 = |
5601 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5589 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5602 classI1.methods = <MethodElement>[methodM1]; | 5590 classI1.methods = <MethodElement>[methodM1]; |
5603 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 5591 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
(...skipping 24 matching lines...) Expand all Loading... |
5628 classI2.type, | 5616 classI2.type, |
5629 classI3.type | 5617 classI3.type |
5630 ]; | 5618 ]; |
5631 MemberMap mapA = | 5619 MemberMap mapA = |
5632 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 5620 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
5633 expect(mapA.size, _numOfMembersInObject + 1); | 5621 expect(mapA.size, _numOfMembersInObject + 1); |
5634 expect(mapA.get(methodName), same(methodM3)); | 5622 expect(mapA.get(methodName), same(methodM3)); |
5635 _assertNoErrors(classA); | 5623 _assertNoErrors(classA); |
5636 } | 5624 } |
5637 | 5625 |
5638 void | 5626 void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods()
{ |
5639 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() { | |
5640 // class I1 { int m(); } | 5627 // class I1 { int m(); } |
5641 // class I2 { int m(); } | 5628 // class I2 { int m(); } |
5642 // class I3 { int m([int]); } | 5629 // class I3 { int m([int]); } |
5643 // class I4 { int m([int, int]); } | 5630 // class I4 { int m([int, int]); } |
5644 // class A implements I1, I2, I3, I4 {} | 5631 // class A implements I1, I2, I3, I4 {} |
5645 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 5632 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
5646 String methodName = "m"; | 5633 String methodName = "m"; |
5647 MethodElement methodM1 = | 5634 MethodElement methodM1 = |
5648 ElementFactory.methodElement(methodName, _typeProvider.intType); | 5635 ElementFactory.methodElement(methodName, _typeProvider.intType); |
5649 classI1.methods = <MethodElement>[methodM1]; | 5636 classI1.methods = <MethodElement>[methodM1]; |
(...skipping 3681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9331 expect(classes, hasLength(1)); | 9318 expect(classes, hasLength(1)); |
9332 List<ElementAnnotation> annotations = classes[0].metadata; | 9319 List<ElementAnnotation> annotations = classes[0].metadata; |
9333 expect(annotations, hasLength(1)); | 9320 expect(annotations, hasLength(1)); |
9334 assertNoErrors(source); | 9321 assertNoErrors(source); |
9335 verify([source]); | 9322 verify([source]); |
9336 CompilationUnit unit = resolveCompilationUnit(source, library); | 9323 CompilationUnit unit = resolveCompilationUnit(source, library); |
9337 NodeList<CompilationUnitMember> declarations = unit.declarations; | 9324 NodeList<CompilationUnitMember> declarations = unit.declarations; |
9338 expect(declarations, hasLength(2)); | 9325 expect(declarations, hasLength(2)); |
9339 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) | 9326 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) |
9340 .variables | 9327 .variables |
9341 .variables[0] | 9328 .variables[0].name.staticElement; |
9342 .name | |
9343 .staticElement; | |
9344 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, | 9329 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, |
9345 PropertyInducingElement, expectedElement); | 9330 PropertyInducingElement, expectedElement); |
9346 expectedElement = (expectedElement as PropertyInducingElement).getter; | 9331 expectedElement = (expectedElement as PropertyInducingElement).getter; |
9347 Element actualElement = | 9332 Element actualElement = |
9348 (declarations[1] as ClassDeclaration).metadata[0].name.staticElement; | 9333 (declarations[1] as ClassDeclaration).metadata[0].name.staticElement; |
9349 expect(actualElement, same(expectedElement)); | 9334 expect(actualElement, same(expectedElement)); |
9350 } | 9335 } |
9351 | 9336 |
9352 void test_metadata_field() { | 9337 void test_metadata_field() { |
9353 Source source = addSource(r''' | 9338 Source source = addSource(r''' |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9524 expect(aliases, hasLength(1)); | 9509 expect(aliases, hasLength(1)); |
9525 List<ElementAnnotation> annotations = aliases[0].metadata; | 9510 List<ElementAnnotation> annotations = aliases[0].metadata; |
9526 expect(annotations, hasLength(1)); | 9511 expect(annotations, hasLength(1)); |
9527 assertNoErrors(source); | 9512 assertNoErrors(source); |
9528 verify([source]); | 9513 verify([source]); |
9529 CompilationUnit unit = resolveCompilationUnit(source, library); | 9514 CompilationUnit unit = resolveCompilationUnit(source, library); |
9530 NodeList<CompilationUnitMember> declarations = unit.declarations; | 9515 NodeList<CompilationUnitMember> declarations = unit.declarations; |
9531 expect(declarations, hasLength(2)); | 9516 expect(declarations, hasLength(2)); |
9532 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) | 9517 Element expectedElement = (declarations[0] as TopLevelVariableDeclaration) |
9533 .variables | 9518 .variables |
9534 .variables[0] | 9519 .variables[0].name.staticElement; |
9535 .name | |
9536 .staticElement; | |
9537 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, | 9520 EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, |
9538 PropertyInducingElement, expectedElement); | 9521 PropertyInducingElement, expectedElement); |
9539 expectedElement = (expectedElement as PropertyInducingElement).getter; | 9522 expectedElement = (expectedElement as PropertyInducingElement).getter; |
9540 Element actualElement = | 9523 Element actualElement = |
9541 (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement; | 9524 (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement; |
9542 expect(actualElement, same(expectedElement)); | 9525 expect(actualElement, same(expectedElement)); |
9543 } | 9526 } |
9544 | 9527 |
9545 void test_method_fromMixin() { | 9528 void test_method_fromMixin() { |
9546 Source source = addSource(r''' | 9529 Source source = addSource(r''' |
(...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11749 } | 11732 } |
11750 | 11733 |
11751 /** | 11734 /** |
11752 * Strong mode static analyzer downwards inference tests | 11735 * Strong mode static analyzer downwards inference tests |
11753 */ | 11736 */ |
11754 @reflectiveTest | 11737 @reflectiveTest |
11755 class StrongModeDownwardsInferenceTest extends ResolverTestCase { | 11738 class StrongModeDownwardsInferenceTest extends ResolverTestCase { |
11756 TypeAssertions _assertions; | 11739 TypeAssertions _assertions; |
11757 AsserterBuilder<Element, DartType> _hasElement; | 11740 AsserterBuilder<Element, DartType> _hasElement; |
11758 AsserterBuilder<DartType, DartType> _isType; | 11741 AsserterBuilder<DartType, DartType> _isType; |
11759 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, DartType> | 11742 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, |
11760 _isFunction2Of; | 11743 DartType> _isFunction2Of; |
11761 AsserterBuilderBuilder<Asserter<DartType>, List<Asserter<DartType>>, DartType> | 11744 AsserterBuilderBuilder<Asserter<DartType>, List<Asserter<DartType>>, |
11762 _isInstantiationOf; | 11745 DartType> _isInstantiationOf; |
11763 Asserter<DartType> _isInt; | 11746 Asserter<DartType> _isInt; |
11764 Asserter<DartType> _isNum; | 11747 Asserter<DartType> _isNum; |
11765 Asserter<DartType> _isString; | 11748 Asserter<DartType> _isString; |
11766 Asserter<DartType> _isDynamic; | 11749 Asserter<DartType> _isDynamic; |
11767 AsserterBuilder<Asserter<DartType>, InterfaceType> _isListOf; | 11750 AsserterBuilder<Asserter<DartType>, InterfaceType> _isListOf; |
11768 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, InterfaceType> | 11751 AsserterBuilder2<Asserter<DartType>, Asserter<DartType>, |
11769 _isMapOf; | 11752 InterfaceType> _isMapOf; |
11770 | 11753 |
11771 @override | 11754 @override |
11772 void setUp() { | 11755 void setUp() { |
11773 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 11756 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
11774 options.strongMode = true; | 11757 options.strongMode = true; |
11775 resetWithOptions(options); | 11758 resetWithOptions(options); |
11776 _assertions = new TypeAssertions(typeProvider); | 11759 _assertions = new TypeAssertions(typeProvider); |
11777 _isType = _assertions.isType; | 11760 _isType = _assertions.isType; |
11778 _hasElement = _assertions.hasElement; | 11761 _hasElement = _assertions.hasElement; |
11779 _isInstantiationOf = _assertions.isInstantiationOf; | 11762 _isInstantiationOf = _assertions.isInstantiationOf; |
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13990 import 'lib.dart'; | 13973 import 'lib.dart'; |
13991 class B extends A { | 13974 class B extends A { |
13992 m() { | 13975 m() { |
13993 return v; // marker | 13976 return v; // marker |
13994 } | 13977 } |
13995 }'''; | 13978 }'''; |
13996 _assertTypeOfMarkedExpression( | 13979 _assertTypeOfMarkedExpression( |
13997 code, typeProvider.dynamicType, typeProvider.intType); | 13980 code, typeProvider.dynamicType, typeProvider.intType); |
13998 } | 13981 } |
13999 | 13982 |
14000 void | 13983 void test_finalPropertyInducingVariable_classMember_instance_propagatedTarget(
) { |
14001 test_finalPropertyInducingVariable_classMember_instance_propagatedTarget()
{ | |
14002 addNamedSource( | 13984 addNamedSource( |
14003 "/lib.dart", | 13985 "/lib.dart", |
14004 r''' | 13986 r''' |
14005 class A { | 13987 class A { |
14006 final v = 0; | 13988 final v = 0; |
14007 }'''); | 13989 }'''); |
14008 String code = r''' | 13990 String code = r''' |
14009 import 'lib.dart'; | 13991 import 'lib.dart'; |
14010 f(p) { | 13992 f(p) { |
14011 if (p is A) { | 13993 if (p is A) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14210 FormalParameter kParameter = EngineTestCase.findNode( | 14192 FormalParameter kParameter = EngineTestCase.findNode( |
14211 unit, code, "k, ", (node) => node is SimpleFormalParameter); | 14193 unit, code, "k, ", (node) => node is SimpleFormalParameter); |
14212 expect(kParameter.identifier.propagatedType, same(intType)); | 14194 expect(kParameter.identifier.propagatedType, same(intType)); |
14213 // v | 14195 // v |
14214 DartType stringType = typeProvider.stringType; | 14196 DartType stringType = typeProvider.stringType; |
14215 FormalParameter vParameter = EngineTestCase.findNode( | 14197 FormalParameter vParameter = EngineTestCase.findNode( |
14216 unit, code, "v)", (node) => node is SimpleFormalParameter); | 14198 unit, code, "v)", (node) => node is SimpleFormalParameter); |
14217 expect(vParameter.identifier.propagatedType, same(stringType)); | 14199 expect(vParameter.identifier.propagatedType, same(stringType)); |
14218 } | 14200 } |
14219 | 14201 |
14220 void | 14202 void test_functionExpression_asInvocationArgument_functionExpressionInvocation
() { |
14221 test_functionExpression_asInvocationArgument_functionExpressionInvocation(
) { | |
14222 String code = r''' | 14203 String code = r''' |
14223 main() { | 14204 main() { |
14224 (f(String value)) {} ((v) { | 14205 (f(String value)) {} ((v) { |
14225 v; | 14206 v; |
14226 }); | 14207 }); |
14227 }'''; | 14208 }'''; |
14228 Source source = addSource(code); | 14209 Source source = addSource(code); |
14229 LibraryElement library = resolve2(source); | 14210 LibraryElement library = resolve2(source); |
14230 assertNoErrors(source); | 14211 assertNoErrors(source); |
14231 verify([source]); | 14212 verify([source]); |
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16089 | 16070 |
16090 void _resolveTestUnit(String code) { | 16071 void _resolveTestUnit(String code) { |
16091 testCode = code; | 16072 testCode = code; |
16092 testSource = addSource(testCode); | 16073 testSource = addSource(testCode); |
16093 LibraryElement library = resolve2(testSource); | 16074 LibraryElement library = resolve2(testSource); |
16094 assertNoErrors(testSource); | 16075 assertNoErrors(testSource); |
16095 verify([testSource]); | 16076 verify([testSource]); |
16096 testUnit = resolveCompilationUnit(testSource, library); | 16077 testUnit = resolveCompilationUnit(testSource, library); |
16097 } | 16078 } |
16098 } | 16079 } |
OLD | NEW |