| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.inheritance_manager_test; | 5 library analyzer.test.generated.inheritance_manager_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 _numOfMembersInObject = | 59 _numOfMembersInObject = |
| 60 objectType.methods.length + objectType.accessors.length; | 60 objectType.methods.length + objectType.accessors.length; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void test_getMapOfMembersInheritedFromClasses_accessor_extends() { | 63 void test_getMapOfMembersInheritedFromClasses_accessor_extends() { |
| 64 // class A { int get g; } | 64 // class A { int get g; } |
| 65 // class B extends A {} | 65 // class B extends A {} |
| 66 ClassElementImpl classA = ElementFactory.classElement2("A"); | 66 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 67 String getterName = "g"; | 67 String getterName = "g"; |
| 68 PropertyAccessorElement getterG = | 68 PropertyAccessorElement getterG = |
| 69 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 69 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 70 classA.accessors = <PropertyAccessorElement>[getterG]; | 70 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 71 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 71 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 72 MemberMap mapB = | 72 MemberMap mapB = |
| 73 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 73 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 74 MemberMap mapA = | 74 MemberMap mapA = |
| 75 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 75 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 76 expect(mapA.size, _numOfMembersInObject); | 76 expect(mapA.size, _numOfMembersInObject); |
| 77 expect(mapB.size, _numOfMembersInObject + 1); | 77 expect(mapB.size, _numOfMembersInObject + 1); |
| 78 expect(mapB.get(getterName), same(getterG)); | 78 expect(mapB.get(getterName), same(getterG)); |
| 79 _assertNoErrors(classA); | 79 _assertNoErrors(classA); |
| 80 _assertNoErrors(classB); | 80 _assertNoErrors(classB); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void test_getMapOfMembersInheritedFromClasses_accessor_implements() { | 83 void test_getMapOfMembersInheritedFromClasses_accessor_implements() { |
| 84 // class A { int get g; } | 84 // class A { int get g; } |
| 85 // class B implements A {} | 85 // class B implements A {} |
| 86 ClassElementImpl classA = ElementFactory.classElement2("A"); | 86 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 87 String getterName = "g"; | 87 String getterName = "g"; |
| 88 PropertyAccessorElement getterG = | 88 PropertyAccessorElement getterG = |
| 89 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 89 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 90 classA.accessors = <PropertyAccessorElement>[getterG]; | 90 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 91 ClassElementImpl classB = ElementFactory.classElement2("B"); | 91 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 92 classB.interfaces = <InterfaceType>[classA.type]; | 92 classB.interfaces = <InterfaceType>[classA.type]; |
| 93 MemberMap mapB = | 93 MemberMap mapB = |
| 94 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 94 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 95 MemberMap mapA = | 95 MemberMap mapA = |
| 96 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 96 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 97 expect(mapA.size, _numOfMembersInObject); | 97 expect(mapA.size, _numOfMembersInObject); |
| 98 expect(mapB.size, _numOfMembersInObject); | 98 expect(mapB.size, _numOfMembersInObject); |
| 99 expect(mapB.get(getterName), isNull); | 99 expect(mapB.get(getterName), isNull); |
| 100 _assertNoErrors(classA); | 100 _assertNoErrors(classA); |
| 101 _assertNoErrors(classB); | 101 _assertNoErrors(classB); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void test_getMapOfMembersInheritedFromClasses_accessor_with() { | 104 void test_getMapOfMembersInheritedFromClasses_accessor_with() { |
| 105 // class A { int get g; } | 105 // class A { int get g; } |
| 106 // class B extends Object with A {} | 106 // class B extends Object with A {} |
| 107 ClassElementImpl classA = ElementFactory.classElement2("A"); | 107 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 108 String getterName = "g"; | 108 String getterName = "g"; |
| 109 PropertyAccessorElement getterG = | 109 PropertyAccessorElement getterG = |
| 110 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 110 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 111 classA.accessors = <PropertyAccessorElement>[getterG]; | 111 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 112 ClassElementImpl classB = ElementFactory.classElement2("B"); | 112 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 113 classB.mixins = <InterfaceType>[classA.type]; | 113 classB.mixins = <InterfaceType>[classA.type]; |
| 114 MemberMap mapB = | 114 MemberMap mapB = |
| 115 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 115 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 116 MemberMap mapA = | 116 MemberMap mapA = |
| 117 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 117 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 118 expect(mapA.size, _numOfMembersInObject); | 118 expect(mapA.size, _numOfMembersInObject); |
| 119 expect(mapB.size, _numOfMembersInObject + 1); | 119 expect(mapB.size, _numOfMembersInObject + 1); |
| 120 expect(mapB.get(getterName), same(getterG)); | 120 expect(mapB.get(getterName), same(getterG)); |
| 121 _assertNoErrors(classA); | 121 _assertNoErrors(classA); |
| 122 _assertNoErrors(classB); | 122 _assertNoErrors(classB); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void test_getMapOfMembersInheritedFromClasses_implicitExtends() { | 125 void test_getMapOfMembersInheritedFromClasses_implicitExtends() { |
| 126 // class A {} | 126 // class A {} |
| 127 ClassElementImpl classA = ElementFactory.classElement2("A"); | 127 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 128 MemberMap mapA = | 128 MemberMap mapA = |
| 129 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 129 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 130 expect(mapA.size, _numOfMembersInObject); | 130 expect(mapA.size, _numOfMembersInObject); |
| 131 _assertNoErrors(classA); | 131 _assertNoErrors(classA); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void test_getMapOfMembersInheritedFromClasses_method_extends() { | 134 void test_getMapOfMembersInheritedFromClasses_method_extends() { |
| 135 // class A { int g(); } | 135 // class A { int g(); } |
| 136 // class B extends A {} | 136 // class B extends A {} |
| 137 ClassElementImpl classA = ElementFactory.classElement2("A"); | 137 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 138 String methodName = "m"; | 138 String methodName = "m"; |
| 139 MethodElement methodM = | 139 MethodElement methodM = |
| 140 ElementFactory.methodElement(methodName, _typeProvider.intType); | 140 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 141 classA.methods = <MethodElement>[methodM]; | 141 classA.methods = <MethodElement>[methodM]; |
| 142 ClassElementImpl classB = ElementFactory.classElement2("B"); | 142 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 143 classB.supertype = classA.type; | 143 classB.supertype = classA.type; |
| 144 MemberMap mapB = | 144 MemberMap mapB = |
| 145 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 145 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 146 MemberMap mapA = | 146 MemberMap mapA = |
| 147 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 147 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 148 expect(mapA.size, _numOfMembersInObject); | 148 expect(mapA.size, _numOfMembersInObject); |
| 149 expect(mapB.size, _numOfMembersInObject + 1); | 149 expect(mapB.size, _numOfMembersInObject + 1); |
| 150 expect(mapB.get(methodName), same(methodM)); | 150 expect(mapB.get(methodName), same(methodM)); |
| 151 _assertNoErrors(classA); | 151 _assertNoErrors(classA); |
| 152 _assertNoErrors(classB); | 152 _assertNoErrors(classB); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void test_getMapOfMembersInheritedFromClasses_method_implements() { | 155 void test_getMapOfMembersInheritedFromClasses_method_implements() { |
| 156 // class A { int g(); } | 156 // class A { int g(); } |
| 157 // class B implements A {} | 157 // class B implements A {} |
| 158 ClassElementImpl classA = ElementFactory.classElement2("A"); | 158 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 159 String methodName = "m"; | 159 String methodName = "m"; |
| 160 MethodElement methodM = | 160 MethodElement methodM = |
| 161 ElementFactory.methodElement(methodName, _typeProvider.intType); | 161 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 162 classA.methods = <MethodElement>[methodM]; | 162 classA.methods = <MethodElement>[methodM]; |
| 163 ClassElementImpl classB = ElementFactory.classElement2("B"); | 163 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 164 classB.interfaces = <InterfaceType>[classA.type]; | 164 classB.interfaces = <InterfaceType>[classA.type]; |
| 165 MemberMap mapB = | 165 MemberMap mapB = |
| 166 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 166 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 167 MemberMap mapA = | 167 MemberMap mapA = |
| 168 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 168 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 169 expect(mapA.size, _numOfMembersInObject); | 169 expect(mapA.size, _numOfMembersInObject); |
| 170 expect(mapB.size, _numOfMembersInObject); | 170 expect(mapB.size, _numOfMembersInObject); |
| 171 expect(mapB.get(methodName), isNull); | 171 expect(mapB.get(methodName), isNull); |
| 172 _assertNoErrors(classA); | 172 _assertNoErrors(classA); |
| 173 _assertNoErrors(classB); | 173 _assertNoErrors(classB); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void test_getMapOfMembersInheritedFromClasses_method_with() { | 176 void test_getMapOfMembersInheritedFromClasses_method_with() { |
| 177 // class A { int g(); } | 177 // class A { int g(); } |
| 178 // class B extends Object with A {} | 178 // class B extends Object with A {} |
| 179 ClassElementImpl classA = ElementFactory.classElement2("A"); | 179 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 180 String methodName = "m"; | 180 String methodName = "m"; |
| 181 MethodElement methodM = | 181 MethodElement methodM = |
| 182 ElementFactory.methodElement(methodName, _typeProvider.intType); | 182 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 183 classA.methods = <MethodElement>[methodM]; | 183 classA.methods = <MethodElement>[methodM]; |
| 184 ClassElementImpl classB = ElementFactory.classElement2("B"); | 184 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 185 classB.mixins = <InterfaceType>[classA.type]; | 185 classB.mixins = <InterfaceType>[classA.type]; |
| 186 MemberMap mapB = | 186 MemberMap mapB = |
| 187 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 187 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 188 MemberMap mapA = | 188 MemberMap mapA = |
| 189 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); | 189 _inheritanceManager.getMapOfMembersInheritedFromClasses(classA); |
| 190 expect(mapA.size, _numOfMembersInObject); | 190 expect(mapA.size, _numOfMembersInObject); |
| 191 expect(mapB.size, _numOfMembersInObject + 1); | 191 expect(mapB.size, _numOfMembersInObject + 1); |
| 192 expect(mapB.get(methodName), same(methodM)); | 192 expect(mapB.get(methodName), same(methodM)); |
| 193 _assertNoErrors(classA); | 193 _assertNoErrors(classA); |
| 194 _assertNoErrors(classB); | 194 _assertNoErrors(classB); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void test_getMapOfMembersInheritedFromClasses_method_with_two_mixins() { | 197 void test_getMapOfMembersInheritedFromClasses_method_with_two_mixins() { |
| 198 // class A1 { int m(); } | 198 // class A1 { int m(); } |
| 199 // class A2 { int m(); } | 199 // class A2 { int m(); } |
| 200 // class B extends Object with A1, A2 {} | 200 // class B extends Object with A1, A2 {} |
| 201 ClassElementImpl classA1 = ElementFactory.classElement2("A1"); | 201 ClassElementImpl classA1 = ElementFactory.classElement2("A1"); |
| 202 String methodName = "m"; | 202 String methodName = "m"; |
| 203 MethodElement methodA1M = | 203 MethodElement methodA1M = |
| 204 ElementFactory.methodElement(methodName, _typeProvider.intType); | 204 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 205 classA1.methods = <MethodElement>[methodA1M]; | 205 classA1.methods = <MethodElement>[methodA1M]; |
| 206 ClassElementImpl classA2 = ElementFactory.classElement2("A2"); | 206 ClassElementImpl classA2 = ElementFactory.classElement2("A2"); |
| 207 MethodElement methodA2M = | 207 MethodElement methodA2M = |
| 208 ElementFactory.methodElement(methodName, _typeProvider.intType); | 208 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 209 classA2.methods = <MethodElement>[methodA2M]; | 209 classA2.methods = <MethodElement>[methodA2M]; |
| 210 ClassElementImpl classB = ElementFactory.classElement2("B"); | 210 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 211 classB.mixins = <InterfaceType>[classA1.type, classA2.type]; | 211 classB.mixins = <InterfaceType>[classA1.type, classA2.type]; |
| 212 MemberMap mapB = | 212 MemberMap mapB = |
| 213 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); | 213 _inheritanceManager.getMapOfMembersInheritedFromClasses(classB); |
| 214 expect(mapB.get(methodName), same(methodA2M)); | 214 expect(mapB.get(methodName), same(methodA2M)); |
| 215 _assertNoErrors(classA1); | 215 _assertNoErrors(classA1); |
| 216 _assertNoErrors(classA2); | 216 _assertNoErrors(classA2); |
| 217 _assertNoErrors(classB); | 217 _assertNoErrors(classB); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void test_getMapOfMembersInheritedFromInterfaces_accessor_extends() { | 220 void test_getMapOfMembersInheritedFromInterfaces_accessor_extends() { |
| 221 // class A { int get g; } | 221 // class A { int get g; } |
| 222 // class B extends A {} | 222 // class B extends A {} |
| 223 ClassElementImpl classA = ElementFactory.classElement2("A"); | 223 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 224 String getterName = "g"; | 224 String getterName = "g"; |
| 225 PropertyAccessorElement getterG = | 225 PropertyAccessorElement getterG = |
| 226 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 226 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 227 classA.accessors = <PropertyAccessorElement>[getterG]; | 227 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 228 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 228 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 229 MemberMap mapB = | 229 MemberMap mapB = |
| 230 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 230 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 231 MemberMap mapA = | 231 MemberMap mapA = |
| 232 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 232 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 233 expect(mapA.size, _numOfMembersInObject); | 233 expect(mapA.size, _numOfMembersInObject); |
| 234 expect(mapB.size, _numOfMembersInObject + 1); | 234 expect(mapB.size, _numOfMembersInObject + 1); |
| 235 expect(mapB.get(getterName), same(getterG)); | 235 expect(mapB.get(getterName), same(getterG)); |
| 236 _assertNoErrors(classA); | 236 _assertNoErrors(classA); |
| 237 _assertNoErrors(classB); | 237 _assertNoErrors(classB); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void test_getMapOfMembersInheritedFromInterfaces_accessor_implements() { | 240 void test_getMapOfMembersInheritedFromInterfaces_accessor_implements() { |
| 241 // class A { int get g; } | 241 // class A { int get g; } |
| 242 // class B implements A {} | 242 // class B implements A {} |
| 243 ClassElementImpl classA = ElementFactory.classElement2("A"); | 243 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 244 String getterName = "g"; | 244 String getterName = "g"; |
| 245 PropertyAccessorElement getterG = | 245 PropertyAccessorElement getterG = |
| 246 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 246 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 247 classA.accessors = <PropertyAccessorElement>[getterG]; | 247 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 248 ClassElementImpl classB = ElementFactory.classElement2("B"); | 248 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 249 classB.interfaces = <InterfaceType>[classA.type]; | 249 classB.interfaces = <InterfaceType>[classA.type]; |
| 250 MemberMap mapB = | 250 MemberMap mapB = |
| 251 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 251 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 252 MemberMap mapA = | 252 MemberMap mapA = |
| 253 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 253 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 254 expect(mapA.size, _numOfMembersInObject); | 254 expect(mapA.size, _numOfMembersInObject); |
| 255 expect(mapB.size, _numOfMembersInObject + 1); | 255 expect(mapB.size, _numOfMembersInObject + 1); |
| 256 expect(mapB.get(getterName), same(getterG)); | 256 expect(mapB.get(getterName), same(getterG)); |
| 257 _assertNoErrors(classA); | 257 _assertNoErrors(classA); |
| 258 _assertNoErrors(classB); | 258 _assertNoErrors(classB); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void test_getMapOfMembersInheritedFromInterfaces_accessor_with() { | 261 void test_getMapOfMembersInheritedFromInterfaces_accessor_with() { |
| 262 // class A { int get g; } | 262 // class A { int get g; } |
| 263 // class B extends Object with A {} | 263 // class B extends Object with A {} |
| 264 ClassElementImpl classA = ElementFactory.classElement2("A"); | 264 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 265 String getterName = "g"; | 265 String getterName = "g"; |
| 266 PropertyAccessorElement getterG = | 266 PropertyAccessorElement getterG = |
| 267 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 267 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 268 classA.accessors = <PropertyAccessorElement>[getterG]; | 268 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 269 ClassElementImpl classB = ElementFactory.classElement2("B"); | 269 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 270 classB.mixins = <InterfaceType>[classA.type]; | 270 classB.mixins = <InterfaceType>[classA.type]; |
| 271 MemberMap mapB = | 271 MemberMap mapB = |
| 272 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 272 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 273 MemberMap mapA = | 273 MemberMap mapA = |
| 274 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 274 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 275 expect(mapA.size, _numOfMembersInObject); | 275 expect(mapA.size, _numOfMembersInObject); |
| 276 expect(mapB.size, _numOfMembersInObject + 1); | 276 expect(mapB.size, _numOfMembersInObject + 1); |
| 277 expect(mapB.get(getterName), same(getterG)); | 277 expect(mapB.get(getterName), same(getterG)); |
| 278 _assertNoErrors(classA); | 278 _assertNoErrors(classA); |
| 279 _assertNoErrors(classB); | 279 _assertNoErrors(classB); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { | 282 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { |
| 283 // class A {} | 283 // class A {} |
| 284 ClassElementImpl classA = ElementFactory.classElement2("A"); | 284 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 285 MemberMap mapA = | 285 MemberMap mapA = |
| 286 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 286 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 287 expect(mapA.size, _numOfMembersInObject); | 287 expect(mapA.size, _numOfMembersInObject); |
| 288 _assertNoErrors(classA); | 288 _assertNoErrors(classA); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void | 291 void |
| 292 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_gett
er_method() { | 292 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
getter_method() { |
| 293 // class I1 { int m(); } | 293 // class I1 { int m(); } |
| 294 // class I2 { int get m; } | 294 // class I2 { int get m; } |
| 295 // class A implements I2, I1 {} | 295 // class A implements I2, I1 {} |
| 296 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 296 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 297 String methodName = "m"; | 297 String methodName = "m"; |
| 298 MethodElement methodM = | 298 MethodElement methodM = |
| 299 ElementFactory.methodElement(methodName, _typeProvider.intType); | 299 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 300 classI1.methods = <MethodElement>[methodM]; | 300 classI1.methods = <MethodElement>[methodM]; |
| 301 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 301 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 302 PropertyAccessorElement getter = | 302 PropertyAccessorElement getter = |
| 303 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 303 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
| 304 classI2.accessors = <PropertyAccessorElement>[getter]; | 304 classI2.accessors = <PropertyAccessorElement>[getter]; |
| 305 ClassElementImpl classA = ElementFactory.classElement2("A"); | 305 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 306 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 306 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
| 307 MemberMap mapA = | 307 MemberMap mapA = |
| 308 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 308 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 309 expect(mapA.size, _numOfMembersInObject); | 309 expect(mapA.size, _numOfMembersInObject); |
| 310 expect(mapA.get(methodName), isNull); | 310 expect(mapA.get(methodName), isNull); |
| 311 _assertErrors(classA, | 311 _assertErrors(classA, |
| 312 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 312 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void | 315 void |
| 316 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_int_
str() { | 316 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
int_str() { |
| 317 // class I1 { int m(); } | 317 // class I1 { int m(); } |
| 318 // class I2 { String m(); } | 318 // class I2 { String m(); } |
| 319 // class A implements I1, I2 {} | 319 // class A implements I1, I2 {} |
| 320 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 320 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 321 String methodName = "m"; | 321 String methodName = "m"; |
| 322 MethodElement methodM1 = | 322 MethodElement methodM1 = |
| 323 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 323 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
| 324 classI1.methods = <MethodElement>[methodM1]; | 324 classI1.methods = <MethodElement>[methodM1]; |
| 325 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 325 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 326 MethodElement methodM2 = ElementFactory | 326 MethodElement methodM2 = ElementFactory |
| 327 .methodElement(methodName, null, [_typeProvider.stringType]); | 327 .methodElement(methodName, null, [_typeProvider.stringType]); |
| 328 classI2.methods = <MethodElement>[methodM2]; | 328 classI2.methods = <MethodElement>[methodM2]; |
| 329 ClassElementImpl classA = ElementFactory.classElement2("A"); | 329 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 330 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 330 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 331 MemberMap mapA = | 331 MemberMap mapA = |
| 332 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 332 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 333 expect(mapA.size, _numOfMembersInObject); | 333 expect(mapA.size, _numOfMembersInObject); |
| 334 expect(mapA.get(methodName), isNull); | 334 expect(mapA.get(methodName), isNull); |
| 335 _assertErrors( | 335 _assertErrors( |
| 336 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 336 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void | 339 void |
| 340 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_meth
od_getter() { | 340 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
method_getter() { |
| 341 // class I1 { int m(); } | 341 // class I1 { int m(); } |
| 342 // class I2 { int get m; } | 342 // class I2 { int get m; } |
| 343 // class A implements I1, I2 {} | 343 // class A implements I1, I2 {} |
| 344 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 344 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 345 String methodName = "m"; | 345 String methodName = "m"; |
| 346 MethodElement methodM = | 346 MethodElement methodM = |
| 347 ElementFactory.methodElement(methodName, _typeProvider.intType); | 347 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 348 classI1.methods = <MethodElement>[methodM]; | 348 classI1.methods = <MethodElement>[methodM]; |
| 349 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 349 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 350 PropertyAccessorElement getter = | 350 PropertyAccessorElement getter = |
| 351 ElementFactory.getterElement(methodName, false, _typeProvider.intType); | 351 ElementFactory.getterElement(methodName, false, _typeProvider.intType); |
| 352 classI2.accessors = <PropertyAccessorElement>[getter]; | 352 classI2.accessors = <PropertyAccessorElement>[getter]; |
| 353 ClassElementImpl classA = ElementFactory.classElement2("A"); | 353 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 354 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 354 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 355 MemberMap mapA = | 355 MemberMap mapA = |
| 356 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 356 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 357 expect(mapA.size, _numOfMembersInObject); | 357 expect(mapA.size, _numOfMembersInObject); |
| 358 expect(mapA.get(methodName), isNull); | 358 expect(mapA.get(methodName), isNull); |
| 359 _assertErrors(classA, | 359 _assertErrors(classA, |
| 360 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); | 360 [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void | 363 void |
| 364 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_numO
fRequiredParams() { | 364 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
numOfRequiredParams() { |
| 365 // class I1 { dynamic m(int, [int]); } | 365 // class I1 { dynamic m(int, [int]); } |
| 366 // class I2 { dynamic m(int, int, int); } | 366 // class I2 { dynamic m(int, int, int); } |
| 367 // class A implements I1, I2 {} | 367 // class A implements I1, I2 {} |
| 368 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 368 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 369 String methodName = "m"; | 369 String methodName = "m"; |
| 370 MethodElementImpl methodM1 = | 370 MethodElementImpl methodM1 = |
| 371 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 371 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 372 ParameterElementImpl parameter1 = | 372 ParameterElementImpl parameter1 = |
| 373 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 373 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 374 parameter1.type = _typeProvider.intType; | 374 parameter1.type = _typeProvider.intType; |
| 375 parameter1.parameterKind = ParameterKind.REQUIRED; | 375 parameter1.parameterKind = ParameterKind.REQUIRED; |
| 376 ParameterElementImpl parameter2 = | 376 ParameterElementImpl parameter2 = |
| 377 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); | 377 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); |
| 378 parameter2.type = _typeProvider.intType; | 378 parameter2.type = _typeProvider.intType; |
| 379 parameter2.parameterKind = ParameterKind.POSITIONAL; | 379 parameter2.parameterKind = ParameterKind.POSITIONAL; |
| 380 methodM1.parameters = <ParameterElement>[parameter1, parameter2]; | 380 methodM1.parameters = <ParameterElement>[parameter1, parameter2]; |
| 381 classI1.methods = <MethodElement>[methodM1]; | 381 classI1.methods = <MethodElement>[methodM1]; |
| 382 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 382 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 383 MethodElementImpl methodM2 = | 383 MethodElementImpl methodM2 = |
| 384 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 384 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 385 ParameterElementImpl parameter3 = | 385 ParameterElementImpl parameter3 = |
| 386 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); | 386 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); |
| 387 parameter3.type = _typeProvider.intType; | 387 parameter3.type = _typeProvider.intType; |
| 388 parameter3.parameterKind = ParameterKind.REQUIRED; | 388 parameter3.parameterKind = ParameterKind.REQUIRED; |
| 389 ParameterElementImpl parameter4 = | 389 ParameterElementImpl parameter4 = |
| 390 new ParameterElementImpl.forNode(AstFactory.identifier3("a4")); | 390 new ParameterElementImpl.forNode(AstFactory.identifier3("a4")); |
| 391 parameter4.type = _typeProvider.intType; | 391 parameter4.type = _typeProvider.intType; |
| 392 parameter4.parameterKind = ParameterKind.REQUIRED; | 392 parameter4.parameterKind = ParameterKind.REQUIRED; |
| 393 ParameterElementImpl parameter5 = | 393 ParameterElementImpl parameter5 = |
| 394 new ParameterElementImpl.forNode(AstFactory.identifier3("a5")); | 394 new ParameterElementImpl.forNode(AstFactory.identifier3("a5")); |
| 395 parameter5.type = _typeProvider.intType; | 395 parameter5.type = _typeProvider.intType; |
| 396 parameter5.parameterKind = ParameterKind.REQUIRED; | 396 parameter5.parameterKind = ParameterKind.REQUIRED; |
| 397 methodM2.parameters = <ParameterElement>[ | 397 methodM2.parameters = <ParameterElement>[ |
| 398 parameter3, | 398 parameter3, |
| 399 parameter4, | 399 parameter4, |
| 400 parameter5 | 400 parameter5 |
| 401 ]; | 401 ]; |
| 402 classI2.methods = <MethodElement>[methodM2]; | 402 classI2.methods = <MethodElement>[methodM2]; |
| 403 ClassElementImpl classA = ElementFactory.classElement2("A"); | 403 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 404 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 404 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 405 MemberMap mapA = | 405 MemberMap mapA = |
| 406 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 406 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 407 expect(mapA.size, _numOfMembersInObject); | 407 expect(mapA.size, _numOfMembersInObject); |
| 408 expect(mapA.get(methodName), isNull); | 408 expect(mapA.get(methodName), isNull); |
| 409 _assertErrors( | 409 _assertErrors( |
| 410 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 410 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
| 411 } | 411 } |
| 412 | 412 |
| 413 void | 413 void |
| 414 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_str_
int() { | 414 test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_
str_int() { |
| 415 // class I1 { int m(); } | 415 // class I1 { int m(); } |
| 416 // class I2 { String m(); } | 416 // class I2 { String m(); } |
| 417 // class A implements I2, I1 {} | 417 // class A implements I2, I1 {} |
| 418 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 418 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 419 String methodName = "m"; | 419 String methodName = "m"; |
| 420 MethodElement methodM1 = ElementFactory | 420 MethodElement methodM1 = ElementFactory |
| 421 .methodElement(methodName, null, [_typeProvider.stringType]); | 421 .methodElement(methodName, null, [_typeProvider.stringType]); |
| 422 classI1.methods = <MethodElement>[methodM1]; | 422 classI1.methods = <MethodElement>[methodM1]; |
| 423 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 423 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 424 MethodElement methodM2 = | 424 MethodElement methodM2 = |
| 425 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); | 425 ElementFactory.methodElement(methodName, null, [_typeProvider.intType]); |
| 426 classI2.methods = <MethodElement>[methodM2]; | 426 classI2.methods = <MethodElement>[methodM2]; |
| 427 ClassElementImpl classA = ElementFactory.classElement2("A"); | 427 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 428 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; | 428 classA.interfaces = <InterfaceType>[classI2.type, classI1.type]; |
| 429 MemberMap mapA = | 429 MemberMap mapA = |
| 430 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 430 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 431 expect(mapA.size, _numOfMembersInObject); | 431 expect(mapA.size, _numOfMembersInObject); |
| 432 expect(mapA.get(methodName), isNull); | 432 expect(mapA.get(methodName), isNull); |
| 433 _assertErrors( | 433 _assertErrors( |
| 434 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 434 classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void test_getMapOfMembersInheritedFromInterfaces_method_extends() { | 437 void test_getMapOfMembersInheritedFromInterfaces_method_extends() { |
| 438 // class A { int g(); } | 438 // class A { int g(); } |
| 439 // class B extends A {} | 439 // class B extends A {} |
| 440 ClassElementImpl classA = ElementFactory.classElement2("A"); | 440 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 441 String methodName = "m"; | 441 String methodName = "m"; |
| 442 MethodElement methodM = | 442 MethodElement methodM = |
| 443 ElementFactory.methodElement(methodName, _typeProvider.intType); | 443 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 444 classA.methods = <MethodElement>[methodM]; | 444 classA.methods = <MethodElement>[methodM]; |
| 445 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 445 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 446 MemberMap mapB = | 446 MemberMap mapB = |
| 447 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 447 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 448 MemberMap mapA = | 448 MemberMap mapA = |
| 449 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 449 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 450 expect(mapA.size, _numOfMembersInObject); | 450 expect(mapA.size, _numOfMembersInObject); |
| 451 expect(mapB.size, _numOfMembersInObject + 1); | 451 expect(mapB.size, _numOfMembersInObject + 1); |
| 452 expect(mapB.get(methodName), same(methodM)); | 452 expect(mapB.get(methodName), same(methodM)); |
| 453 _assertNoErrors(classA); | 453 _assertNoErrors(classA); |
| 454 _assertNoErrors(classB); | 454 _assertNoErrors(classB); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void test_getMapOfMembersInheritedFromInterfaces_method_implements() { | 457 void test_getMapOfMembersInheritedFromInterfaces_method_implements() { |
| 458 // class A { int g(); } | 458 // class A { int g(); } |
| 459 // class B implements A {} | 459 // class B implements A {} |
| 460 ClassElementImpl classA = ElementFactory.classElement2("A"); | 460 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 461 String methodName = "m"; | 461 String methodName = "m"; |
| 462 MethodElement methodM = | 462 MethodElement methodM = |
| 463 ElementFactory.methodElement(methodName, _typeProvider.intType); | 463 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 464 classA.methods = <MethodElement>[methodM]; | 464 classA.methods = <MethodElement>[methodM]; |
| 465 ClassElementImpl classB = ElementFactory.classElement2("B"); | 465 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 466 classB.interfaces = <InterfaceType>[classA.type]; | 466 classB.interfaces = <InterfaceType>[classA.type]; |
| 467 MemberMap mapB = | 467 MemberMap mapB = |
| 468 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 468 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 469 MemberMap mapA = | 469 MemberMap mapA = |
| 470 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 470 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 471 expect(mapA.size, _numOfMembersInObject); | 471 expect(mapA.size, _numOfMembersInObject); |
| 472 expect(mapB.size, _numOfMembersInObject + 1); | 472 expect(mapB.size, _numOfMembersInObject + 1); |
| 473 expect(mapB.get(methodName), same(methodM)); | 473 expect(mapB.get(methodName), same(methodM)); |
| 474 _assertNoErrors(classA); | 474 _assertNoErrors(classA); |
| 475 _assertNoErrors(classB); | 475 _assertNoErrors(classB); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void test_getMapOfMembersInheritedFromInterfaces_method_with() { | 478 void test_getMapOfMembersInheritedFromInterfaces_method_with() { |
| 479 // class A { int g(); } | 479 // class A { int g(); } |
| 480 // class B extends Object with A {} | 480 // class B extends Object with A {} |
| 481 ClassElementImpl classA = ElementFactory.classElement2("A"); | 481 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 482 String methodName = "m"; | 482 String methodName = "m"; |
| 483 MethodElement methodM = | 483 MethodElement methodM = |
| 484 ElementFactory.methodElement(methodName, _typeProvider.intType); | 484 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 485 classA.methods = <MethodElement>[methodM]; | 485 classA.methods = <MethodElement>[methodM]; |
| 486 ClassElementImpl classB = ElementFactory.classElement2("B"); | 486 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 487 classB.mixins = <InterfaceType>[classA.type]; | 487 classB.mixins = <InterfaceType>[classA.type]; |
| 488 MemberMap mapB = | 488 MemberMap mapB = |
| 489 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); | 489 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB); |
| 490 MemberMap mapA = | 490 MemberMap mapA = |
| 491 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 491 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 492 expect(mapA.size, _numOfMembersInObject); | 492 expect(mapA.size, _numOfMembersInObject); |
| 493 expect(mapB.size, _numOfMembersInObject + 1); | 493 expect(mapB.size, _numOfMembersInObject + 1); |
| 494 expect(mapB.get(methodName), same(methodM)); | 494 expect(mapB.get(methodName), same(methodM)); |
| 495 _assertNoErrors(classA); | 495 _assertNoErrors(classA); |
| 496 _assertNoErrors(classB); | 496 _assertNoErrors(classB); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void test_getMapOfMembersInheritedFromInterfaces_union_differentNames() { | 499 void test_getMapOfMembersInheritedFromInterfaces_union_differentNames() { |
| 500 // class I1 { int m1(); } | 500 // class I1 { int m1(); } |
| 501 // class I2 { int m2(); } | 501 // class I2 { int m2(); } |
| 502 // class A implements I1, I2 {} | 502 // class A implements I1, I2 {} |
| 503 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 503 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 504 String methodName1 = "m1"; | 504 String methodName1 = "m1"; |
| 505 MethodElement methodM1 = | 505 MethodElement methodM1 = |
| 506 ElementFactory.methodElement(methodName1, _typeProvider.intType); | 506 ElementFactory.methodElement(methodName1, _typeProvider.intType); |
| 507 classI1.methods = <MethodElement>[methodM1]; | 507 classI1.methods = <MethodElement>[methodM1]; |
| 508 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 508 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 509 String methodName2 = "m2"; | 509 String methodName2 = "m2"; |
| 510 MethodElement methodM2 = | 510 MethodElement methodM2 = |
| 511 ElementFactory.methodElement(methodName2, _typeProvider.intType); | 511 ElementFactory.methodElement(methodName2, _typeProvider.intType); |
| 512 classI2.methods = <MethodElement>[methodM2]; | 512 classI2.methods = <MethodElement>[methodM2]; |
| 513 ClassElementImpl classA = ElementFactory.classElement2("A"); | 513 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 514 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 514 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 515 MemberMap mapA = | 515 MemberMap mapA = |
| 516 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 516 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 517 expect(mapA.size, _numOfMembersInObject + 2); | 517 expect(mapA.size, _numOfMembersInObject + 2); |
| 518 expect(mapA.get(methodName1), same(methodM1)); | 518 expect(mapA.get(methodName1), same(methodM1)); |
| 519 expect(mapA.get(methodName2), same(methodM2)); | 519 expect(mapA.get(methodName2), same(methodM2)); |
| 520 _assertNoErrors(classA); | 520 _assertNoErrors(classA); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void | 523 void |
| 524 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_getters()
{ | 524 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_gette
rs() { |
| 525 // class I1 { int get g; } | 525 // class I1 { int get g; } |
| 526 // class I2 { num get g; } | 526 // class I2 { num get g; } |
| 527 // class A implements I1, I2 {} | 527 // class A implements I1, I2 {} |
| 528 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 528 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 529 String accessorName = "g"; | 529 String accessorName = "g"; |
| 530 PropertyAccessorElement getter1 = ElementFactory.getterElement( | 530 PropertyAccessorElement getter1 = ElementFactory.getterElement( |
| 531 accessorName, false, _typeProvider.intType); | 531 accessorName, false, _typeProvider.intType); |
| 532 classI1.accessors = <PropertyAccessorElement>[getter1]; | 532 classI1.accessors = <PropertyAccessorElement>[getter1]; |
| 533 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 533 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 534 PropertyAccessorElement getter2 = ElementFactory.getterElement( | 534 PropertyAccessorElement getter2 = ElementFactory.getterElement( |
| 535 accessorName, false, _typeProvider.numType); | 535 accessorName, false, _typeProvider.numType); |
| 536 classI2.accessors = <PropertyAccessorElement>[getter2]; | 536 classI2.accessors = <PropertyAccessorElement>[getter2]; |
| 537 ClassElementImpl classA = ElementFactory.classElement2("A"); | 537 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 538 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 538 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 539 MemberMap mapA = | 539 MemberMap mapA = |
| 540 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 540 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 541 expect(mapA.size, _numOfMembersInObject + 1); | 541 expect(mapA.size, _numOfMembersInObject + 1); |
| 542 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 542 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
| 543 accessorName, false, _typeProvider.dynamicType); | 543 accessorName, false, _typeProvider.dynamicType); |
| 544 expect(mapA.get(accessorName).type, syntheticAccessor.type); | 544 expect(mapA.get(accessorName).type, syntheticAccessor.type); |
| 545 _assertNoErrors(classA); | 545 _assertNoErrors(classA); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void | 548 void |
| 549 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_methods()
{ | 549 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_metho
ds() { |
| 550 // class I1 { dynamic m(int); } | 550 // class I1 { dynamic m(int); } |
| 551 // class I2 { dynamic m(num); } | 551 // class I2 { dynamic m(num); } |
| 552 // class A implements I1, I2 {} | 552 // class A implements I1, I2 {} |
| 553 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 553 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 554 String methodName = "m"; | 554 String methodName = "m"; |
| 555 MethodElementImpl methodM1 = | 555 MethodElementImpl methodM1 = |
| 556 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 556 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 557 ParameterElementImpl parameter1 = | 557 ParameterElementImpl parameter1 = |
| 558 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 558 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 559 parameter1.type = _typeProvider.intType; | 559 parameter1.type = _typeProvider.intType; |
| 560 parameter1.parameterKind = ParameterKind.REQUIRED; | 560 parameter1.parameterKind = ParameterKind.REQUIRED; |
| 561 methodM1.parameters = <ParameterElement>[parameter1]; | 561 methodM1.parameters = <ParameterElement>[parameter1]; |
| 562 classI1.methods = <MethodElement>[methodM1]; | 562 classI1.methods = <MethodElement>[methodM1]; |
| 563 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 563 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 564 MethodElementImpl methodM2 = | 564 MethodElementImpl methodM2 = |
| 565 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 565 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 566 ParameterElementImpl parameter2 = | 566 ParameterElementImpl parameter2 = |
| 567 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 567 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 568 parameter2.type = _typeProvider.numType; | 568 parameter2.type = _typeProvider.numType; |
| 569 parameter2.parameterKind = ParameterKind.REQUIRED; | 569 parameter2.parameterKind = ParameterKind.REQUIRED; |
| 570 methodM2.parameters = <ParameterElement>[parameter2]; | 570 methodM2.parameters = <ParameterElement>[parameter2]; |
| 571 classI2.methods = <MethodElement>[methodM2]; | 571 classI2.methods = <MethodElement>[methodM2]; |
| 572 ClassElementImpl classA = ElementFactory.classElement2("A"); | 572 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 573 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 573 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 574 MemberMap mapA = | 574 MemberMap mapA = |
| 575 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 575 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 576 expect(mapA.size, _numOfMembersInObject + 1); | 576 expect(mapA.size, _numOfMembersInObject + 1); |
| 577 MethodElement syntheticMethod = ElementFactory.methodElement( | 577 MethodElement syntheticMethod = ElementFactory.methodElement( |
| 578 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 578 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
| 579 expect(mapA.get(methodName).type, syntheticMethod.type); | 579 expect(mapA.get(methodName).type, syntheticMethod.type); |
| 580 _assertNoErrors(classA); | 580 _assertNoErrors(classA); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void | 583 void |
| 584 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_setters()
{ | 584 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_sette
rs() { |
| 585 // class I1 { set s(int); } | 585 // class I1 { set s(int); } |
| 586 // class I2 { set s(num); } | 586 // class I2 { set s(num); } |
| 587 // class A implements I1, I2 {} | 587 // class A implements I1, I2 {} |
| 588 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 588 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 589 String accessorName = "s"; | 589 String accessorName = "s"; |
| 590 PropertyAccessorElement setter1 = ElementFactory.setterElement( | 590 PropertyAccessorElement setter1 = ElementFactory.setterElement( |
| 591 accessorName, false, _typeProvider.intType); | 591 accessorName, false, _typeProvider.intType); |
| 592 classI1.accessors = <PropertyAccessorElement>[setter1]; | 592 classI1.accessors = <PropertyAccessorElement>[setter1]; |
| 593 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 593 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 594 PropertyAccessorElement setter2 = ElementFactory.setterElement( | 594 PropertyAccessorElement setter2 = ElementFactory.setterElement( |
| 595 accessorName, false, _typeProvider.numType); | 595 accessorName, false, _typeProvider.numType); |
| 596 classI2.accessors = <PropertyAccessorElement>[setter2]; | 596 classI2.accessors = <PropertyAccessorElement>[setter2]; |
| 597 ClassElementImpl classA = ElementFactory.classElement2("A"); | 597 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 598 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 598 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 599 MemberMap mapA = | 599 MemberMap mapA = |
| 600 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 600 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 601 expect(mapA.size, _numOfMembersInObject + 1); | 601 expect(mapA.size, _numOfMembersInObject + 1); |
| 602 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 602 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
| 603 .setterElement(accessorName, false, _typeProvider.dynamicType); | 603 .setterElement(accessorName, false, _typeProvider.dynamicType); |
| 604 syntheticAccessor.returnType = _typeProvider.dynamicType; | 604 syntheticAccessor.returnType = _typeProvider.dynamicType; |
| 605 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); | 605 expect(mapA.get("$accessorName=").type, syntheticAccessor.type); |
| 606 _assertNoErrors(classA); | 606 _assertNoErrors(classA); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void | 609 void |
| 610 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_getters()
{ | 610 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_gette
rs() { |
| 611 // class A {} | 611 // class A {} |
| 612 // class B extends A {} | 612 // class B extends A {} |
| 613 // class C extends B {} | 613 // class C extends B {} |
| 614 // class I1 { A get g; } | 614 // class I1 { A get g; } |
| 615 // class I2 { B get g; } | 615 // class I2 { B get g; } |
| 616 // class I3 { C get g; } | 616 // class I3 { C get g; } |
| 617 // class D implements I1, I2, I3 {} | 617 // class D implements I1, I2, I3 {} |
| 618 ClassElementImpl classA = ElementFactory.classElement2("A"); | 618 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 619 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 619 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 620 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 620 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| 621 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 621 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 622 String accessorName = "g"; | 622 String accessorName = "g"; |
| 623 PropertyAccessorElement getter1 = | 623 PropertyAccessorElement getter1 = |
| 624 ElementFactory.getterElement(accessorName, false, classA.type); | 624 ElementFactory.getterElement(accessorName, false, classA.type); |
| 625 classI1.accessors = <PropertyAccessorElement>[getter1]; | 625 classI1.accessors = <PropertyAccessorElement>[getter1]; |
| 626 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 626 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 627 PropertyAccessorElement getter2 = | 627 PropertyAccessorElement getter2 = |
| 628 ElementFactory.getterElement(accessorName, false, classB.type); | 628 ElementFactory.getterElement(accessorName, false, classB.type); |
| 629 classI2.accessors = <PropertyAccessorElement>[getter2]; | 629 classI2.accessors = <PropertyAccessorElement>[getter2]; |
| 630 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); | 630 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); |
| 631 PropertyAccessorElement getter3 = | 631 PropertyAccessorElement getter3 = |
| 632 ElementFactory.getterElement(accessorName, false, classC.type); | 632 ElementFactory.getterElement(accessorName, false, classC.type); |
| 633 classI3.accessors = <PropertyAccessorElement>[getter3]; | 633 classI3.accessors = <PropertyAccessorElement>[getter3]; |
| 634 ClassElementImpl classD = ElementFactory.classElement2("D"); | 634 ClassElementImpl classD = ElementFactory.classElement2("D"); |
| 635 classD.interfaces = <InterfaceType>[ | 635 classD.interfaces = <InterfaceType>[ |
| 636 classI1.type, | 636 classI1.type, |
| 637 classI2.type, | 637 classI2.type, |
| 638 classI3.type | 638 classI3.type |
| 639 ]; | 639 ]; |
| 640 MemberMap mapD = | 640 MemberMap mapD = |
| 641 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 641 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 642 expect(mapD.size, _numOfMembersInObject + 1); | 642 expect(mapD.size, _numOfMembersInObject + 1); |
| 643 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( | 643 PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement( |
| 644 accessorName, false, _typeProvider.dynamicType); | 644 accessorName, false, _typeProvider.dynamicType); |
| 645 expect(mapD.get(accessorName).type, syntheticAccessor.type); | 645 expect(mapD.get(accessorName).type, syntheticAccessor.type); |
| 646 _assertNoErrors(classD); | 646 _assertNoErrors(classD); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void | 649 void |
| 650 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_methods()
{ | 650 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_metho
ds() { |
| 651 // class A {} | 651 // class A {} |
| 652 // class B extends A {} | 652 // class B extends A {} |
| 653 // class C extends B {} | 653 // class C extends B {} |
| 654 // class I1 { dynamic m(A a); } | 654 // class I1 { dynamic m(A a); } |
| 655 // class I2 { dynamic m(B b); } | 655 // class I2 { dynamic m(B b); } |
| 656 // class I3 { dynamic m(C c); } | 656 // class I3 { dynamic m(C c); } |
| 657 // class D implements I1, I2, I3 {} | 657 // class D implements I1, I2, I3 {} |
| 658 ClassElementImpl classA = ElementFactory.classElement2("A"); | 658 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 659 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 659 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 660 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 660 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| 661 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 661 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 662 String methodName = "m"; | 662 String methodName = "m"; |
| 663 MethodElementImpl methodM1 = | 663 MethodElementImpl methodM1 = |
| 664 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 664 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 665 ParameterElementImpl parameter1 = | 665 ParameterElementImpl parameter1 = |
| 666 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 666 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 667 parameter1.type = classA.type; | 667 parameter1.type = classA.type; |
| 668 parameter1.parameterKind = ParameterKind.REQUIRED; | 668 parameter1.parameterKind = ParameterKind.REQUIRED; |
| 669 methodM1.parameters = <ParameterElement>[parameter1]; | 669 methodM1.parameters = <ParameterElement>[parameter1]; |
| 670 classI1.methods = <MethodElement>[methodM1]; | 670 classI1.methods = <MethodElement>[methodM1]; |
| 671 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 671 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 672 MethodElementImpl methodM2 = | 672 MethodElementImpl methodM2 = |
| 673 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 673 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 674 ParameterElementImpl parameter2 = | 674 ParameterElementImpl parameter2 = |
| 675 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 675 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 676 parameter2.type = classB.type; | 676 parameter2.type = classB.type; |
| 677 parameter2.parameterKind = ParameterKind.REQUIRED; | 677 parameter2.parameterKind = ParameterKind.REQUIRED; |
| 678 methodM2.parameters = <ParameterElement>[parameter2]; | 678 methodM2.parameters = <ParameterElement>[parameter2]; |
| 679 classI2.methods = <MethodElement>[methodM2]; | 679 classI2.methods = <MethodElement>[methodM2]; |
| 680 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); | 680 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); |
| 681 MethodElementImpl methodM3 = | 681 MethodElementImpl methodM3 = |
| 682 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); | 682 ElementFactory.methodElement(methodName, _typeProvider.dynamicType); |
| 683 ParameterElementImpl parameter3 = | 683 ParameterElementImpl parameter3 = |
| 684 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); | 684 new ParameterElementImpl.forNode(AstFactory.identifier3("a0")); |
| 685 parameter3.type = classC.type; | 685 parameter3.type = classC.type; |
| 686 parameter3.parameterKind = ParameterKind.REQUIRED; | 686 parameter3.parameterKind = ParameterKind.REQUIRED; |
| 687 methodM3.parameters = <ParameterElement>[parameter3]; | 687 methodM3.parameters = <ParameterElement>[parameter3]; |
| 688 classI3.methods = <MethodElement>[methodM3]; | 688 classI3.methods = <MethodElement>[methodM3]; |
| 689 ClassElementImpl classD = ElementFactory.classElement2("D"); | 689 ClassElementImpl classD = ElementFactory.classElement2("D"); |
| 690 classD.interfaces = <InterfaceType>[ | 690 classD.interfaces = <InterfaceType>[ |
| 691 classI1.type, | 691 classI1.type, |
| 692 classI2.type, | 692 classI2.type, |
| 693 classI3.type | 693 classI3.type |
| 694 ]; | 694 ]; |
| 695 MemberMap mapD = | 695 MemberMap mapD = |
| 696 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 696 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 697 expect(mapD.size, _numOfMembersInObject + 1); | 697 expect(mapD.size, _numOfMembersInObject + 1); |
| 698 MethodElement syntheticMethod = ElementFactory.methodElement( | 698 MethodElement syntheticMethod = ElementFactory.methodElement( |
| 699 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); | 699 methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]); |
| 700 expect(mapD.get(methodName).type, syntheticMethod.type); | 700 expect(mapD.get(methodName).type, syntheticMethod.type); |
| 701 _assertNoErrors(classD); | 701 _assertNoErrors(classD); |
| 702 } | 702 } |
| 703 | 703 |
| 704 void | 704 void |
| 705 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_setters()
{ | 705 test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_sette
rs() { |
| 706 // class A {} | 706 // class A {} |
| 707 // class B extends A {} | 707 // class B extends A {} |
| 708 // class C extends B {} | 708 // class C extends B {} |
| 709 // class I1 { set s(A); } | 709 // class I1 { set s(A); } |
| 710 // class I2 { set s(B); } | 710 // class I2 { set s(B); } |
| 711 // class I3 { set s(C); } | 711 // class I3 { set s(C); } |
| 712 // class D implements I1, I2, I3 {} | 712 // class D implements I1, I2, I3 {} |
| 713 ClassElementImpl classA = ElementFactory.classElement2("A"); | 713 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 714 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 714 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 715 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); | 715 ClassElementImpl classC = ElementFactory.classElement("C", classB.type); |
| 716 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 716 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 717 String accessorName = "s"; | 717 String accessorName = "s"; |
| 718 PropertyAccessorElement setter1 = | 718 PropertyAccessorElement setter1 = |
| 719 ElementFactory.setterElement(accessorName, false, classA.type); | 719 ElementFactory.setterElement(accessorName, false, classA.type); |
| 720 classI1.accessors = <PropertyAccessorElement>[setter1]; | 720 classI1.accessors = <PropertyAccessorElement>[setter1]; |
| 721 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 721 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 722 PropertyAccessorElement setter2 = | 722 PropertyAccessorElement setter2 = |
| 723 ElementFactory.setterElement(accessorName, false, classB.type); | 723 ElementFactory.setterElement(accessorName, false, classB.type); |
| 724 classI2.accessors = <PropertyAccessorElement>[setter2]; | 724 classI2.accessors = <PropertyAccessorElement>[setter2]; |
| 725 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); | 725 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); |
| 726 PropertyAccessorElement setter3 = | 726 PropertyAccessorElement setter3 = |
| 727 ElementFactory.setterElement(accessorName, false, classC.type); | 727 ElementFactory.setterElement(accessorName, false, classC.type); |
| 728 classI3.accessors = <PropertyAccessorElement>[setter3]; | 728 classI3.accessors = <PropertyAccessorElement>[setter3]; |
| 729 ClassElementImpl classD = ElementFactory.classElement2("D"); | 729 ClassElementImpl classD = ElementFactory.classElement2("D"); |
| 730 classD.interfaces = <InterfaceType>[ | 730 classD.interfaces = <InterfaceType>[ |
| 731 classI1.type, | 731 classI1.type, |
| 732 classI2.type, | 732 classI2.type, |
| 733 classI3.type | 733 classI3.type |
| 734 ]; | 734 ]; |
| 735 MemberMap mapD = | 735 MemberMap mapD = |
| 736 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); | 736 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD); |
| 737 expect(mapD.size, _numOfMembersInObject + 1); | 737 expect(mapD.size, _numOfMembersInObject + 1); |
| 738 PropertyAccessorElementImpl syntheticAccessor = ElementFactory | 738 PropertyAccessorElementImpl syntheticAccessor = ElementFactory |
| 739 .setterElement(accessorName, false, _typeProvider.dynamicType); | 739 .setterElement(accessorName, false, _typeProvider.dynamicType); |
| 740 syntheticAccessor.returnType = _typeProvider.dynamicType; | 740 syntheticAccessor.returnType = _typeProvider.dynamicType; |
| 741 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); | 741 expect(mapD.get("$accessorName=").type, syntheticAccessor.type); |
| 742 _assertNoErrors(classD); | 742 _assertNoErrors(classD); |
| 743 } | 743 } |
| 744 | 744 |
| 745 void | 745 void |
| 746 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() { | 746 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() { |
| 747 // class I1 { int m(); } | 747 // class I1 { int m(); } |
| 748 // class I2 { int m([int]); } | 748 // class I2 { int m([int]); } |
| 749 // class A implements I1, I2 {} | 749 // class A implements I1, I2 {} |
| 750 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 750 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 751 String methodName = "m"; | 751 String methodName = "m"; |
| 752 MethodElement methodM1 = | 752 MethodElement methodM1 = |
| 753 ElementFactory.methodElement(methodName, _typeProvider.intType); | 753 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 754 classI1.methods = <MethodElement>[methodM1]; | 754 classI1.methods = <MethodElement>[methodM1]; |
| 755 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 755 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 756 MethodElementImpl methodM2 = | 756 MethodElementImpl methodM2 = |
| 757 ElementFactory.methodElement(methodName, _typeProvider.intType); | 757 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 758 ParameterElementImpl parameter1 = | 758 ParameterElementImpl parameter1 = |
| 759 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 759 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 760 parameter1.type = _typeProvider.intType; | 760 parameter1.type = _typeProvider.intType; |
| 761 parameter1.parameterKind = ParameterKind.POSITIONAL; | 761 parameter1.parameterKind = ParameterKind.POSITIONAL; |
| 762 methodM2.parameters = <ParameterElement>[parameter1]; | 762 methodM2.parameters = <ParameterElement>[parameter1]; |
| 763 classI2.methods = <MethodElement>[methodM2]; | 763 classI2.methods = <MethodElement>[methodM2]; |
| 764 ClassElementImpl classA = ElementFactory.classElement2("A"); | 764 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 765 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; | 765 classA.interfaces = <InterfaceType>[classI1.type, classI2.type]; |
| 766 MemberMap mapA = | 766 MemberMap mapA = |
| 767 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 767 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 768 expect(mapA.size, _numOfMembersInObject + 1); | 768 expect(mapA.size, _numOfMembersInObject + 1); |
| 769 expect(mapA.get(methodName), same(methodM2)); | 769 expect(mapA.get(methodName), same(methodM2)); |
| 770 _assertNoErrors(classA); | 770 _assertNoErrors(classA); |
| 771 } | 771 } |
| 772 | 772 |
| 773 void | 773 void |
| 774 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() { | 774 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() { |
| 775 // class I1 { int m(); } | 775 // class I1 { int m(); } |
| 776 // class I2 { int m([int]); } | 776 // class I2 { int m([int]); } |
| 777 // class I3 { int m([int, int]); } | 777 // class I3 { int m([int, int]); } |
| 778 // class A implements I1, I2, I3 {} | 778 // class A implements I1, I2, I3 {} |
| 779 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 779 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 780 String methodName = "m"; | 780 String methodName = "m"; |
| 781 MethodElementImpl methodM1 = | 781 MethodElementImpl methodM1 = |
| 782 ElementFactory.methodElement(methodName, _typeProvider.intType); | 782 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 783 classI1.methods = <MethodElement>[methodM1]; | 783 classI1.methods = <MethodElement>[methodM1]; |
| 784 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 784 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 785 MethodElementImpl methodM2 = | 785 MethodElementImpl methodM2 = |
| 786 ElementFactory.methodElement(methodName, _typeProvider.intType); | 786 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 787 ParameterElementImpl parameter1 = | 787 ParameterElementImpl parameter1 = |
| 788 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 788 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 789 parameter1.type = _typeProvider.intType; | 789 parameter1.type = _typeProvider.intType; |
| 790 parameter1.parameterKind = ParameterKind.POSITIONAL; | 790 parameter1.parameterKind = ParameterKind.POSITIONAL; |
| 791 methodM1.parameters = <ParameterElement>[parameter1]; | 791 methodM1.parameters = <ParameterElement>[parameter1]; |
| 792 classI2.methods = <MethodElement>[methodM2]; | 792 classI2.methods = <MethodElement>[methodM2]; |
| 793 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); | 793 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); |
| 794 MethodElementImpl methodM3 = | 794 MethodElementImpl methodM3 = |
| 795 ElementFactory.methodElement(methodName, _typeProvider.intType); | 795 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 796 ParameterElementImpl parameter2 = | 796 ParameterElementImpl parameter2 = |
| 797 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); | 797 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); |
| 798 parameter2.type = _typeProvider.intType; | 798 parameter2.type = _typeProvider.intType; |
| 799 parameter2.parameterKind = ParameterKind.POSITIONAL; | 799 parameter2.parameterKind = ParameterKind.POSITIONAL; |
| 800 ParameterElementImpl parameter3 = | 800 ParameterElementImpl parameter3 = |
| 801 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); | 801 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); |
| 802 parameter3.type = _typeProvider.intType; | 802 parameter3.type = _typeProvider.intType; |
| 803 parameter3.parameterKind = ParameterKind.POSITIONAL; | 803 parameter3.parameterKind = ParameterKind.POSITIONAL; |
| 804 methodM3.parameters = <ParameterElement>[parameter2, parameter3]; | 804 methodM3.parameters = <ParameterElement>[parameter2, parameter3]; |
| 805 classI3.methods = <MethodElement>[methodM3]; | 805 classI3.methods = <MethodElement>[methodM3]; |
| 806 ClassElementImpl classA = ElementFactory.classElement2("A"); | 806 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 807 classA.interfaces = <InterfaceType>[ | 807 classA.interfaces = <InterfaceType>[ |
| 808 classI1.type, | 808 classI1.type, |
| 809 classI2.type, | 809 classI2.type, |
| 810 classI3.type | 810 classI3.type |
| 811 ]; | 811 ]; |
| 812 MemberMap mapA = | 812 MemberMap mapA = |
| 813 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 813 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 814 expect(mapA.size, _numOfMembersInObject + 1); | 814 expect(mapA.size, _numOfMembersInObject + 1); |
| 815 expect(mapA.get(methodName), same(methodM3)); | 815 expect(mapA.get(methodName), same(methodM3)); |
| 816 _assertNoErrors(classA); | 816 _assertNoErrors(classA); |
| 817 } | 817 } |
| 818 | 818 |
| 819 void | 819 void |
| 820 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() { | 820 test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() { |
| 821 // class I1 { int m(); } | 821 // class I1 { int m(); } |
| 822 // class I2 { int m(); } | 822 // class I2 { int m(); } |
| 823 // class I3 { int m([int]); } | 823 // class I3 { int m([int]); } |
| 824 // class I4 { int m([int, int]); } | 824 // class I4 { int m([int, int]); } |
| 825 // class A implements I1, I2, I3, I4 {} | 825 // class A implements I1, I2, I3, I4 {} |
| 826 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 826 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 827 String methodName = "m"; | 827 String methodName = "m"; |
| 828 MethodElement methodM1 = | 828 MethodElement methodM1 = |
| 829 ElementFactory.methodElement(methodName, _typeProvider.intType); | 829 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 830 classI1.methods = <MethodElement>[methodM1]; | 830 classI1.methods = <MethodElement>[methodM1]; |
| 831 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 831 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 832 MethodElement methodM2 = | 832 MethodElement methodM2 = |
| 833 ElementFactory.methodElement(methodName, _typeProvider.intType); | 833 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 834 classI2.methods = <MethodElement>[methodM2]; | 834 classI2.methods = <MethodElement>[methodM2]; |
| 835 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); | 835 ClassElementImpl classI3 = ElementFactory.classElement2("I3"); |
| 836 MethodElementImpl methodM3 = | 836 MethodElementImpl methodM3 = |
| 837 ElementFactory.methodElement(methodName, _typeProvider.intType); | 837 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 838 ParameterElementImpl parameter1 = | 838 ParameterElementImpl parameter1 = |
| 839 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); | 839 new ParameterElementImpl.forNode(AstFactory.identifier3("a1")); |
| 840 parameter1.type = _typeProvider.intType; | 840 parameter1.type = _typeProvider.intType; |
| 841 parameter1.parameterKind = ParameterKind.POSITIONAL; | 841 parameter1.parameterKind = ParameterKind.POSITIONAL; |
| 842 methodM3.parameters = <ParameterElement>[parameter1]; | 842 methodM3.parameters = <ParameterElement>[parameter1]; |
| 843 classI3.methods = <MethodElement>[methodM3]; | 843 classI3.methods = <MethodElement>[methodM3]; |
| 844 ClassElementImpl classI4 = ElementFactory.classElement2("I4"); | 844 ClassElementImpl classI4 = ElementFactory.classElement2("I4"); |
| 845 MethodElementImpl methodM4 = | 845 MethodElementImpl methodM4 = |
| 846 ElementFactory.methodElement(methodName, _typeProvider.intType); | 846 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 847 ParameterElementImpl parameter2 = | 847 ParameterElementImpl parameter2 = |
| 848 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); | 848 new ParameterElementImpl.forNode(AstFactory.identifier3("a2")); |
| 849 parameter2.type = _typeProvider.intType; | 849 parameter2.type = _typeProvider.intType; |
| 850 parameter2.parameterKind = ParameterKind.POSITIONAL; | 850 parameter2.parameterKind = ParameterKind.POSITIONAL; |
| 851 ParameterElementImpl parameter3 = | 851 ParameterElementImpl parameter3 = |
| 852 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); | 852 new ParameterElementImpl.forNode(AstFactory.identifier3("a3")); |
| 853 parameter3.type = _typeProvider.intType; | 853 parameter3.type = _typeProvider.intType; |
| 854 parameter3.parameterKind = ParameterKind.POSITIONAL; | 854 parameter3.parameterKind = ParameterKind.POSITIONAL; |
| 855 methodM4.parameters = <ParameterElement>[parameter2, parameter3]; | 855 methodM4.parameters = <ParameterElement>[parameter2, parameter3]; |
| 856 classI4.methods = <MethodElement>[methodM4]; | 856 classI4.methods = <MethodElement>[methodM4]; |
| 857 ClassElementImpl classA = ElementFactory.classElement2("A"); | 857 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 858 classA.interfaces = <InterfaceType>[ | 858 classA.interfaces = <InterfaceType>[ |
| 859 classI1.type, | 859 classI1.type, |
| 860 classI2.type, | 860 classI2.type, |
| 861 classI3.type, | 861 classI3.type, |
| 862 classI4.type | 862 classI4.type |
| 863 ]; | 863 ]; |
| 864 MemberMap mapA = | 864 MemberMap mapA = |
| 865 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); | 865 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA); |
| 866 expect(mapA.size, _numOfMembersInObject + 1); | 866 expect(mapA.size, _numOfMembersInObject + 1); |
| 867 expect(mapA.get(methodName), same(methodM4)); | 867 expect(mapA.get(methodName), same(methodM4)); |
| 868 _assertNoErrors(classA); | 868 _assertNoErrors(classA); |
| 869 } | 869 } |
| 870 | 870 |
| 871 void test_lookupInheritance_interface_getter() { | 871 void test_lookupInheritance_interface_getter() { |
| 872 ClassElementImpl classA = ElementFactory.classElement2("A"); | 872 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 873 String getterName = "g"; | 873 String getterName = "g"; |
| 874 PropertyAccessorElement getterG = | 874 PropertyAccessorElement getterG = |
| 875 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 875 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 876 classA.accessors = <PropertyAccessorElement>[getterG]; | 876 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 877 ClassElementImpl classB = ElementFactory.classElement2("B"); | 877 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 878 classB.interfaces = <InterfaceType>[classA.type]; | 878 classB.interfaces = <InterfaceType>[classA.type]; |
| 879 expect(_inheritanceManager.lookupInheritance(classB, getterName), | 879 expect(_inheritanceManager.lookupInheritance(classB, getterName), |
| 880 same(getterG)); | 880 same(getterG)); |
| 881 _assertNoErrors(classA); | 881 _assertNoErrors(classA); |
| 882 _assertNoErrors(classB); | 882 _assertNoErrors(classB); |
| 883 } | 883 } |
| 884 | 884 |
| 885 void test_lookupInheritance_interface_method() { | 885 void test_lookupInheritance_interface_method() { |
| 886 ClassElementImpl classA = ElementFactory.classElement2("A"); | 886 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 887 String methodName = "m"; | 887 String methodName = "m"; |
| 888 MethodElement methodM = | 888 MethodElement methodM = |
| 889 ElementFactory.methodElement(methodName, _typeProvider.intType); | 889 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 890 classA.methods = <MethodElement>[methodM]; | 890 classA.methods = <MethodElement>[methodM]; |
| 891 ClassElementImpl classB = ElementFactory.classElement2("B"); | 891 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 892 classB.interfaces = <InterfaceType>[classA.type]; | 892 classB.interfaces = <InterfaceType>[classA.type]; |
| 893 expect(_inheritanceManager.lookupInheritance(classB, methodName), | 893 expect(_inheritanceManager.lookupInheritance(classB, methodName), |
| 894 same(methodM)); | 894 same(methodM)); |
| 895 _assertNoErrors(classA); | 895 _assertNoErrors(classA); |
| 896 _assertNoErrors(classB); | 896 _assertNoErrors(classB); |
| 897 } | 897 } |
| 898 | 898 |
| 899 void test_lookupInheritance_interface_setter() { | 899 void test_lookupInheritance_interface_setter() { |
| 900 ClassElementImpl classA = ElementFactory.classElement2("A"); | 900 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 901 String setterName = "s"; | 901 String setterName = "s"; |
| 902 PropertyAccessorElement setterS = | 902 PropertyAccessorElement setterS = |
| 903 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 903 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
| 904 classA.accessors = <PropertyAccessorElement>[setterS]; | 904 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 905 ClassElementImpl classB = ElementFactory.classElement2("B"); | 905 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 906 classB.interfaces = <InterfaceType>[classA.type]; | 906 classB.interfaces = <InterfaceType>[classA.type]; |
| 907 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), | 907 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), |
| 908 same(setterS)); | 908 same(setterS)); |
| 909 _assertNoErrors(classA); | 909 _assertNoErrors(classA); |
| 910 _assertNoErrors(classB); | 910 _assertNoErrors(classB); |
| 911 } | 911 } |
| 912 | 912 |
| 913 void test_lookupInheritance_interface_staticMember() { | 913 void test_lookupInheritance_interface_staticMember() { |
| 914 ClassElementImpl classA = ElementFactory.classElement2("A"); | 914 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 915 String methodName = "m"; | 915 String methodName = "m"; |
| 916 MethodElement methodM = | 916 MethodElement methodM = |
| 917 ElementFactory.methodElement(methodName, _typeProvider.intType); | 917 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 918 (methodM as MethodElementImpl).static = true; | 918 (methodM as MethodElementImpl).static = true; |
| 919 classA.methods = <MethodElement>[methodM]; | 919 classA.methods = <MethodElement>[methodM]; |
| 920 ClassElementImpl classB = ElementFactory.classElement2("B"); | 920 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 921 classB.interfaces = <InterfaceType>[classA.type]; | 921 classB.interfaces = <InterfaceType>[classA.type]; |
| 922 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); | 922 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); |
| 923 _assertNoErrors(classA); | 923 _assertNoErrors(classA); |
| 924 _assertNoErrors(classB); | 924 _assertNoErrors(classB); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void test_lookupInheritance_interfaces_infiniteLoop() { | 927 void test_lookupInheritance_interfaces_infiniteLoop() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 938 classB.interfaces = <InterfaceType>[classA.type]; | 938 classB.interfaces = <InterfaceType>[classA.type]; |
| 939 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); | 939 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); |
| 940 _assertNoErrors(classA); | 940 _assertNoErrors(classA); |
| 941 _assertNoErrors(classB); | 941 _assertNoErrors(classB); |
| 942 } | 942 } |
| 943 | 943 |
| 944 void test_lookupInheritance_interfaces_union2() { | 944 void test_lookupInheritance_interfaces_union2() { |
| 945 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); | 945 ClassElementImpl classI1 = ElementFactory.classElement2("I1"); |
| 946 String methodName1 = "m1"; | 946 String methodName1 = "m1"; |
| 947 MethodElement methodM1 = | 947 MethodElement methodM1 = |
| 948 ElementFactory.methodElement(methodName1, _typeProvider.intType); | 948 ElementFactory.methodElement(methodName1, _typeProvider.intType); |
| 949 classI1.methods = <MethodElement>[methodM1]; | 949 classI1.methods = <MethodElement>[methodM1]; |
| 950 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); | 950 ClassElementImpl classI2 = ElementFactory.classElement2("I2"); |
| 951 String methodName2 = "m2"; | 951 String methodName2 = "m2"; |
| 952 MethodElement methodM2 = | 952 MethodElement methodM2 = |
| 953 ElementFactory.methodElement(methodName2, _typeProvider.intType); | 953 ElementFactory.methodElement(methodName2, _typeProvider.intType); |
| 954 classI2.methods = <MethodElement>[methodM2]; | 954 classI2.methods = <MethodElement>[methodM2]; |
| 955 classI2.interfaces = <InterfaceType>[classI1.type]; | 955 classI2.interfaces = <InterfaceType>[classI1.type]; |
| 956 ClassElementImpl classA = ElementFactory.classElement2("A"); | 956 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 957 classA.interfaces = <InterfaceType>[classI2.type]; | 957 classA.interfaces = <InterfaceType>[classI2.type]; |
| 958 expect(_inheritanceManager.lookupInheritance(classA, methodName1), | 958 expect(_inheritanceManager.lookupInheritance(classA, methodName1), |
| 959 same(methodM1)); | 959 same(methodM1)); |
| 960 expect(_inheritanceManager.lookupInheritance(classA, methodName2), | 960 expect(_inheritanceManager.lookupInheritance(classA, methodName2), |
| 961 same(methodM2)); | 961 same(methodM2)); |
| 962 _assertNoErrors(classI1); | 962 _assertNoErrors(classI1); |
| 963 _assertNoErrors(classI2); | 963 _assertNoErrors(classI2); |
| 964 _assertNoErrors(classA); | 964 _assertNoErrors(classA); |
| 965 } | 965 } |
| 966 | 966 |
| 967 void test_lookupInheritance_mixin_getter() { | 967 void test_lookupInheritance_mixin_getter() { |
| 968 ClassElementImpl classA = ElementFactory.classElement2("A"); | 968 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 969 String getterName = "g"; | 969 String getterName = "g"; |
| 970 PropertyAccessorElement getterG = | 970 PropertyAccessorElement getterG = |
| 971 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 971 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 972 classA.accessors = <PropertyAccessorElement>[getterG]; | 972 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 973 ClassElementImpl classB = ElementFactory.classElement2("B"); | 973 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 974 classB.mixins = <InterfaceType>[classA.type]; | 974 classB.mixins = <InterfaceType>[classA.type]; |
| 975 expect(_inheritanceManager.lookupInheritance(classB, getterName), | 975 expect(_inheritanceManager.lookupInheritance(classB, getterName), |
| 976 same(getterG)); | 976 same(getterG)); |
| 977 _assertNoErrors(classA); | 977 _assertNoErrors(classA); |
| 978 _assertNoErrors(classB); | 978 _assertNoErrors(classB); |
| 979 } | 979 } |
| 980 | 980 |
| 981 void test_lookupInheritance_mixin_method() { | 981 void test_lookupInheritance_mixin_method() { |
| 982 ClassElementImpl classA = ElementFactory.classElement2("A"); | 982 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 983 String methodName = "m"; | 983 String methodName = "m"; |
| 984 MethodElement methodM = | 984 MethodElement methodM = |
| 985 ElementFactory.methodElement(methodName, _typeProvider.intType); | 985 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 986 classA.methods = <MethodElement>[methodM]; | 986 classA.methods = <MethodElement>[methodM]; |
| 987 ClassElementImpl classB = ElementFactory.classElement2("B"); | 987 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 988 classB.mixins = <InterfaceType>[classA.type]; | 988 classB.mixins = <InterfaceType>[classA.type]; |
| 989 expect(_inheritanceManager.lookupInheritance(classB, methodName), | 989 expect(_inheritanceManager.lookupInheritance(classB, methodName), |
| 990 same(methodM)); | 990 same(methodM)); |
| 991 _assertNoErrors(classA); | 991 _assertNoErrors(classA); |
| 992 _assertNoErrors(classB); | 992 _assertNoErrors(classB); |
| 993 } | 993 } |
| 994 | 994 |
| 995 void test_lookupInheritance_mixin_setter() { | 995 void test_lookupInheritance_mixin_setter() { |
| 996 ClassElementImpl classA = ElementFactory.classElement2("A"); | 996 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 997 String setterName = "s"; | 997 String setterName = "s"; |
| 998 PropertyAccessorElement setterS = | 998 PropertyAccessorElement setterS = |
| 999 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 999 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
| 1000 classA.accessors = <PropertyAccessorElement>[setterS]; | 1000 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 1001 ClassElementImpl classB = ElementFactory.classElement2("B"); | 1001 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 1002 classB.mixins = <InterfaceType>[classA.type]; | 1002 classB.mixins = <InterfaceType>[classA.type]; |
| 1003 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), | 1003 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), |
| 1004 same(setterS)); | 1004 same(setterS)); |
| 1005 _assertNoErrors(classA); | 1005 _assertNoErrors(classA); |
| 1006 _assertNoErrors(classB); | 1006 _assertNoErrors(classB); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 void test_lookupInheritance_mixin_staticMember() { | 1009 void test_lookupInheritance_mixin_staticMember() { |
| 1010 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1010 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1011 String methodName = "m"; | 1011 String methodName = "m"; |
| 1012 MethodElement methodM = | 1012 MethodElement methodM = |
| 1013 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1013 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1014 (methodM as MethodElementImpl).static = true; | 1014 (methodM as MethodElementImpl).static = true; |
| 1015 classA.methods = <MethodElement>[methodM]; | 1015 classA.methods = <MethodElement>[methodM]; |
| 1016 ClassElementImpl classB = ElementFactory.classElement2("B"); | 1016 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 1017 classB.mixins = <InterfaceType>[classA.type]; | 1017 classB.mixins = <InterfaceType>[classA.type]; |
| 1018 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); | 1018 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); |
| 1019 _assertNoErrors(classA); | 1019 _assertNoErrors(classA); |
| 1020 _assertNoErrors(classB); | 1020 _assertNoErrors(classB); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 void test_lookupInheritance_noMember() { | 1023 void test_lookupInheritance_noMember() { |
| 1024 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1024 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1025 expect(_inheritanceManager.lookupInheritance(classA, "a"), isNull); | 1025 expect(_inheritanceManager.lookupInheritance(classA, "a"), isNull); |
| 1026 _assertNoErrors(classA); | 1026 _assertNoErrors(classA); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 void test_lookupInheritance_superclass_getter() { | 1029 void test_lookupInheritance_superclass_getter() { |
| 1030 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1030 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1031 String getterName = "g"; | 1031 String getterName = "g"; |
| 1032 PropertyAccessorElement getterG = | 1032 PropertyAccessorElement getterG = |
| 1033 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 1033 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 1034 classA.accessors = <PropertyAccessorElement>[getterG]; | 1034 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 1035 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 1035 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 1036 expect(_inheritanceManager.lookupInheritance(classB, getterName), | 1036 expect(_inheritanceManager.lookupInheritance(classB, getterName), |
| 1037 same(getterG)); | 1037 same(getterG)); |
| 1038 _assertNoErrors(classA); | 1038 _assertNoErrors(classA); |
| 1039 _assertNoErrors(classB); | 1039 _assertNoErrors(classB); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 void test_lookupInheritance_superclass_infiniteLoop() { | 1042 void test_lookupInheritance_superclass_infiniteLoop() { |
| 1043 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1043 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1044 classA.supertype = classA.type; | 1044 classA.supertype = classA.type; |
| 1045 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); | 1045 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); |
| 1046 _assertNoErrors(classA); | 1046 _assertNoErrors(classA); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 void test_lookupInheritance_superclass_infiniteLoop2() { | 1049 void test_lookupInheritance_superclass_infiniteLoop2() { |
| 1050 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1050 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1051 ClassElementImpl classB = ElementFactory.classElement2("B"); | 1051 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 1052 classA.supertype = classB.type; | 1052 classA.supertype = classB.type; |
| 1053 classB.supertype = classA.type; | 1053 classB.supertype = classA.type; |
| 1054 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); | 1054 expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull); |
| 1055 _assertNoErrors(classA); | 1055 _assertNoErrors(classA); |
| 1056 _assertNoErrors(classB); | 1056 _assertNoErrors(classB); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 void test_lookupInheritance_superclass_method() { | 1059 void test_lookupInheritance_superclass_method() { |
| 1060 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1060 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1061 String methodName = "m"; | 1061 String methodName = "m"; |
| 1062 MethodElement methodM = | 1062 MethodElement methodM = |
| 1063 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1063 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1064 classA.methods = <MethodElement>[methodM]; | 1064 classA.methods = <MethodElement>[methodM]; |
| 1065 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 1065 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 1066 expect(_inheritanceManager.lookupInheritance(classB, methodName), | 1066 expect(_inheritanceManager.lookupInheritance(classB, methodName), |
| 1067 same(methodM)); | 1067 same(methodM)); |
| 1068 _assertNoErrors(classA); | 1068 _assertNoErrors(classA); |
| 1069 _assertNoErrors(classB); | 1069 _assertNoErrors(classB); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 void test_lookupInheritance_superclass_setter() { | 1072 void test_lookupInheritance_superclass_setter() { |
| 1073 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1073 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1074 String setterName = "s"; | 1074 String setterName = "s"; |
| 1075 PropertyAccessorElement setterS = | 1075 PropertyAccessorElement setterS = |
| 1076 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 1076 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
| 1077 classA.accessors = <PropertyAccessorElement>[setterS]; | 1077 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 1078 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 1078 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 1079 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), | 1079 expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), |
| 1080 same(setterS)); | 1080 same(setterS)); |
| 1081 _assertNoErrors(classA); | 1081 _assertNoErrors(classA); |
| 1082 _assertNoErrors(classB); | 1082 _assertNoErrors(classB); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 void test_lookupInheritance_superclass_staticMember() { | 1085 void test_lookupInheritance_superclass_staticMember() { |
| 1086 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1086 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1087 String methodName = "m"; | 1087 String methodName = "m"; |
| 1088 MethodElement methodM = | 1088 MethodElement methodM = |
| 1089 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1089 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1090 (methodM as MethodElementImpl).static = true; | 1090 (methodM as MethodElementImpl).static = true; |
| 1091 classA.methods = <MethodElement>[methodM]; | 1091 classA.methods = <MethodElement>[methodM]; |
| 1092 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 1092 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 1093 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); | 1093 expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull); |
| 1094 _assertNoErrors(classA); | 1094 _assertNoErrors(classA); |
| 1095 _assertNoErrors(classB); | 1095 _assertNoErrors(classB); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 void test_lookupMember_getter() { | 1098 void test_lookupMember_getter() { |
| 1099 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1099 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1100 String getterName = "g"; | 1100 String getterName = "g"; |
| 1101 PropertyAccessorElement getterG = | 1101 PropertyAccessorElement getterG = |
| 1102 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 1102 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 1103 classA.accessors = <PropertyAccessorElement>[getterG]; | 1103 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 1104 expect(_inheritanceManager.lookupMember(classA, getterName), same(getterG)); | 1104 expect(_inheritanceManager.lookupMember(classA, getterName), same(getterG)); |
| 1105 _assertNoErrors(classA); | 1105 _assertNoErrors(classA); |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 void test_lookupMember_getter_static() { | 1108 void test_lookupMember_getter_static() { |
| 1109 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1109 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1110 String getterName = "g"; | 1110 String getterName = "g"; |
| 1111 PropertyAccessorElement getterG = | 1111 PropertyAccessorElement getterG = |
| 1112 ElementFactory.getterElement(getterName, true, _typeProvider.intType); | 1112 ElementFactory.getterElement(getterName, true, _typeProvider.intType); |
| 1113 classA.accessors = <PropertyAccessorElement>[getterG]; | 1113 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 1114 expect(_inheritanceManager.lookupMember(classA, getterName), isNull); | 1114 expect(_inheritanceManager.lookupMember(classA, getterName), isNull); |
| 1115 _assertNoErrors(classA); | 1115 _assertNoErrors(classA); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 void test_lookupMember_method() { | 1118 void test_lookupMember_method() { |
| 1119 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1119 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1120 String methodName = "m"; | 1120 String methodName = "m"; |
| 1121 MethodElement methodM = | 1121 MethodElement methodM = |
| 1122 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1122 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1123 classA.methods = <MethodElement>[methodM]; | 1123 classA.methods = <MethodElement>[methodM]; |
| 1124 expect(_inheritanceManager.lookupMember(classA, methodName), same(methodM)); | 1124 expect(_inheritanceManager.lookupMember(classA, methodName), same(methodM)); |
| 1125 _assertNoErrors(classA); | 1125 _assertNoErrors(classA); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 void test_lookupMember_method_static() { | 1128 void test_lookupMember_method_static() { |
| 1129 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1129 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1130 String methodName = "m"; | 1130 String methodName = "m"; |
| 1131 MethodElement methodM = | 1131 MethodElement methodM = |
| 1132 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1132 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1133 (methodM as MethodElementImpl).static = true; | 1133 (methodM as MethodElementImpl).static = true; |
| 1134 classA.methods = <MethodElement>[methodM]; | 1134 classA.methods = <MethodElement>[methodM]; |
| 1135 expect(_inheritanceManager.lookupMember(classA, methodName), isNull); | 1135 expect(_inheritanceManager.lookupMember(classA, methodName), isNull); |
| 1136 _assertNoErrors(classA); | 1136 _assertNoErrors(classA); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 void test_lookupMember_noMember() { | 1139 void test_lookupMember_noMember() { |
| 1140 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1140 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1141 expect(_inheritanceManager.lookupMember(classA, "a"), isNull); | 1141 expect(_inheritanceManager.lookupMember(classA, "a"), isNull); |
| 1142 _assertNoErrors(classA); | 1142 _assertNoErrors(classA); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 void test_lookupMember_setter() { | 1145 void test_lookupMember_setter() { |
| 1146 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1146 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1147 String setterName = "s"; | 1147 String setterName = "s"; |
| 1148 PropertyAccessorElement setterS = | 1148 PropertyAccessorElement setterS = |
| 1149 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 1149 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
| 1150 classA.accessors = <PropertyAccessorElement>[setterS]; | 1150 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 1151 expect(_inheritanceManager.lookupMember(classA, "$setterName="), | 1151 expect(_inheritanceManager.lookupMember(classA, "$setterName="), |
| 1152 same(setterS)); | 1152 same(setterS)); |
| 1153 _assertNoErrors(classA); | 1153 _assertNoErrors(classA); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 void test_lookupMember_setter_static() { | 1156 void test_lookupMember_setter_static() { |
| 1157 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1157 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1158 String setterName = "s"; | 1158 String setterName = "s"; |
| 1159 PropertyAccessorElement setterS = | 1159 PropertyAccessorElement setterS = |
| 1160 ElementFactory.setterElement(setterName, true, _typeProvider.intType); | 1160 ElementFactory.setterElement(setterName, true, _typeProvider.intType); |
| 1161 classA.accessors = <PropertyAccessorElement>[setterS]; | 1161 classA.accessors = <PropertyAccessorElement>[setterS]; |
| 1162 expect(_inheritanceManager.lookupMember(classA, setterName), isNull); | 1162 expect(_inheritanceManager.lookupMember(classA, setterName), isNull); |
| 1163 _assertNoErrors(classA); | 1163 _assertNoErrors(classA); |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 void test_lookupOverrides_noParentClasses() { | 1166 void test_lookupOverrides_noParentClasses() { |
| 1167 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1167 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1168 String methodName = "m"; | 1168 String methodName = "m"; |
| 1169 MethodElementImpl methodM = | 1169 MethodElementImpl methodM = |
| 1170 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1170 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1171 classA.methods = <MethodElement>[methodM]; | 1171 classA.methods = <MethodElement>[methodM]; |
| 1172 expect( | 1172 expect( |
| 1173 _inheritanceManager.lookupOverrides(classA, methodName), hasLength(0)); | 1173 _inheritanceManager.lookupOverrides(classA, methodName), hasLength(0)); |
| 1174 _assertNoErrors(classA); | 1174 _assertNoErrors(classA); |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 void test_lookupOverrides_overrideBaseClass() { | 1177 void test_lookupOverrides_overrideBaseClass() { |
| 1178 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1178 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1179 String methodName = "m"; | 1179 String methodName = "m"; |
| 1180 MethodElementImpl methodMinA = | 1180 MethodElementImpl methodMinA = |
| 1181 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1181 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1182 classA.methods = <MethodElement>[methodMinA]; | 1182 classA.methods = <MethodElement>[methodMinA]; |
| 1183 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 1183 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 1184 MethodElementImpl methodMinB = | 1184 MethodElementImpl methodMinB = |
| 1185 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1185 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1186 classB.methods = <MethodElement>[methodMinB]; | 1186 classB.methods = <MethodElement>[methodMinB]; |
| 1187 List<ExecutableElement> overrides = | 1187 List<ExecutableElement> overrides = |
| 1188 _inheritanceManager.lookupOverrides(classB, methodName); | 1188 _inheritanceManager.lookupOverrides(classB, methodName); |
| 1189 expect(overrides, unorderedEquals([methodMinA])); | 1189 expect(overrides, unorderedEquals([methodMinA])); |
| 1190 _assertNoErrors(classA); | 1190 _assertNoErrors(classA); |
| 1191 _assertNoErrors(classB); | 1191 _assertNoErrors(classB); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 void test_lookupOverrides_overrideInterface() { | 1194 void test_lookupOverrides_overrideInterface() { |
| 1195 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1195 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1196 String methodName = "m"; | 1196 String methodName = "m"; |
| 1197 MethodElementImpl methodMinA = | 1197 MethodElementImpl methodMinA = |
| 1198 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1198 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1199 classA.methods = <MethodElement>[methodMinA]; | 1199 classA.methods = <MethodElement>[methodMinA]; |
| 1200 ClassElementImpl classB = ElementFactory.classElement2("B"); | 1200 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 1201 classB.interfaces = <InterfaceType>[classA.type]; | 1201 classB.interfaces = <InterfaceType>[classA.type]; |
| 1202 MethodElementImpl methodMinB = | 1202 MethodElementImpl methodMinB = |
| 1203 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1203 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1204 classB.methods = <MethodElement>[methodMinB]; | 1204 classB.methods = <MethodElement>[methodMinB]; |
| 1205 List<ExecutableElement> overrides = | 1205 List<ExecutableElement> overrides = |
| 1206 _inheritanceManager.lookupOverrides(classB, methodName); | 1206 _inheritanceManager.lookupOverrides(classB, methodName); |
| 1207 expect(overrides, unorderedEquals([methodMinA])); | 1207 expect(overrides, unorderedEquals([methodMinA])); |
| 1208 _assertNoErrors(classA); | 1208 _assertNoErrors(classA); |
| 1209 _assertNoErrors(classB); | 1209 _assertNoErrors(classB); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 void test_lookupOverrides_overrideTwoInterfaces() { | 1212 void test_lookupOverrides_overrideTwoInterfaces() { |
| 1213 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1213 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1214 String methodName = "m"; | 1214 String methodName = "m"; |
| 1215 MethodElementImpl methodMinA = | 1215 MethodElementImpl methodMinA = |
| 1216 ElementFactory.methodElement(methodName, _typeProvider.intType); | 1216 ElementFactory.methodElement(methodName, _typeProvider.intType); |
| 1217 classA.methods = <MethodElement>[methodMinA]; | 1217 classA.methods = <MethodElement>[methodMinA]; |
| 1218 ClassElementImpl classB = ElementFactory.classElement2("B"); | 1218 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 1219 MethodElementImpl methodMinB = | 1219 MethodElementImpl methodMinB = |
| 1220 ElementFactory.methodElement(methodName, _typeProvider.doubleType); | 1220 ElementFactory.methodElement(methodName, _typeProvider.doubleType); |
| 1221 classB.methods = <MethodElement>[methodMinB]; | 1221 classB.methods = <MethodElement>[methodMinB]; |
| 1222 ClassElementImpl classC = ElementFactory.classElement2("C"); | 1222 ClassElementImpl classC = ElementFactory.classElement2("C"); |
| 1223 classC.interfaces = <InterfaceType>[classA.type, classB.type]; | 1223 classC.interfaces = <InterfaceType>[classA.type, classB.type]; |
| 1224 MethodElementImpl methodMinC = | 1224 MethodElementImpl methodMinC = |
| 1225 ElementFactory.methodElement(methodName, _typeProvider.numType); | 1225 ElementFactory.methodElement(methodName, _typeProvider.numType); |
| 1226 classC.methods = <MethodElement>[methodMinC]; | 1226 classC.methods = <MethodElement>[methodMinC]; |
| 1227 List<ExecutableElement> overrides = | 1227 List<ExecutableElement> overrides = |
| 1228 _inheritanceManager.lookupOverrides(classC, methodName); | 1228 _inheritanceManager.lookupOverrides(classC, methodName); |
| 1229 expect(overrides, unorderedEquals([methodMinA, methodMinB])); | 1229 expect(overrides, unorderedEquals([methodMinA, methodMinB])); |
| 1230 _assertNoErrors(classA); | 1230 _assertNoErrors(classA); |
| 1231 _assertNoErrors(classB); | 1231 _assertNoErrors(classB); |
| 1232 _assertNoErrors(classC); | 1232 _assertNoErrors(classC); |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 void _assertErrors(ClassElement classElt, | 1235 void _assertErrors(ClassElement classElt, |
| 1236 [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) { | 1236 [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) { |
| 1237 GatheringErrorListener errorListener = new GatheringErrorListener(); | 1237 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 1238 HashSet<AnalysisError> actualErrors = | 1238 HashSet<AnalysisError> actualErrors = |
| 1239 _inheritanceManager.getErrors(classElt); | 1239 _inheritanceManager.getErrors(classElt); |
| 1240 if (actualErrors != null) { | 1240 if (actualErrors != null) { |
| 1241 for (AnalysisError error in actualErrors) { | 1241 for (AnalysisError error in actualErrors) { |
| 1242 errorListener.onError(error); | 1242 errorListener.onError(error); |
| 1243 } | 1243 } |
| 1244 } | 1244 } |
| 1245 errorListener.assertErrorsWithCodes(expectedErrorCodes); | 1245 errorListener.assertErrorsWithCodes(expectedErrorCodes); |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 void _assertNoErrors(ClassElement classElt) { | 1248 void _assertNoErrors(ClassElement classElt) { |
| 1249 _assertErrors(classElt); | 1249 _assertErrors(classElt); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 /** | 1252 /** |
| 1253 * Create the inheritance manager used by the tests. | 1253 * Create the inheritance manager used by the tests. |
| 1254 * | 1254 * |
| 1255 * @return the inheritance manager that was created | 1255 * @return the inheritance manager that was created |
| 1256 */ | 1256 */ |
| 1257 InheritanceManager _createInheritanceManager() { | 1257 InheritanceManager _createInheritanceManager() { |
| 1258 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 1258 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 1259 FileBasedSource source = | 1259 FileBasedSource source = |
| 1260 new FileBasedSource(FileUtilities2.createFile("/test.dart")); | 1260 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 1261 CompilationUnitElementImpl definingCompilationUnit = | 1261 CompilationUnitElementImpl definingCompilationUnit = |
| 1262 new CompilationUnitElementImpl("test.dart"); | 1262 new CompilationUnitElementImpl("test.dart"); |
| 1263 definingCompilationUnit.librarySource = | 1263 definingCompilationUnit.librarySource = |
| 1264 definingCompilationUnit.source = source; | 1264 definingCompilationUnit.source = source; |
| 1265 _definingLibrary = ElementFactory.library(context, "test"); | 1265 _definingLibrary = ElementFactory.library(context, "test"); |
| 1266 _definingLibrary.definingCompilationUnit = definingCompilationUnit; | 1266 _definingLibrary.definingCompilationUnit = definingCompilationUnit; |
| 1267 return new InheritanceManager(_definingLibrary); | 1267 return new InheritanceManager(_definingLibrary); |
| 1268 } | 1268 } |
| 1269 } | 1269 } |
| OLD | NEW |