| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.serialization_test; | 5 library dart2js.serialization_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import '../memory_compiler.dart'; | 8 import '../memory_compiler.dart'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (entryPoint == null) { | 85 if (entryPoint == null) { |
| 86 entryPoint = Uri.parse('memory:main.dart'); | 86 entryPoint = Uri.parse('memory:main.dart'); |
| 87 sourceFiles = TEST_SOURCES; | 87 sourceFiles = TEST_SOURCES; |
| 88 } | 88 } |
| 89 asyncTest(() async { | 89 asyncTest(() async { |
| 90 CompilationResult result = await runCompiler( | 90 CompilationResult result = await runCompiler( |
| 91 memorySourceFiles: sourceFiles, | 91 memorySourceFiles: sourceFiles, |
| 92 entryPoint: entryPoint, | 92 entryPoint: entryPoint, |
| 93 options: [Flags.analyzeAll, Flags.genericMethodSyntax]); | 93 options: [Flags.analyzeAll, Flags.genericMethodSyntax]); |
| 94 Compiler compiler = result.compiler; | 94 Compiler compiler = result.compiler; |
| 95 testSerialization( | 95 testSerialization(compiler.libraryLoader.libraries, compiler.reporter, |
| 96 compiler.libraryLoader.libraries, | 96 compiler.resolution, compiler.libraryLoader, |
| 97 compiler.reporter, | 97 outPath: outPath, prettyPrint: prettyPrint); |
| 98 compiler.resolution, | 98 Expect.isFalse( |
| 99 compiler.libraryLoader, | 99 compiler.reporter.hasReportedError, "Unexpected errors occured."); |
| 100 outPath: outPath, | |
| 101 prettyPrint: prettyPrint); | |
| 102 Expect.isFalse(compiler.reporter.hasReportedError, | |
| 103 "Unexpected errors occured."); | |
| 104 }); | 100 }); |
| 105 } | 101 } |
| 106 | 102 |
| 107 void testSerialization( | 103 void testSerialization( |
| 108 Iterable<LibraryElement> libraries1, | 104 Iterable<LibraryElement> libraries1, |
| 109 DiagnosticReporter reporter, | 105 DiagnosticReporter reporter, |
| 110 Resolution resolution, | 106 Resolution resolution, |
| 111 LibraryProvider libraryProvider, | 107 LibraryProvider libraryProvider, |
| 112 {String outPath, | 108 {String outPath, |
| 113 bool prettyPrint}) { | 109 bool prettyPrint}) { |
| 114 Serializer serializer = new Serializer(); | 110 Serializer serializer = new Serializer(); |
| 115 for (LibraryElement library1 in libraries1) { | 111 for (LibraryElement library1 in libraries1) { |
| 116 serializer.serialize(library1); | 112 serializer.serialize(library1); |
| 117 } | 113 } |
| 118 String text = serializer.toText(const JsonSerializationEncoder()); | 114 String text = serializer.toText(const JsonSerializationEncoder()); |
| 119 String outText = text; | 115 String outText = text; |
| 120 if (prettyPrint) { | 116 if (prettyPrint) { |
| 121 outText = serializer.prettyPrint(); | 117 outText = serializer.prettyPrint(); |
| 122 } | 118 } |
| 123 if (outPath != null) { | 119 if (outPath != null) { |
| 124 new File(outPath).writeAsStringSync(outText); | 120 new File(outPath).writeAsStringSync(outText); |
| 125 } else if (prettyPrint) { | 121 } else if (prettyPrint) { |
| 126 print(outText); | 122 print(outText); |
| 127 } | 123 } |
| 128 | 124 |
| 129 Deserializer deserializer = new Deserializer.fromText( | 125 Deserializer deserializer = new Deserializer.fromText( |
| 130 new DeserializationContext(reporter, resolution, libraryProvider), | 126 new DeserializationContext(reporter, resolution, libraryProvider), |
| 131 Uri.parse('out1.data'), | 127 Uri.parse('out1.data'), |
| 132 text, const JsonSerializationDecoder()); | 128 text, |
| 129 const JsonSerializationDecoder()); |
| 133 List<LibraryElement> libraries2 = <LibraryElement>[]; | 130 List<LibraryElement> libraries2 = <LibraryElement>[]; |
| 134 for (LibraryElement library1 in libraries1) { | 131 for (LibraryElement library1 in libraries1) { |
| 135 LibraryElement library2 = | 132 LibraryElement library2 = deserializer.lookupLibrary(library1.canonicalUri); |
| 136 deserializer.lookupLibrary(library1.canonicalUri); | |
| 137 if (library2 == null) { | 133 if (library2 == null) { |
| 138 throw new ArgumentError('No library ${library1.canonicalUri} found.'); | 134 throw new ArgumentError('No library ${library1.canonicalUri} found.'); |
| 139 } | 135 } |
| 140 checkLibraryContent('library1', 'library2', 'library', library1, library2); | 136 checkLibraryContent('library1', 'library2', 'library', library1, library2); |
| 141 libraries2.add(library2); | 137 libraries2.add(library2); |
| 142 } | 138 } |
| 143 | 139 |
| 144 Serializer serializer2 = new Serializer(); | 140 Serializer serializer2 = new Serializer(); |
| 145 for (LibraryElement library2 in libraries2) { | 141 for (LibraryElement library2 in libraries2) { |
| 146 serializer2.serialize(library2); | 142 serializer2.serialize(library2); |
| 147 } | 143 } |
| 148 String text2 = serializer2.toText(const JsonSerializationEncoder()); | 144 String text2 = serializer2.toText(const JsonSerializationEncoder()); |
| 149 | 145 |
| 150 Deserializer deserializer3 = new Deserializer.fromText( | 146 Deserializer deserializer3 = new Deserializer.fromText( |
| 151 new DeserializationContext(reporter, resolution, libraryProvider), | 147 new DeserializationContext(reporter, resolution, libraryProvider), |
| 152 Uri.parse('out2.data'), | 148 Uri.parse('out2.data'), |
| 153 text2, const JsonSerializationDecoder()); | 149 text2, |
| 150 const JsonSerializationDecoder()); |
| 154 for (LibraryElement library1 in libraries1) { | 151 for (LibraryElement library1 in libraries1) { |
| 155 LibraryElement library2 = | 152 LibraryElement library2 = deserializer.lookupLibrary(library1.canonicalUri); |
| 156 deserializer.lookupLibrary(library1.canonicalUri); | |
| 157 if (library2 == null) { | 153 if (library2 == null) { |
| 158 throw new ArgumentError('No library ${library1.canonicalUri} found.'); | 154 throw new ArgumentError('No library ${library1.canonicalUri} found.'); |
| 159 } | 155 } |
| 160 LibraryElement library3 = | 156 LibraryElement library3 = |
| 161 deserializer3.lookupLibrary(library1.canonicalUri); | 157 deserializer3.lookupLibrary(library1.canonicalUri); |
| 162 if (library3 == null) { | 158 if (library3 == null) { |
| 163 throw new ArgumentError('No library ${library1.canonicalUri} found.'); | 159 throw new ArgumentError('No library ${library1.canonicalUri} found.'); |
| 164 } | 160 } |
| 165 checkLibraryContent('library1', 'library3', 'library', library1, library3); | 161 checkLibraryContent('library1', 'library3', 'library', library1, library3); |
| 166 checkLibraryContent('library2', 'library3', 'library', library2, library3); | 162 checkLibraryContent('library2', 'library3', 'library', library2, library3); |
| 167 } | 163 } |
| 168 } | 164 } |
| 169 | 165 |
| 170 /// Check the equivalence of [library1] and [library2] and their content. | 166 /// Check the equivalence of [library1] and [library2] and their content. |
| 171 /// | 167 /// |
| 172 /// Uses [object1], [object2] and [property] to provide context for failures. | 168 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 173 checkLibraryContent( | 169 checkLibraryContent(Object object1, object2, String property, |
| 174 Object object1, object2, String property, | |
| 175 LibraryElement library1, LibraryElement library2) { | 170 LibraryElement library1, LibraryElement library2) { |
| 176 checkElementProperties(object1, object2, property, library1, library2); | 171 checkElementProperties(object1, object2, property, library1, library2); |
| 177 } | 172 } |
| 178 | 173 |
| 179 /// Check the equivalence of [element1] and [element2] and their properties. | 174 /// Check the equivalence of [element1] and [element2] and their properties. |
| 180 /// | 175 /// |
| 181 /// Uses [object1], [object2] and [property] to provide context for failures. | 176 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 182 checkElementProperties( | 177 checkElementProperties(Object object1, object2, String property, |
| 183 Object object1, object2, String property, | |
| 184 Element element1, Element element2) { | 178 Element element1, Element element2) { |
| 185 currentCheck = | 179 currentCheck = |
| 186 new Check(currentCheck, object1, object2, property, element1, element2); | 180 new Check(currentCheck, object1, object2, property, element1, element2); |
| 187 const ElementPropertyEquivalence().visit(element1, element2); | 181 const ElementPropertyEquivalence().visit(element1, element2); |
| 188 currentCheck = currentCheck.parent; | 182 currentCheck = currentCheck.parent; |
| 189 } | 183 } |
| 190 | 184 |
| 191 /// Checks the equivalence of [constructor1] and [constructor2]. | 185 /// Checks the equivalence of [constructor1] and [constructor2]. |
| 192 void constantConstructorEquivalence(ConstantConstructor constructor1, | 186 void constantConstructorEquivalence( |
| 193 ConstantConstructor constructor2) { | 187 ConstantConstructor constructor1, ConstantConstructor constructor2) { |
| 194 const ConstantConstructorEquivalence().visit(constructor1, constructor2); | 188 const ConstantConstructorEquivalence().visit(constructor1, constructor2); |
| 195 } | 189 } |
| 196 | 190 |
| 197 /// Visitor that checks the equivalence of [ConstantConstructor]s. | 191 /// Visitor that checks the equivalence of [ConstantConstructor]s. |
| 198 class ConstantConstructorEquivalence | 192 class ConstantConstructorEquivalence |
| 199 extends ConstantConstructorVisitor<dynamic, ConstantConstructor> { | 193 extends ConstantConstructorVisitor<dynamic, ConstantConstructor> { |
| 200 const ConstantConstructorEquivalence(); | 194 const ConstantConstructorEquivalence(); |
| 201 | 195 |
| 202 @override | 196 @override |
| 203 void visit(ConstantConstructor constructor1, | 197 void visit( |
| 204 ConstantConstructor constructor2) { | 198 ConstantConstructor constructor1, ConstantConstructor constructor2) { |
| 205 if (identical(constructor1, constructor2)) return; | 199 if (identical(constructor1, constructor2)) return; |
| 206 check(constructor1, constructor2, 'kind', | 200 check(constructor1, constructor2, 'kind', constructor1.kind, |
| 207 constructor1.kind, constructor2.kind); | 201 constructor2.kind); |
| 208 constructor1.accept(this, constructor2); | 202 constructor1.accept(this, constructor2); |
| 209 } | 203 } |
| 210 | 204 |
| 211 @override | 205 @override |
| 212 visitGenerative( | 206 visitGenerative(GenerativeConstantConstructor constructor1, |
| 213 GenerativeConstantConstructor constructor1, | |
| 214 GenerativeConstantConstructor constructor2) { | 207 GenerativeConstantConstructor constructor2) { |
| 215 checkTypes( | 208 checkTypes(constructor1, constructor2, 'type', constructor1.type, |
| 216 constructor1, constructor2, 'type', | 209 constructor2.type); |
| 217 constructor1.type, constructor2.type); | |
| 218 check(constructor1, constructor2, 'defaultValues.length', | 210 check(constructor1, constructor2, 'defaultValues.length', |
| 219 constructor1.defaultValues.length, | 211 constructor1.defaultValues.length, constructor2.defaultValues.length); |
| 220 constructor2.defaultValues.length); | |
| 221 constructor1.defaultValues.forEach((k, v) { | 212 constructor1.defaultValues.forEach((k, v) { |
| 222 checkConstants( | 213 checkConstants(constructor1, constructor2, 'defaultValue[$k]', v, |
| 223 constructor1, constructor2, 'defaultValue[$k]', | 214 constructor2.defaultValues[k]); |
| 224 v, constructor2.defaultValues[k]); | |
| 225 }); | 215 }); |
| 226 check(constructor1, constructor2, 'fieldMap.length', | 216 check(constructor1, constructor2, 'fieldMap.length', |
| 227 constructor1.fieldMap.length, | 217 constructor1.fieldMap.length, constructor2.fieldMap.length); |
| 228 constructor2.fieldMap.length); | |
| 229 constructor1.fieldMap.forEach((k1, v1) { | 218 constructor1.fieldMap.forEach((k1, v1) { |
| 230 bool matched = false; | 219 bool matched = false; |
| 231 constructor2.fieldMap.forEach((k2, v2) { | 220 constructor2.fieldMap.forEach((k2, v2) { |
| 232 if (k1.name == k2.name && | 221 if (k1.name == k2.name && |
| 233 k1.library.canonicalUri == k2.library.canonicalUri) { | 222 k1.library.canonicalUri == k2.library.canonicalUri) { |
| 234 checkElementIdentities( | 223 checkElementIdentities( |
| 235 constructor1, constructor2, 'fieldMap[${k1.name}].key', k1, k2); | 224 constructor1, constructor2, 'fieldMap[${k1.name}].key', k1, k2); |
| 236 checkConstants( | 225 checkConstants( |
| 237 constructor1, constructor2, 'fieldMap[${k1.name}].value', v1, v2); | 226 constructor1, constructor2, 'fieldMap[${k1.name}].value', v1, v2); |
| 238 matched = true; | 227 matched = true; |
| 239 } | 228 } |
| 240 }); | 229 }); |
| 241 if (!matched) { | 230 if (!matched) { |
| 242 throw 'Unmatched field $k1 = $v1'; | 231 throw 'Unmatched field $k1 = $v1'; |
| 243 } | 232 } |
| 244 }); | 233 }); |
| 245 checkConstants( | 234 checkConstants( |
| 246 constructor1, constructor2, 'superConstructorInvocation', | 235 constructor1, |
| 236 constructor2, |
| 237 'superConstructorInvocation', |
| 247 constructor1.superConstructorInvocation, | 238 constructor1.superConstructorInvocation, |
| 248 constructor2.superConstructorInvocation); | 239 constructor2.superConstructorInvocation); |
| 249 } | 240 } |
| 250 | 241 |
| 251 @override | 242 @override |
| 252 visitRedirectingFactory( | 243 visitRedirectingFactory(RedirectingFactoryConstantConstructor constructor1, |
| 253 RedirectingFactoryConstantConstructor constructor1, | |
| 254 RedirectingFactoryConstantConstructor constructor2) { | 244 RedirectingFactoryConstantConstructor constructor2) { |
| 255 checkConstants( | 245 checkConstants( |
| 256 constructor1, constructor2, 'targetConstructorInvocation', | 246 constructor1, |
| 247 constructor2, |
| 248 'targetConstructorInvocation', |
| 257 constructor1.targetConstructorInvocation, | 249 constructor1.targetConstructorInvocation, |
| 258 constructor2.targetConstructorInvocation); | 250 constructor2.targetConstructorInvocation); |
| 259 } | 251 } |
| 260 | 252 |
| 261 @override | 253 @override |
| 262 visitRedirectingGenerative( | 254 visitRedirectingGenerative( |
| 263 RedirectingGenerativeConstantConstructor constructor1, | 255 RedirectingGenerativeConstantConstructor constructor1, |
| 264 RedirectingGenerativeConstantConstructor constructor2) { | 256 RedirectingGenerativeConstantConstructor constructor2) { |
| 265 check(constructor1, constructor2, 'defaultValues.length', | 257 check(constructor1, constructor2, 'defaultValues.length', |
| 266 constructor1.defaultValues.length, | 258 constructor1.defaultValues.length, constructor2.defaultValues.length); |
| 267 constructor2.defaultValues.length); | |
| 268 constructor1.defaultValues.forEach((k, v) { | 259 constructor1.defaultValues.forEach((k, v) { |
| 269 checkConstants( | 260 checkConstants(constructor1, constructor2, 'defaultValue[$k]', v, |
| 270 constructor1, constructor2, 'defaultValue[$k]', | 261 constructor2.defaultValues[k]); |
| 271 v, constructor2.defaultValues[k]); | |
| 272 }); | 262 }); |
| 273 checkConstants( | 263 checkConstants( |
| 274 constructor1, constructor2, 'thisConstructorInvocation', | 264 constructor1, |
| 265 constructor2, |
| 266 'thisConstructorInvocation', |
| 275 constructor1.thisConstructorInvocation, | 267 constructor1.thisConstructorInvocation, |
| 276 constructor2.thisConstructorInvocation); | 268 constructor2.thisConstructorInvocation); |
| 277 } | 269 } |
| 278 } | 270 } |
| 279 | 271 |
| 280 /// Check the equivalence of the two lists of elements, [list1] and [list2]. | 272 /// Check the equivalence of the two lists of elements, [list1] and [list2]. |
| 281 /// | 273 /// |
| 282 /// Uses [object1], [object2] and [property] to provide context for failures. | 274 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 283 checkElementLists(Object object1, Object object2, String property, | 275 checkElementLists(Object object1, Object object2, String property, |
| 284 Iterable<Element> list1, Iterable<Element> list2) { | 276 Iterable<Element> list1, Iterable<Element> list2) { |
| 285 checkListEquivalence(object1, object2, property, | 277 checkListEquivalence( |
| 286 list1, list2, checkElementProperties); | 278 object1, object2, property, list1, list2, checkElementProperties); |
| 287 } | 279 } |
| 288 | 280 |
| 289 /// Check the equivalence of the two metadata annotations, [metadata1] and | 281 /// Check the equivalence of the two metadata annotations, [metadata1] and |
| 290 /// [metadata2]. | 282 /// [metadata2]. |
| 291 /// | 283 /// |
| 292 /// Uses [object1], [object2] and [property] to provide context for failures. | 284 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 293 checkMetadata(Object object1, Object object2, String property, | 285 checkMetadata(Object object1, Object object2, String property, |
| 294 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { | 286 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { |
| 295 check(object1, object2, property, | 287 check(object1, object2, property, metadata1, metadata2, |
| 296 metadata1, metadata2, areMetadataAnnotationsEquivalent); | 288 areMetadataAnnotationsEquivalent); |
| 297 } | 289 } |
| 298 | 290 |
| 299 /// Visitor that checks for equivalence of [Element] properties. | 291 /// Visitor that checks for equivalence of [Element] properties. |
| 300 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> { | 292 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> { |
| 301 const ElementPropertyEquivalence(); | 293 const ElementPropertyEquivalence(); |
| 302 | 294 |
| 303 void visit(Element element1, Element element2) { | 295 void visit(Element element1, Element element2) { |
| 304 if (element1 == null && element2 == null) return; | 296 if (element1 == null && element2 == null) return; |
| 305 if (element1 == null || element2 == null) { | 297 if (element1 == null || element2 == null) { |
| 306 throw currentCheck; | 298 throw currentCheck; |
| 307 } | 299 } |
| 308 element1 = element1.declaration; | 300 element1 = element1.declaration; |
| 309 element2 = element2.declaration; | 301 element2 = element2.declaration; |
| 310 if (element1 == element2) return; | 302 if (element1 == element2) return; |
| 311 check(element1, element2, 'kind', element1.kind, element2.kind); | 303 check(element1, element2, 'kind', element1.kind, element2.kind); |
| 312 element1.accept(this, element2); | 304 element1.accept(this, element2); |
| 313 check(element1, element2, 'isSynthesized', | 305 check(element1, element2, 'isSynthesized', element1.isSynthesized, |
| 314 element1.isSynthesized, element2.isSynthesized); | 306 element2.isSynthesized); |
| 315 check(element1, element2, 'isLocal', | 307 check(element1, element2, 'isLocal', element1.isLocal, element2.isLocal); |
| 316 element1.isLocal, element2.isLocal); | 308 check(element1, element2, 'isFinal', element1.isFinal, element2.isFinal); |
| 317 check(element1, element2, 'isFinal', | 309 check(element1, element2, 'isConst', element1.isConst, element2.isConst); |
| 318 element1.isFinal, element2.isFinal); | 310 check(element1, element2, 'isAbstract', element1.isAbstract, |
| 319 check(element1, element2, 'isConst', | 311 element2.isAbstract); |
| 320 element1.isConst, element2.isConst); | 312 check(element1, element2, 'isStatic', element1.isStatic, element2.isStatic); |
| 321 check(element1, element2, 'isAbstract', | 313 check(element1, element2, 'isTopLevel', element1.isTopLevel, |
| 322 element1.isAbstract, element2.isAbstract); | 314 element2.isTopLevel); |
| 323 check(element1, element2, 'isStatic', | 315 check(element1, element2, 'isClassMember', element1.isClassMember, |
| 324 element1.isStatic, element2.isStatic); | 316 element2.isClassMember); |
| 325 check(element1, element2, 'isTopLevel', | 317 check(element1, element2, 'isInstanceMember', element1.isInstanceMember, |
| 326 element1.isTopLevel, element2.isTopLevel); | 318 element2.isInstanceMember); |
| 327 check(element1, element2, 'isClassMember', | |
| 328 element1.isClassMember, element2.isClassMember); | |
| 329 check(element1, element2, 'isInstanceMember', | |
| 330 element1.isInstanceMember, element2.isInstanceMember); | |
| 331 List<MetadataAnnotation> metadata1 = <MetadataAnnotation>[]; | 319 List<MetadataAnnotation> metadata1 = <MetadataAnnotation>[]; |
| 332 metadata1.addAll(element1.metadata); | 320 metadata1.addAll(element1.metadata); |
| 333 if (element1.isPatched) { | 321 if (element1.isPatched) { |
| 334 metadata1.addAll(element1.implementation.metadata); | 322 metadata1.addAll(element1.implementation.metadata); |
| 335 } | 323 } |
| 336 List<MetadataAnnotation> metadata2 = <MetadataAnnotation>[]; | 324 List<MetadataAnnotation> metadata2 = <MetadataAnnotation>[]; |
| 337 metadata2.addAll(element2.metadata); | 325 metadata2.addAll(element2.metadata); |
| 338 if (element2.isPatched) { | 326 if (element2.isPatched) { |
| 339 metadata2.addAll(element2.implementation.metadata); | 327 metadata2.addAll(element2.implementation.metadata); |
| 340 } | 328 } |
| 341 checkListEquivalence(element1, element2, 'metadata', | 329 checkListEquivalence( |
| 342 metadata1, metadata2, checkMetadata); | 330 element1, element2, 'metadata', metadata1, metadata2, checkMetadata); |
| 343 } | 331 } |
| 344 | 332 |
| 345 @override | 333 @override |
| 346 void visitElement(Element e, Element arg) { | 334 void visitElement(Element e, Element arg) { |
| 347 throw new UnsupportedError("Unsupported element $e"); | 335 throw new UnsupportedError("Unsupported element $e"); |
| 348 } | 336 } |
| 349 | 337 |
| 350 @override | 338 @override |
| 351 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { | 339 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { |
| 352 checkElementIdentities(null, null, null, element1, element2); | 340 checkElementIdentities(null, null, null, element1, element2); |
| 353 check(element1, element2, 'name', element1.name, element2.name); | 341 check(element1, element2, 'name', element1.name, element2.name); |
| 354 check(element1, element2, 'libraryName', | 342 check(element1, element2, 'libraryName', element1.libraryName, |
| 355 element1.libraryName, element2.libraryName); | 343 element2.libraryName); |
| 356 visitMembers(element1, element2); | 344 visitMembers(element1, element2); |
| 357 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); | 345 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); |
| 358 | 346 |
| 359 checkElementLists( | 347 checkElementLists( |
| 360 element1, element2, 'compilationUnits', | 348 element1, |
| 349 element2, |
| 350 'compilationUnits', |
| 361 LibrarySerializer.getCompilationUnits(element1), | 351 LibrarySerializer.getCompilationUnits(element1), |
| 362 LibrarySerializer.getCompilationUnits(element2)); | 352 LibrarySerializer.getCompilationUnits(element2)); |
| 363 | 353 |
| 364 checkElementLists( | 354 checkElementLists( |
| 365 element1, element2, 'imports', | 355 element1, |
| 356 element2, |
| 357 'imports', |
| 366 LibrarySerializer.getImports(element1), | 358 LibrarySerializer.getImports(element1), |
| 367 LibrarySerializer.getImports(element2)); | 359 LibrarySerializer.getImports(element2)); |
| 368 checkElementLists( | 360 checkElementLists( |
| 369 element1, element2, 'exports', element1.exports, element2.exports); | 361 element1, element2, 'exports', element1.exports, element2.exports); |
| 370 | 362 |
| 371 List<Element> imported1 = LibrarySerializer.getImportedElements(element1); | 363 List<Element> imported1 = LibrarySerializer.getImportedElements(element1); |
| 372 List<Element> imported2 = LibrarySerializer.getImportedElements(element2); | 364 List<Element> imported2 = LibrarySerializer.getImportedElements(element2); |
| 373 checkElementListIdentities( | 365 checkElementListIdentities( |
| 374 element1, element2, 'importScope', imported1, imported2); | 366 element1, element2, 'importScope', imported1, imported2); |
| 375 | 367 |
| 376 checkElementListIdentities( | 368 checkElementListIdentities( |
| 377 element1, element2, 'exportScope', | 369 element1, |
| 370 element2, |
| 371 'exportScope', |
| 378 LibrarySerializer.getExportedElements(element1), | 372 LibrarySerializer.getExportedElements(element1), |
| 379 LibrarySerializer.getExportedElements(element2)); | 373 LibrarySerializer.getExportedElements(element2)); |
| 380 | 374 |
| 381 for (int index = 0; index < imported1.length; index++) { | 375 for (int index = 0; index < imported1.length; index++) { |
| 382 checkImportsFor(element1, element2, imported1[index], imported2[index]); | 376 checkImportsFor(element1, element2, imported1[index], imported2[index]); |
| 383 } | 377 } |
| 384 } | 378 } |
| 385 | 379 |
| 386 void checkImportsFor(Element element1, Element element2, | 380 void checkImportsFor( |
| 387 Element import1, Element import2) { | 381 Element element1, Element element2, Element import1, Element import2) { |
| 388 List<ImportElement> imports1 = element1.library.getImportsFor(import1); | 382 List<ImportElement> imports1 = element1.library.getImportsFor(import1); |
| 389 List<ImportElement> imports2 = element2.library.getImportsFor(import2); | 383 List<ImportElement> imports2 = element2.library.getImportsFor(import2); |
| 390 checkElementListIdentities( | 384 checkElementListIdentities(element1, element2, |
| 391 element1, element2, 'importsFor($import1/$import2)', | 385 'importsFor($import1/$import2)', imports1, imports2); |
| 392 imports1, imports2); | |
| 393 } | 386 } |
| 394 | 387 |
| 395 @override | 388 @override |
| 396 void visitCompilationUnitElement(CompilationUnitElement element1, | 389 void visitCompilationUnitElement( |
| 397 CompilationUnitElement element2) { | 390 CompilationUnitElement element1, CompilationUnitElement element2) { |
| 398 check(element1, element2, | 391 check(element1, element2, 'name', element1.name, element2.name); |
| 399 'name', | |
| 400 element1.name, element2.name); | |
| 401 checkElementIdentities( | 392 checkElementIdentities( |
| 402 element1, element2, 'library', | 393 element1, element2, 'library', element1.library, element2.library); |
| 403 element1.library, element2.library); | 394 check(element1, element2, 'script.resourceUri', element1.script.resourceUri, |
| 404 check(element1, element2, | 395 element2.script.resourceUri); |
| 405 'script.resourceUri', | |
| 406 element1.script.resourceUri, element2.script.resourceUri); | |
| 407 List<Element> members1 = <Element>[]; | 396 List<Element> members1 = <Element>[]; |
| 408 List<Element> members2 = <Element>[]; | 397 List<Element> members2 = <Element>[]; |
| 409 element1.forEachLocalMember((Element member) { | 398 element1.forEachLocalMember((Element member) { |
| 410 members1.add(member); | 399 members1.add(member); |
| 411 }); | 400 }); |
| 412 element2.forEachLocalMember((Element member) { | 401 element2.forEachLocalMember((Element member) { |
| 413 members2.add(member); | 402 members2.add(member); |
| 414 }); | 403 }); |
| 415 checkElementListIdentities( | 404 checkElementListIdentities( |
| 416 element1, element2, 'localMembers', members1, members2); | 405 element1, element2, 'localMembers', members1, members2); |
| 417 } | 406 } |
| 418 | 407 |
| 419 void visitMembers(ScopeContainerElement element1, | 408 void visitMembers( |
| 420 ScopeContainerElement element2) { | 409 ScopeContainerElement element1, ScopeContainerElement element2) { |
| 421 Set<String> names = new Set<String>(); | 410 Set<String> names = new Set<String>(); |
| 422 Iterable<Element> members1 = element1.isLibrary | 411 Iterable<Element> members1 = element1.isLibrary |
| 423 ? LibrarySerializer.getMembers(element1) | 412 ? LibrarySerializer.getMembers(element1) |
| 424 : ClassSerializer.getMembers(element1); | 413 : ClassSerializer.getMembers(element1); |
| 425 Iterable<Element> members2 = element2.isLibrary | 414 Iterable<Element> members2 = element2.isLibrary |
| 426 ? LibrarySerializer.getMembers(element2) | 415 ? LibrarySerializer.getMembers(element2) |
| 427 : ClassSerializer.getMembers(element2); | 416 : ClassSerializer.getMembers(element2); |
| 428 for (Element member in members1) { | 417 for (Element member in members1) { |
| 429 names.add(member.name); | 418 names.add(member.name); |
| 430 } | 419 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 451 String message = | 440 String message = |
| 452 'Missing member for $member1 in\n ${members2.join('\n ')}'; | 441 'Missing member for $member1 in\n ${members2.join('\n ')}'; |
| 453 if (member1.isAbstractField) { | 442 if (member1.isAbstractField) { |
| 454 // TODO(johnniwinther): Ensure abstract fields are handled correctly. | 443 // TODO(johnniwinther): Ensure abstract fields are handled correctly. |
| 455 //print(message); | 444 //print(message); |
| 456 continue; | 445 continue; |
| 457 } else { | 446 } else { |
| 458 throw message; | 447 throw message; |
| 459 } | 448 } |
| 460 } | 449 } |
| 461 currentCheck = new Check(currentCheck, element1, element2, | 450 currentCheck = new Check( |
| 462 'member:$name', member1, member2); | 451 currentCheck, element1, element2, 'member:$name', member1, member2); |
| 463 visit(member1, member2); | 452 visit(member1, member2); |
| 464 currentCheck = currentCheck.parent; | 453 currentCheck = currentCheck.parent; |
| 465 } | 454 } |
| 466 } | 455 } |
| 467 | 456 |
| 468 @override | 457 @override |
| 469 void visitClassElement(ClassElement element1, ClassElement element2) { | 458 void visitClassElement(ClassElement element1, ClassElement element2) { |
| 470 checkElementIdentities(null, null, null, element1, element2); | 459 checkElementIdentities(null, null, null, element1, element2); |
| 471 check(element1, element2, 'name', | 460 check(element1, element2, 'name', element1.name, element2.name); |
| 472 element1.name, element2.name); | |
| 473 if (!element1.isUnnamedMixinApplication) { | 461 if (!element1.isUnnamedMixinApplication) { |
| 474 check(element1, element2, 'sourcePosition', | 462 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 475 element1.sourcePosition, element2.sourcePosition); | 463 element2.sourcePosition); |
| 476 } else { | 464 } else { |
| 477 check(element1, element2, 'sourcePosition.uri', | 465 check(element1, element2, 'sourcePosition.uri', |
| 478 element1.sourcePosition.uri, element2.sourcePosition.uri); | 466 element1.sourcePosition.uri, element2.sourcePosition.uri); |
| 479 MixinApplicationElement mixin1 = element1; | 467 MixinApplicationElement mixin1 = element1; |
| 480 MixinApplicationElement mixin2 = element2; | 468 MixinApplicationElement mixin2 = element2; |
| 481 checkElementIdentities(mixin1, mixin2, 'subclass', | 469 checkElementIdentities( |
| 482 mixin1.subclass, mixin2.subclass); | 470 mixin1, mixin2, 'subclass', mixin1.subclass, mixin2.subclass); |
| 483 checkTypes(mixin1, mixin2, 'mixinType', | 471 checkTypes( |
| 484 mixin1.mixinType, mixin2.mixinType); | 472 mixin1, mixin2, 'mixinType', mixin1.mixinType, mixin2.mixinType); |
| 485 } | 473 } |
| 486 checkElementIdentities( | 474 checkElementIdentities( |
| 487 element1, element2, 'library', | 475 element1, element2, 'library', element1.library, element2.library); |
| 488 element1.library, element2.library); | 476 checkElementIdentities(element1, element2, 'compilationUnit', |
| 489 checkElementIdentities( | |
| 490 element1, element2, 'compilationUnit', | |
| 491 element1.compilationUnit, element2.compilationUnit); | 477 element1.compilationUnit, element2.compilationUnit); |
| 492 checkTypeLists( | 478 checkTypeLists(element1, element2, 'typeVariables', element1.typeVariables, |
| 493 element1, element2, 'typeVariables', | 479 element2.typeVariables); |
| 494 element1.typeVariables, element2.typeVariables); | |
| 495 checkTypes( | 480 checkTypes( |
| 496 element1, element2, 'thisType', | 481 element1, element2, 'thisType', element1.thisType, element2.thisType); |
| 497 element1.thisType, element2.thisType); | |
| 498 checkTypes( | 482 checkTypes( |
| 499 element1, element2, 'rawType', | 483 element1, element2, 'rawType', element1.rawType, element2.rawType); |
| 500 element1.rawType, element2.rawType); | 484 check(element1, element2, 'isObject', element1.isObject, element2.isObject); |
| 501 check(element1, element2, 'isObject', | 485 checkTypeLists(element1, element2, 'typeVariables', element1.typeVariables, |
| 502 element1.isObject, element2.isObject); | 486 element2.typeVariables); |
| 503 checkTypeLists(element1, element2, 'typeVariables', | 487 check(element1, element2, 'isAbstract', element1.isAbstract, |
| 504 element1.typeVariables, element2.typeVariables); | 488 element2.isAbstract); |
| 505 check(element1, element2, 'isAbstract', | |
| 506 element1.isAbstract, element2.isAbstract); | |
| 507 check(element1, element2, 'isUnnamedMixinApplication', | 489 check(element1, element2, 'isUnnamedMixinApplication', |
| 508 element1.isUnnamedMixinApplication, element2.isUnnamedMixinApplication); | 490 element1.isUnnamedMixinApplication, element2.isUnnamedMixinApplication); |
| 509 check(element1, element2, 'isProxy', | 491 check(element1, element2, 'isProxy', element1.isProxy, element2.isProxy); |
| 510 element1.isProxy, element2.isProxy); | 492 check(element1, element2, 'isInjected', element1.isInjected, |
| 511 check(element1, element2, 'isInjected', | 493 element2.isInjected); |
| 512 element1.isInjected, element2.isInjected); | 494 check(element1, element2, 'isEnumClass', element1.isEnumClass, |
| 513 check(element1, element2, 'isEnumClass', | 495 element2.isEnumClass); |
| 514 element1.isEnumClass, element2.isEnumClass); | |
| 515 if (element1.isEnumClass) { | 496 if (element1.isEnumClass) { |
| 516 EnumClassElement enum1 = element1; | 497 EnumClassElement enum1 = element1; |
| 517 EnumClassElement enum2 = element2; | 498 EnumClassElement enum2 = element2; |
| 518 checkElementLists(enum1, enum2, 'enumValues', | 499 checkElementLists( |
| 519 enum1.enumValues, enum2.enumValues); | 500 enum1, enum2, 'enumValues', enum1.enumValues, enum2.enumValues); |
| 520 } | 501 } |
| 521 if (!element1.isObject) { | 502 if (!element1.isObject) { |
| 522 checkTypes(element1, element2, 'supertype', | 503 checkTypes(element1, element2, 'supertype', element1.supertype, |
| 523 element1.supertype, element2.supertype); | 504 element2.supertype); |
| 524 } | 505 } |
| 525 check(element1, element2, 'hierarchyDepth', | 506 check(element1, element2, 'hierarchyDepth', element1.hierarchyDepth, |
| 526 element1.hierarchyDepth, element2.hierarchyDepth); | 507 element2.hierarchyDepth); |
| 527 checkTypeLists( | 508 checkTypeLists(element1, element2, 'allSupertypes', |
| 528 element1, element2, 'allSupertypes', | 509 element1.allSupertypes.toList(), element2.allSupertypes.toList()); |
| 529 element1.allSupertypes.toList(), | |
| 530 element2.allSupertypes.toList()); | |
| 531 OrderedTypeSet typeSet1 = element1.allSupertypesAndSelf; | 510 OrderedTypeSet typeSet1 = element1.allSupertypesAndSelf; |
| 532 OrderedTypeSet typeSet2 = element2.allSupertypesAndSelf; | 511 OrderedTypeSet typeSet2 = element2.allSupertypesAndSelf; |
| 533 checkListEquivalence( | 512 checkListEquivalence(element1, element2, 'allSupertypes', |
| 534 element1, element2, 'allSupertypes', | 513 typeSet1.levelOffsets, typeSet2.levelOffsets, check); |
| 535 typeSet1.levelOffsets, | 514 check(element1, element2, 'allSupertypesAndSelf.levels', typeSet1.levels, |
| 536 typeSet2.levelOffsets, | 515 typeSet2.levels); |
| 537 check); | 516 checkTypeLists(element1, element2, 'supertypes', |
| 538 check(element1, element2, 'allSupertypesAndSelf.levels', | 517 typeSet1.supertypes.toList(), typeSet2.supertypes.toList()); |
| 539 typeSet1.levels, typeSet2.levels); | 518 checkTypeLists(element1, element2, 'types', typeSet1.types.toList(), |
| 540 checkTypeLists( | |
| 541 element1, element2, 'supertypes', | |
| 542 typeSet1.supertypes.toList(), | |
| 543 typeSet2.supertypes.toList()); | |
| 544 checkTypeLists( | |
| 545 element1, element2, 'types', | |
| 546 typeSet1.types.toList(), | |
| 547 typeSet2.types.toList()); | 519 typeSet2.types.toList()); |
| 548 | 520 |
| 549 checkTypeLists( | 521 checkTypeLists(element1, element2, 'interfaces', |
| 550 element1, element2, 'interfaces', | 522 element1.interfaces.toList(), element2.interfaces.toList()); |
| 551 element1.interfaces.toList(), | |
| 552 element2.interfaces.toList()); | |
| 553 | 523 |
| 554 List<ConstructorElement> getConstructors(ClassElement cls) { | 524 List<ConstructorElement> getConstructors(ClassElement cls) { |
| 555 return cls.implementation.constructors.map((c) => c.declaration).toList(); | 525 return cls.implementation.constructors.map((c) => c.declaration).toList(); |
| 556 } | 526 } |
| 557 | 527 |
| 558 checkElementLists( | 528 checkElementLists(element1, element2, 'constructors', |
| 559 element1, element2, 'constructors', | 529 getConstructors(element1), getConstructors(element2)); |
| 560 getConstructors(element1), | |
| 561 getConstructors(element2)); | |
| 562 | 530 |
| 563 checkElementIdentities(element1, element2, 'defaultConstructor', | 531 checkElementIdentities( |
| 532 element1, |
| 533 element2, |
| 534 'defaultConstructor', |
| 564 element1.lookupDefaultConstructor(), | 535 element1.lookupDefaultConstructor(), |
| 565 element2.lookupDefaultConstructor()); | 536 element2.lookupDefaultConstructor()); |
| 566 | 537 |
| 567 visitMembers(element1, element2); | 538 visitMembers(element1, element2); |
| 568 | 539 |
| 569 ClassElement superclass1 = element1.superclass; | 540 ClassElement superclass1 = element1.superclass; |
| 570 ClassElement superclass2 = element2.superclass; | 541 ClassElement superclass2 = element2.superclass; |
| 571 while (superclass1 != null && superclass1.isMixinApplication) { | 542 while (superclass1 != null && superclass1.isMixinApplication) { |
| 572 checkElementProperties(element1, element2, 'supermixin', | 543 checkElementProperties( |
| 573 superclass1, superclass2); | 544 element1, element2, 'supermixin', superclass1, superclass2); |
| 574 superclass1 = superclass1.superclass; | 545 superclass1 = superclass1.superclass; |
| 575 superclass2 = superclass2.superclass; | 546 superclass2 = superclass2.superclass; |
| 576 } | 547 } |
| 577 } | 548 } |
| 578 | 549 |
| 579 @override | 550 @override |
| 580 void visitFieldElement(FieldElement element1, FieldElement element2) { | 551 void visitFieldElement(FieldElement element1, FieldElement element2) { |
| 581 checkElementIdentities(null, null, null, element1, element2); | 552 checkElementIdentities(null, null, null, element1, element2); |
| 582 check(element1, element2, 'name', | 553 check(element1, element2, 'name', element1.name, element2.name); |
| 583 element1.name, element2.name); | 554 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 584 check(element1, element2, 'sourcePosition', | 555 element2.sourcePosition); |
| 585 element1.sourcePosition, element2.sourcePosition); | 556 checkTypes(element1, element2, 'type', element1.type, element2.type); |
| 586 checkTypes( | |
| 587 element1, element2, 'type', | |
| 588 element1.type, element2.type); | |
| 589 checkConstants( | 557 checkConstants( |
| 590 element1, element2, 'constant', | 558 element1, element2, 'constant', element1.constant, element2.constant); |
| 591 element1.constant, element2.constant); | 559 check(element1, element2, 'isTopLevel', element1.isTopLevel, |
| 592 check(element1, element2, 'isTopLevel', | 560 element2.isTopLevel); |
| 593 element1.isTopLevel, element2.isTopLevel); | 561 check(element1, element2, 'isStatic', element1.isStatic, element2.isStatic); |
| 594 check(element1, element2, 'isStatic', | 562 check(element1, element2, 'isInstanceMember', element1.isInstanceMember, |
| 595 element1.isStatic, element2.isStatic); | 563 element2.isInstanceMember); |
| 596 check(element1, element2, 'isInstanceMember', | 564 check(element1, element2, 'isInjected', element1.isInjected, |
| 597 element1.isInstanceMember, element2.isInstanceMember); | 565 element2.isInjected); |
| 598 check(element1, element2, 'isInjected', | |
| 599 element1.isInjected, element2.isInjected); | |
| 600 | 566 |
| 601 checkElementIdentities( | 567 checkElementIdentities( |
| 602 element1, element2, 'library', | 568 element1, element2, 'library', element1.library, element2.library); |
| 603 element1.library, element2.library); | 569 checkElementIdentities(element1, element2, 'compilationUnit', |
| 604 checkElementIdentities( | |
| 605 element1, element2, 'compilationUnit', | |
| 606 element1.compilationUnit, element2.compilationUnit); | 570 element1.compilationUnit, element2.compilationUnit); |
| 607 checkElementIdentities( | 571 checkElementIdentities(element1, element2, 'enclosingClass', |
| 608 element1, element2, 'enclosingClass', | |
| 609 element1.enclosingClass, element2.enclosingClass); | 572 element1.enclosingClass, element2.enclosingClass); |
| 610 } | 573 } |
| 611 | 574 |
| 612 @override | 575 @override |
| 613 void visitFunctionElement(FunctionElement element1, | 576 void visitFunctionElement( |
| 614 FunctionElement element2) { | 577 FunctionElement element1, FunctionElement element2) { |
| 615 checkElementIdentities(null, null, null, element1, element2); | 578 checkElementIdentities(null, null, null, element1, element2); |
| 616 check(element1, element2, 'name', | 579 check(element1, element2, 'name', element1.name, element2.name); |
| 617 element1.name, element2.name); | 580 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 618 check(element1, element2, 'sourcePosition', | 581 element2.sourcePosition); |
| 619 element1.sourcePosition, element2.sourcePosition); | 582 checkTypes(element1, element2, 'type', element1.type, element2.type); |
| 620 checkTypes( | 583 checkListEquivalence(element1, element2, 'parameters', element1.parameters, |
| 621 element1, element2, 'type', | 584 element2.parameters, checkElementProperties); |
| 622 element1.type, element2.type); | 585 check(element1, element2, 'isOperator', element1.isOperator, |
| 623 checkListEquivalence( | 586 element2.isOperator); |
| 624 element1, element2, 'parameters', | 587 check(element1, element2, 'asyncMarker', element1.asyncMarker, |
| 625 element1.parameters, element2.parameters, | |
| 626 checkElementProperties); | |
| 627 check(element1, element2, 'isOperator', | |
| 628 element1.isOperator, element2.isOperator); | |
| 629 check( | |
| 630 element1, element2, 'asyncMarker', | |
| 631 element1.asyncMarker, | |
| 632 element2.asyncMarker); | 588 element2.asyncMarker); |
| 633 check(element1, element2, 'isInjected', | 589 check(element1, element2, 'isInjected', element1.isInjected, |
| 634 element1.isInjected, element2.isInjected); | 590 element2.isInjected); |
| 635 | 591 |
| 636 checkElementIdentities( | 592 checkElementIdentities( |
| 637 element1, element2, 'library', | 593 element1, element2, 'library', element1.library, element2.library); |
| 638 element1.library, element2.library); | 594 checkElementIdentities(element1, element2, 'compilationUnit', |
| 639 checkElementIdentities( | |
| 640 element1, element2, 'compilationUnit', | |
| 641 element1.compilationUnit, element2.compilationUnit); | 595 element1.compilationUnit, element2.compilationUnit); |
| 642 checkElementIdentities( | 596 checkElementIdentities(element1, element2, 'enclosingClass', |
| 643 element1, element2, 'enclosingClass', | |
| 644 element1.enclosingClass, element2.enclosingClass); | 597 element1.enclosingClass, element2.enclosingClass); |
| 645 | 598 |
| 646 check( | 599 check( |
| 647 element1, element2, 'functionSignature.type', | 600 element1, |
| 601 element2, |
| 602 'functionSignature.type', |
| 648 element1.functionSignature.type, | 603 element1.functionSignature.type, |
| 649 element2.functionSignature.type, | 604 element2.functionSignature.type, |
| 650 areTypesEquivalent); | 605 areTypesEquivalent); |
| 651 checkElementLists( | 606 checkElementLists( |
| 652 element1, element2, 'functionSignature.requiredParameters', | 607 element1, |
| 608 element2, |
| 609 'functionSignature.requiredParameters', |
| 653 element1.functionSignature.requiredParameters, | 610 element1.functionSignature.requiredParameters, |
| 654 element2.functionSignature.requiredParameters); | 611 element2.functionSignature.requiredParameters); |
| 655 checkElementLists( | 612 checkElementLists( |
| 656 element1, element2, 'functionSignature.optionalParameters', | 613 element1, |
| 614 element2, |
| 615 'functionSignature.optionalParameters', |
| 657 element1.functionSignature.optionalParameters, | 616 element1.functionSignature.optionalParameters, |
| 658 element2.functionSignature.optionalParameters); | 617 element2.functionSignature.optionalParameters); |
| 659 check( | 618 check( |
| 660 element1, element2, 'functionSignature.requiredParameterCount', | 619 element1, |
| 620 element2, |
| 621 'functionSignature.requiredParameterCount', |
| 661 element1.functionSignature.requiredParameterCount, | 622 element1.functionSignature.requiredParameterCount, |
| 662 element2.functionSignature.requiredParameterCount); | 623 element2.functionSignature.requiredParameterCount); |
| 663 check( | 624 check( |
| 664 element1, element2, 'functionSignature.optionalParameterCount', | 625 element1, |
| 626 element2, |
| 627 'functionSignature.optionalParameterCount', |
| 665 element1.functionSignature.optionalParameterCount, | 628 element1.functionSignature.optionalParameterCount, |
| 666 element2.functionSignature.optionalParameterCount); | 629 element2.functionSignature.optionalParameterCount); |
| 667 check( | 630 check( |
| 668 element1, element2, 'functionSignature.optionalParametersAreNamed', | 631 element1, |
| 632 element2, |
| 633 'functionSignature.optionalParametersAreNamed', |
| 669 element1.functionSignature.optionalParametersAreNamed, | 634 element1.functionSignature.optionalParametersAreNamed, |
| 670 element2.functionSignature.optionalParametersAreNamed); | 635 element2.functionSignature.optionalParametersAreNamed); |
| 671 check( | 636 check( |
| 672 element1, element2, 'functionSignature.hasOptionalParameters', | 637 element1, |
| 638 element2, |
| 639 'functionSignature.hasOptionalParameters', |
| 673 element1.functionSignature.hasOptionalParameters, | 640 element1.functionSignature.hasOptionalParameters, |
| 674 element2.functionSignature.hasOptionalParameters); | 641 element2.functionSignature.hasOptionalParameters); |
| 675 check( | 642 check( |
| 676 element1, element2, 'functionSignature.parameterCount', | 643 element1, |
| 644 element2, |
| 645 'functionSignature.parameterCount', |
| 677 element1.functionSignature.parameterCount, | 646 element1.functionSignature.parameterCount, |
| 678 element2.functionSignature.parameterCount); | 647 element2.functionSignature.parameterCount); |
| 679 checkElementLists( | 648 checkElementLists( |
| 680 element1, element2, 'functionSignature.orderedOptionalParameters', | 649 element1, |
| 650 element2, |
| 651 'functionSignature.orderedOptionalParameters', |
| 681 element1.functionSignature.orderedOptionalParameters, | 652 element1.functionSignature.orderedOptionalParameters, |
| 682 element2.functionSignature.orderedOptionalParameters); | 653 element2.functionSignature.orderedOptionalParameters); |
| 683 checkTypeLists(element1, element2, 'typeVariables', | 654 checkTypeLists(element1, element2, 'typeVariables', element1.typeVariables, |
| 684 element1.typeVariables, element2.typeVariables); | 655 element2.typeVariables); |
| 685 } | 656 } |
| 686 | 657 |
| 687 @override | 658 @override |
| 688 void visitConstructorElement(ConstructorElement element1, | 659 void visitConstructorElement( |
| 689 ConstructorElement element2) { | 660 ConstructorElement element1, ConstructorElement element2) { |
| 690 checkElementIdentities(null, null, null, element1, element2); | 661 checkElementIdentities(null, null, null, element1, element2); |
| 691 checkElementIdentities( | 662 checkElementIdentities(element1, element2, 'enclosingClass', |
| 692 element1, element2, 'enclosingClass', | |
| 693 element1.enclosingClass, element2.enclosingClass); | 663 element1.enclosingClass, element2.enclosingClass); |
| 694 check( | 664 check(element1, element2, 'name', element1.name, element2.name); |
| 695 element1, element2, 'name', | |
| 696 element1.name, element2.name); | |
| 697 if (!element1.isSynthesized) { | 665 if (!element1.isSynthesized) { |
| 698 check(element1, element2, 'sourcePosition', | 666 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 699 element1.sourcePosition, element2.sourcePosition); | 667 element2.sourcePosition); |
| 700 } else { | 668 } else { |
| 701 check(element1, element2, 'sourcePosition.uri', | 669 check(element1, element2, 'sourcePosition.uri', |
| 702 element1.sourcePosition.uri, element2.sourcePosition.uri); | 670 element1.sourcePosition.uri, element2.sourcePosition.uri); |
| 703 } | 671 } |
| 704 checkListEquivalence( | 672 checkListEquivalence(element1, element2, 'parameters', element1.parameters, |
| 705 element1, element2, 'parameters', | 673 element2.parameters, checkElementProperties); |
| 706 element1.parameters, element2.parameters, | 674 checkTypes(element1, element2, 'type', element1.type, element2.type); |
| 707 checkElementProperties); | 675 check(element1, element2, 'isExternal', element1.isExternal, |
| 708 checkTypes( | 676 element2.isExternal); |
| 709 element1, element2, 'type', | |
| 710 element1.type, element2.type); | |
| 711 check(element1, element2, 'isExternal', | |
| 712 element1.isExternal, element2.isExternal); | |
| 713 if (element1.isConst && !element1.isExternal) { | 677 if (element1.isConst && !element1.isExternal) { |
| 714 constantConstructorEquivalence( | 678 constantConstructorEquivalence( |
| 715 element1.constantConstructor, | 679 element1.constantConstructor, element2.constantConstructor); |
| 716 element2.constantConstructor); | |
| 717 } | 680 } |
| 718 check(element1, element2, 'isRedirectingGenerative', | 681 check(element1, element2, 'isRedirectingGenerative', |
| 719 element1.isRedirectingGenerative, element2.isRedirectingGenerative); | 682 element1.isRedirectingGenerative, element2.isRedirectingGenerative); |
| 720 check(element1, element2, 'isRedirectingFactory', | 683 check(element1, element2, 'isRedirectingFactory', |
| 721 element1.isRedirectingFactory, element2.isRedirectingFactory); | 684 element1.isRedirectingFactory, element2.isRedirectingFactory); |
| 722 checkElementIdentities(element1, element2, 'effectiveTarget', | 685 checkElementIdentities(element1, element2, 'effectiveTarget', |
| 723 element1.effectiveTarget, element2.effectiveTarget); | 686 element1.effectiveTarget, element2.effectiveTarget); |
| 724 if (element1.isRedirectingFactory) { | 687 if (element1.isRedirectingFactory) { |
| 725 checkElementIdentities(element1, element2, 'immediateRedirectionTarget', | 688 checkElementIdentities( |
| 689 element1, |
| 690 element2, |
| 691 'immediateRedirectionTarget', |
| 726 element1.immediateRedirectionTarget, | 692 element1.immediateRedirectionTarget, |
| 727 element2.immediateRedirectionTarget); | 693 element2.immediateRedirectionTarget); |
| 728 checkElementIdentities(element1, element2, 'redirectionDeferredPrefix', | 694 checkElementIdentities( |
| 695 element1, |
| 696 element2, |
| 697 'redirectionDeferredPrefix', |
| 729 element1.redirectionDeferredPrefix, | 698 element1.redirectionDeferredPrefix, |
| 730 element2.redirectionDeferredPrefix); | 699 element2.redirectionDeferredPrefix); |
| 731 check(element1, element2, 'isEffectiveTargetMalformed', | 700 check( |
| 701 element1, |
| 702 element2, |
| 703 'isEffectiveTargetMalformed', |
| 732 element1.isEffectiveTargetMalformed, | 704 element1.isEffectiveTargetMalformed, |
| 733 element2.isEffectiveTargetMalformed); | 705 element2.isEffectiveTargetMalformed); |
| 734 } | 706 } |
| 735 checkElementIdentities(element1, element2, 'definingConstructor', | 707 checkElementIdentities(element1, element2, 'definingConstructor', |
| 736 element1.definingConstructor, element2.definingConstructor); | 708 element1.definingConstructor, element2.definingConstructor); |
| 737 check( | 709 check( |
| 738 element1, element2, 'effectiveTargetType', | 710 element1, |
| 711 element2, |
| 712 'effectiveTargetType', |
| 739 element1.computeEffectiveTargetType(element1.enclosingClass.thisType), | 713 element1.computeEffectiveTargetType(element1.enclosingClass.thisType), |
| 740 element2.computeEffectiveTargetType(element2.enclosingClass.thisType), | 714 element2.computeEffectiveTargetType(element2.enclosingClass.thisType), |
| 741 areTypesEquivalent); | 715 areTypesEquivalent); |
| 742 check( | 716 check( |
| 743 element1, element2, 'effectiveTargetType.raw', | 717 element1, |
| 718 element2, |
| 719 'effectiveTargetType.raw', |
| 744 element1.computeEffectiveTargetType(element1.enclosingClass.rawType), | 720 element1.computeEffectiveTargetType(element1.enclosingClass.rawType), |
| 745 element2.computeEffectiveTargetType(element2.enclosingClass.rawType), | 721 element2.computeEffectiveTargetType(element2.enclosingClass.rawType), |
| 746 areTypesEquivalent); | 722 areTypesEquivalent); |
| 747 checkElementIdentities(element1, element2, 'immediateRedirectionTarget', | 723 checkElementIdentities( |
| 724 element1, |
| 725 element2, |
| 726 'immediateRedirectionTarget', |
| 748 element1.immediateRedirectionTarget, | 727 element1.immediateRedirectionTarget, |
| 749 element2.immediateRedirectionTarget); | 728 element2.immediateRedirectionTarget); |
| 750 checkElementIdentities(element1, element2, 'redirectionDeferredPrefix', | 729 checkElementIdentities(element1, element2, 'redirectionDeferredPrefix', |
| 751 element1.redirectionDeferredPrefix, element2.redirectionDeferredPrefix); | 730 element1.redirectionDeferredPrefix, element2.redirectionDeferredPrefix); |
| 752 check(element1, element2, 'isInjected', | 731 check(element1, element2, 'isInjected', element1.isInjected, |
| 753 element1.isInjected, element2.isInjected); | 732 element2.isInjected); |
| 754 } | 733 } |
| 755 | 734 |
| 756 @override | 735 @override |
| 757 void visitAbstractFieldElement(AbstractFieldElement element1, | 736 void visitAbstractFieldElement( |
| 758 AbstractFieldElement element2) { | 737 AbstractFieldElement element1, AbstractFieldElement element2) { |
| 759 visit(element1.getter, element2.getter); | 738 visit(element1.getter, element2.getter); |
| 760 visit(element1.setter, element2.setter); | 739 visit(element1.setter, element2.setter); |
| 761 } | 740 } |
| 762 | 741 |
| 763 @override | 742 @override |
| 764 void visitTypeVariableElement(TypeVariableElement element1, | 743 void visitTypeVariableElement( |
| 765 TypeVariableElement element2) { | 744 TypeVariableElement element1, TypeVariableElement element2) { |
| 766 checkElementIdentities(null, null, null, element1, element2); | 745 checkElementIdentities(null, null, null, element1, element2); |
| 767 check(element1, element2, 'name', element1.name, element2.name); | 746 check(element1, element2, 'name', element1.name, element2.name); |
| 768 check(element1, element2, 'sourcePosition', | 747 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 769 element1.sourcePosition, element2.sourcePosition); | 748 element2.sourcePosition); |
| 770 check(element1, element2, 'index', element1.index, element2.index); | 749 check(element1, element2, 'index', element1.index, element2.index); |
| 771 checkTypes( | 750 checkTypes(element1, element2, 'type', element1.type, element2.type); |
| 772 element1, element2, 'type', | 751 checkTypes(element1, element2, 'bound', element1.bound, element2.bound); |
| 773 element1.type, element2.type); | |
| 774 checkTypes( | |
| 775 element1, element2, 'bound', | |
| 776 element1.bound, element2.bound); | |
| 777 } | 752 } |
| 778 | 753 |
| 779 @override | 754 @override |
| 780 void visitTypedefElement(TypedefElement element1, | 755 void visitTypedefElement(TypedefElement element1, TypedefElement element2) { |
| 781 TypedefElement element2) { | |
| 782 checkElementIdentities(null, null, null, element1, element2); | 756 checkElementIdentities(null, null, null, element1, element2); |
| 783 check(element1, element2, 'name', element1.name, element2.name); | 757 check(element1, element2, 'name', element1.name, element2.name); |
| 784 check(element1, element2, 'sourcePosition', | 758 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 785 element1.sourcePosition, element2.sourcePosition); | 759 element2.sourcePosition); |
| 786 checkTypes( | 760 checkTypes(element1, element2, 'alias', element1.alias, element2.alias); |
| 787 element1, element2, 'alias', | 761 checkTypeLists(element1, element2, 'typeVariables', element1.typeVariables, |
| 788 element1.alias, element2.alias); | 762 element2.typeVariables); |
| 789 checkTypeLists( | |
| 790 element1, element2, 'typeVariables', | |
| 791 element1.typeVariables, element2.typeVariables); | |
| 792 checkElementIdentities( | 763 checkElementIdentities( |
| 793 element1, element2, 'library', | 764 element1, element2, 'library', element1.library, element2.library); |
| 794 element1.library, element2.library); | 765 checkElementIdentities(element1, element2, 'compilationUnit', |
| 795 checkElementIdentities( | |
| 796 element1, element2, 'compilationUnit', | |
| 797 element1.compilationUnit, element2.compilationUnit); | 766 element1.compilationUnit, element2.compilationUnit); |
| 798 // TODO(johnniwinther): Check the equivalence of typedef parameters. | 767 // TODO(johnniwinther): Check the equivalence of typedef parameters. |
| 799 } | 768 } |
| 800 | 769 |
| 801 @override | 770 @override |
| 802 void visitParameterElement(ParameterElement element1, | 771 void visitParameterElement( |
| 803 ParameterElement element2) { | 772 ParameterElement element1, ParameterElement element2) { |
| 804 checkElementIdentities(null, null, null, element1, element2); | 773 checkElementIdentities(null, null, null, element1, element2); |
| 805 checkElementIdentities( | 774 checkElementIdentities(element1, element2, 'functionDeclaration', |
| 806 element1, element2, 'functionDeclaration', | |
| 807 element1.functionDeclaration, element2.functionDeclaration); | 775 element1.functionDeclaration, element2.functionDeclaration); |
| 808 check(element1, element2, 'name', element1.name, element2.name); | 776 check(element1, element2, 'name', element1.name, element2.name); |
| 809 check(element1, element2, 'sourcePosition', | 777 check(element1, element2, 'sourcePosition', element1.sourcePosition, |
| 810 element1.sourcePosition, element2.sourcePosition); | 778 element2.sourcePosition); |
| 811 checkTypes( | 779 checkTypes(element1, element2, 'type', element1.type, element2.type); |
| 812 element1, element2, 'type', | 780 check(element1, element2, 'isOptional', element1.isOptional, |
| 813 element1.type, element2.type); | 781 element2.isOptional); |
| 814 check( | 782 check(element1, element2, 'isNamed', element1.isNamed, element2.isNamed); |
| 815 element1, element2, 'isOptional', | |
| 816 element1.isOptional, element2.isOptional); | |
| 817 check( | |
| 818 element1, element2, 'isNamed', | |
| 819 element1.isNamed, element2.isNamed); | |
| 820 check(element1, element2, 'name', element1.name, element2.name); | 783 check(element1, element2, 'name', element1.name, element2.name); |
| 821 if (element1.isOptional) { | 784 if (element1.isOptional) { |
| 822 checkConstants( | 785 checkConstants( |
| 823 element1, element2, 'constant', | 786 element1, element2, 'constant', element1.constant, element2.constant); |
| 824 element1.constant, element2.constant); | |
| 825 } | 787 } |
| 826 checkElementIdentities( | 788 checkElementIdentities(element1, element2, 'compilationUnit', |
| 827 element1, element2, 'compilationUnit', | |
| 828 element1.compilationUnit, element2.compilationUnit); | 789 element1.compilationUnit, element2.compilationUnit); |
| 829 } | 790 } |
| 830 | 791 |
| 831 @override | 792 @override |
| 832 void visitFieldParameterElement(InitializingFormalElement element1, | 793 void visitFieldParameterElement( |
| 833 InitializingFormalElement element2) { | 794 InitializingFormalElement element1, InitializingFormalElement element2) { |
| 834 visitParameterElement(element1, element2); | 795 visitParameterElement(element1, element2); |
| 835 checkElementIdentities( | 796 checkElementIdentities(element1, element2, 'fieldElement', |
| 836 element1, element2, 'fieldElement', | |
| 837 element1.fieldElement, element2.fieldElement); | 797 element1.fieldElement, element2.fieldElement); |
| 838 } | 798 } |
| 839 | 799 |
| 840 @override | 800 @override |
| 841 void visitImportElement(ImportElement element1, ImportElement element2) { | 801 void visitImportElement(ImportElement element1, ImportElement element2) { |
| 842 check(element1, element2, 'uri', element1.uri, element2.uri); | 802 check(element1, element2, 'uri', element1.uri, element2.uri); |
| 843 check( | 803 check(element1, element2, 'isDeferred', element1.isDeferred, |
| 844 element1, element2, 'isDeferred', | 804 element2.isDeferred); |
| 845 element1.isDeferred, element2.isDeferred); | |
| 846 checkElementProperties( | 805 checkElementProperties( |
| 847 element1, element2, 'prefix', | 806 element1, element2, 'prefix', element1.prefix, element2.prefix); |
| 848 element1.prefix, element2.prefix); | 807 checkElementIdentities(element1, element2, 'importedLibrary', |
| 849 checkElementIdentities( | |
| 850 element1, element2, 'importedLibrary', | |
| 851 element1.importedLibrary, element2.importedLibrary); | 808 element1.importedLibrary, element2.importedLibrary); |
| 852 } | 809 } |
| 853 | 810 |
| 854 @override | 811 @override |
| 855 void visitExportElement(ExportElement element1, ExportElement element2) { | 812 void visitExportElement(ExportElement element1, ExportElement element2) { |
| 856 check(element1, element2, 'uri', element1.uri, element2.uri); | 813 check(element1, element2, 'uri', element1.uri, element2.uri); |
| 857 checkElementIdentities( | 814 checkElementIdentities(element1, element2, 'importedLibrary', |
| 858 element1, element2, 'importedLibrary', | |
| 859 element1.exportedLibrary, element2.exportedLibrary); | 815 element1.exportedLibrary, element2.exportedLibrary); |
| 860 } | 816 } |
| 861 | 817 |
| 862 @override | 818 @override |
| 863 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { | 819 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { |
| 864 check( | 820 check(element1, element2, 'isDeferred', element1.isDeferred, |
| 865 element1, element2, 'isDeferred', | 821 element2.isDeferred); |
| 866 element1.isDeferred, element2.isDeferred); | 822 checkElementIdentities(element1, element2, 'deferredImport', |
| 867 checkElementIdentities( | |
| 868 element1, element2, 'deferredImport', | |
| 869 element1.deferredImport, element2.deferredImport); | 823 element1.deferredImport, element2.deferredImport); |
| 870 if (element1.isDeferred) { | 824 if (element1.isDeferred) { |
| 871 checkElementProperties(element1, element2, | 825 checkElementProperties(element1, element2, 'loadLibrary', |
| 872 'loadLibrary', element1.loadLibrary, element2.loadLibrary); | 826 element1.loadLibrary, element2.loadLibrary); |
| 873 } | 827 } |
| 874 element1.forEachLocalMember((Element member1) { | 828 element1.forEachLocalMember((Element member1) { |
| 875 String name = member1.name; | 829 String name = member1.name; |
| 876 Element member2 = element2.lookupLocalMember(name); | 830 Element member2 = element2.lookupLocalMember(name); |
| 877 checkElementIdentities(element1, element2, 'lookupLocalMember:$name', | 831 checkElementIdentities( |
| 878 member1, member2); | 832 element1, element2, 'lookupLocalMember:$name', member1, member2); |
| 879 checkImportsFor(element1, element2, member1, member2); | 833 checkImportsFor(element1, element2, member1, member2); |
| 880 }); | 834 }); |
| 881 } | 835 } |
| 882 | 836 |
| 883 @override | 837 @override |
| 884 void visitErroneousElement( | 838 void visitErroneousElement( |
| 885 ErroneousElement element1, ErroneousElement element2) { | 839 ErroneousElement element1, ErroneousElement element2) { |
| 886 check(element1, element2, 'messageKind', | 840 check(element1, element2, 'messageKind', element1.messageKind, |
| 887 element1.messageKind, element2.messageKind); | 841 element2.messageKind); |
| 888 } | 842 } |
| 889 } | 843 } |
| OLD | NEW |