Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.resolver.error_verifier; | 5 library engine.resolver.error_verifier; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 _intType = _typeProvider.intType; | 264 _intType = _typeProvider.intType; |
| 265 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType>[ | 265 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType>[ |
| 266 _typeProvider.nullType, | 266 _typeProvider.nullType, |
| 267 _typeProvider.numType, | 267 _typeProvider.numType, |
| 268 _intType, | 268 _intType, |
| 269 _typeProvider.doubleType, | 269 _typeProvider.doubleType, |
| 270 _boolType, | 270 _boolType, |
| 271 _typeProvider.stringType]; | 271 _typeProvider.stringType]; |
| 272 } | 272 } |
| 273 | 273 |
| 274 /** | |
| 275 * Initialize this instance with the given [ClassDeclaration]. | |
| 276 */ | |
| 277 void initClassDeclaration(ClassDeclaration node) { | |
| 278 _isInNativeClass = node.nativeClause != null; | |
| 279 _enclosingClass = node.element; | |
| 280 // initialize initialFieldElementsMap | |
| 281 if (_enclosingClass != null) { | |
| 282 List<FieldElement> fieldElements = _enclosingClass.fields; | |
| 283 _initialFieldElementsMap = new HashMap<FieldElement, INIT_STATE>(); | |
| 284 for (FieldElement fieldElement in fieldElements) { | |
| 285 if (!fieldElement.isSynthetic) { | |
| 286 _initialFieldElementsMap[fieldElement] = | |
| 287 fieldElement.initializer == null ? | |
| 288 INIT_STATE.NOT_INIT : | |
| 289 INIT_STATE.INIT_IN_DECLARATION; | |
| 290 } | |
| 291 } | |
| 292 } | |
| 293 } | |
| 294 | |
| 295 @override | 274 @override |
| 296 Object visitAnnotation(Annotation node) { | 275 Object visitAnnotation(Annotation node) { |
| 297 _checkForInvalidAnnotationFromDeferredLibrary(node); | 276 _checkForInvalidAnnotationFromDeferredLibrary(node); |
| 298 return super.visitAnnotation(node); | 277 return super.visitAnnotation(node); |
| 299 } | 278 } |
| 300 | 279 |
| 301 @override | 280 @override |
| 302 Object visitArgumentList(ArgumentList node) { | 281 Object visitArgumentList(ArgumentList node) { |
| 303 _checkForArgumentTypesNotAssignableInList(node); | 282 _checkForArgumentTypesNotAssignableInList(node); |
| 304 return super.visitArgumentList(node); | 283 return super.visitArgumentList(node); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 _checkForImplementsDeferredClass(implementsClause); | 423 _checkForImplementsDeferredClass(implementsClause); |
| 445 _checkForNonAbstractClassInheritsAbstractMember(node.name); | 424 _checkForNonAbstractClassInheritsAbstractMember(node.name); |
| 446 _checkForInconsistentMethodInheritance(); | 425 _checkForInconsistentMethodInheritance(); |
| 447 _checkForRecursiveInterfaceInheritance(_enclosingClass); | 426 _checkForRecursiveInterfaceInheritance(_enclosingClass); |
| 448 _checkForConflictingGetterAndMethod(); | 427 _checkForConflictingGetterAndMethod(); |
| 449 _checkForConflictingInstanceGetterAndSuperclassMember(); | 428 _checkForConflictingInstanceGetterAndSuperclassMember(); |
| 450 _checkImplementsSuperClass(node); | 429 _checkImplementsSuperClass(node); |
| 451 _checkImplementsFunctionWithoutCall(node); | 430 _checkImplementsFunctionWithoutCall(node); |
| 452 } | 431 } |
| 453 } | 432 } |
| 454 initClassDeclaration(node); | 433 _isInNativeClass = node.nativeClause != null; |
|
Brian Wilkerson
2014/11/26 15:30:51
I must be missing something, but... Why did you in
scheglov
2014/11/26 15:56:18
Well, in this class implementations of visitClassD
| |
| 434 _enclosingClass = node.element; | |
| 435 // initialize initialFieldElementsMap | |
| 436 if (_enclosingClass != null) { | |
| 437 List<FieldElement> fieldElements = _enclosingClass.fields; | |
| 438 _initialFieldElementsMap = new HashMap<FieldElement, INIT_STATE>(); | |
| 439 for (FieldElement fieldElement in fieldElements) { | |
| 440 if (!fieldElement.isSynthetic) { | |
| 441 _initialFieldElementsMap[fieldElement] = | |
| 442 fieldElement.initializer == null ? | |
| 443 INIT_STATE.NOT_INIT : | |
| 444 INIT_STATE.INIT_IN_DECLARATION; | |
| 445 } | |
| 446 } | |
| 447 } | |
| 455 _checkForFinalNotInitializedInClass(node); | 448 _checkForFinalNotInitializedInClass(node); |
| 456 _checkForDuplicateDefinitionInheritance(); | 449 _checkForDuplicateDefinitionInheritance(); |
| 457 _checkForConflictingInstanceMethodSetter(node); | 450 _checkForConflictingInstanceMethodSetter(node); |
| 458 return super.visitClassDeclaration(node); | 451 return super.visitClassDeclaration(node); |
| 459 } finally { | 452 } finally { |
| 460 _isInNativeClass = false; | 453 _isInNativeClass = false; |
| 461 _initialFieldElementsMap = null; | 454 _initialFieldElementsMap = null; |
| 462 _enclosingClass = outerClass; | 455 _enclosingClass = outerClass; |
| 463 } | 456 } |
| 464 } | 457 } |
| 465 | 458 |
| 459 /** | |
| 460 * Implementation of this method should be synchronized with | |
| 461 * [visitClassDeclaration]. | |
| 462 */ | |
| 463 visitClassDeclarationIncrementally(ClassDeclaration node) { | |
| 464 _isInNativeClass = node.nativeClause != null; | |
| 465 _enclosingClass = node.element; | |
| 466 // initialize initialFieldElementsMap | |
| 467 if (_enclosingClass != null) { | |
| 468 List<FieldElement> fieldElements = _enclosingClass.fields; | |
| 469 _initialFieldElementsMap = new HashMap<FieldElement, INIT_STATE>(); | |
| 470 for (FieldElement fieldElement in fieldElements) { | |
| 471 if (!fieldElement.isSynthetic) { | |
| 472 _initialFieldElementsMap[fieldElement] = | |
| 473 fieldElement.initializer == null ? | |
| 474 INIT_STATE.NOT_INIT : | |
| 475 INIT_STATE.INIT_IN_DECLARATION; | |
| 476 } | |
| 477 } | |
| 478 } | |
| 479 } | |
| 480 | |
| 466 @override | 481 @override |
| 467 Object visitClassTypeAlias(ClassTypeAlias node) { | 482 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 468 _checkForBuiltInIdentifierAsName( | 483 _checkForBuiltInIdentifierAsName( |
| 469 node.name, | 484 node.name, |
| 470 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME); | 485 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME); |
| 471 ClassElement outerClassElement = _enclosingClass; | 486 ClassElement outerClassElement = _enclosingClass; |
| 472 try { | 487 try { |
| 473 _enclosingClass = node.element; | 488 _enclosingClass = node.element; |
| 474 ImplementsClause implementsClause = node.implementsClause; | 489 ImplementsClause implementsClause = node.implementsClause; |
| 475 // Only check for all of the inheritance logic around clauses if there | 490 // Only check for all of the inheritance logic around clauses if there |
| (...skipping 5748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6224 toCheck.add(type.element); | 6239 toCheck.add(type.element); |
| 6225 // type arguments | 6240 // type arguments |
| 6226 if (type is InterfaceType) { | 6241 if (type is InterfaceType) { |
| 6227 InterfaceType interfaceType = type; | 6242 InterfaceType interfaceType = type; |
| 6228 for (DartType typeArgument in interfaceType.typeArguments) { | 6243 for (DartType typeArgument in interfaceType.typeArguments) { |
| 6229 _addTypeToCheck(typeArgument); | 6244 _addTypeToCheck(typeArgument); |
| 6230 } | 6245 } |
| 6231 } | 6246 } |
| 6232 } | 6247 } |
| 6233 } | 6248 } |
| OLD | NEW |