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 analyzer.src.generated.error_verifier; | 5 library analyzer.src.generated.error_verifier; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 ClassElementImpl outerClass = _enclosingClass; | 456 ClassElementImpl outerClass = _enclosingClass; |
| 457 try { | 457 try { |
| 458 _isInNativeClass = node.nativeClause != null; | 458 _isInNativeClass = node.nativeClause != null; |
| 459 _enclosingClass = AbstractClassElementImpl.getImpl(node.element); | 459 _enclosingClass = AbstractClassElementImpl.getImpl(node.element); |
| 460 _checkDuplicateClassMembers(node); | 460 _checkDuplicateClassMembers(node); |
| 461 _checkForBuiltInIdentifierAsName( | 461 _checkForBuiltInIdentifierAsName( |
| 462 node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME); | 462 node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME); |
| 463 _checkForMemberWithClassName(); | 463 _checkForMemberWithClassName(); |
| 464 _checkForNoDefaultSuperConstructorImplicit(node); | 464 _checkForNoDefaultSuperConstructorImplicit(node); |
| 465 _checkForConflictingTypeVariableErrorCodes(node); | 465 _checkForConflictingTypeVariableErrorCodes(node); |
| 466 ExtendsClause extendsClause = node.extendsClause; | 466 TypeName superclass = node.extendsClause?.superclass; |
| 467 ImplementsClause implementsClause = node.implementsClause; | 467 ImplementsClause implementsClause = node.implementsClause; |
| 468 WithClause withClause = node.withClause; | 468 WithClause withClause = node.withClause; |
| 469 | |
| 469 // Only do error checks on the clause nodes if there is a non-null clause | 470 // Only do error checks on the clause nodes if there is a non-null clause |
| 470 if (implementsClause != null || | 471 if (implementsClause != null || |
| 471 extendsClause != null || | 472 superclass != null || |
| 472 withClause != null) { | 473 withClause != null) { |
| 473 // Only check for all of the inheritance logic around clauses if there | 474 _checkClassInheritance(node, superclass, withClause, implementsClause); |
|
Jennifer Messerly
2017/04/24 21:41:02
... a bit of postmortem culture going on here :)
| |
| 474 // isn't an error code such as "Cannot extend double" already on the | |
| 475 // class. | |
| 476 if (!_checkForImplementsDisallowedClass(implementsClause) && | |
| 477 !_checkForExtendsDisallowedClass(extendsClause) && | |
| 478 !_checkForAllMixinErrorCodes(withClause)) { | |
| 479 _checkForExtendsDeferredClass(extendsClause); | |
| 480 _checkForImplementsDeferredClass(implementsClause); | |
| 481 _checkForNonAbstractClassInheritsAbstractMember(node.name); | |
| 482 _checkForInconsistentMethodInheritance(); | |
| 483 _checkForRecursiveInterfaceInheritance(_enclosingClass); | |
| 484 _checkForConflictingGetterAndMethod(); | |
| 485 _checkForConflictingInstanceGetterAndSuperclassMember(); | |
| 486 _checkImplementsSuperClass(node); | |
| 487 _checkImplementsFunctionWithoutCall(node); | |
| 488 _checkForMixinHasNoConstructors(node); | |
| 489 if (_options.strongMode) { | |
| 490 _checkForMixinWithConflictingPrivateMember(node); | |
| 491 } | |
| 492 } | |
| 493 } | 475 } |
| 494 visitClassDeclarationIncrementally(node); | 476 visitClassDeclarationIncrementally(node); |
| 495 _checkForFinalNotInitializedInClass(node); | 477 _checkForFinalNotInitializedInClass(node); |
| 496 _checkForDuplicateDefinitionInheritance(); | 478 _checkForDuplicateDefinitionInheritance(); |
| 497 _checkForConflictingInstanceMethodSetter(node); | 479 _checkForConflictingInstanceMethodSetter(node); |
| 498 _checkForBadFunctionUse(node); | 480 _checkForBadFunctionUse(node); |
| 499 return super.visitClassDeclaration(node); | 481 return super.visitClassDeclaration(node); |
| 500 } finally { | 482 } finally { |
| 501 _isInNativeClass = false; | 483 _isInNativeClass = false; |
| 502 _initialFieldElementsMap = null; | 484 _initialFieldElementsMap = null; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 526 } | 508 } |
| 527 } | 509 } |
| 528 | 510 |
| 529 @override | 511 @override |
| 530 Object visitClassTypeAlias(ClassTypeAlias node) { | 512 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 531 _checkForBuiltInIdentifierAsName( | 513 _checkForBuiltInIdentifierAsName( |
| 532 node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME); | 514 node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME); |
| 533 ClassElementImpl outerClassElement = _enclosingClass; | 515 ClassElementImpl outerClassElement = _enclosingClass; |
| 534 try { | 516 try { |
| 535 _enclosingClass = AbstractClassElementImpl.getImpl(node.element); | 517 _enclosingClass = AbstractClassElementImpl.getImpl(node.element); |
| 536 ImplementsClause implementsClause = node.implementsClause; | 518 _checkClassInheritance( |
| 537 // Only check for all of the inheritance logic around clauses if there | 519 node, node.superclass, node.withClause, node.implementsClause); |
| 538 // isn't an error code such as "Cannot extend double" already on the | |
| 539 // class. | |
| 540 if (!_checkForExtendsDisallowedClassInTypeAlias(node) && | |
| 541 !_checkForImplementsDisallowedClass(implementsClause) && | |
| 542 !_checkForAllMixinErrorCodes(node.withClause)) { | |
| 543 _checkForExtendsDeferredClassInTypeAlias(node); | |
|
Jennifer Messerly
2017/04/24 21:41:02
I also attempted to add tests for all the checks t
| |
| 544 _checkForImplementsDeferredClass(implementsClause); | |
| 545 _checkForRecursiveInterfaceInheritance(_enclosingClass); | |
| 546 _checkForNonAbstractClassInheritsAbstractMember(node.name); | |
| 547 _checkForMixinHasNoConstructors(node); | |
| 548 } | |
| 549 } finally { | 520 } finally { |
| 550 _enclosingClass = outerClassElement; | 521 _enclosingClass = outerClassElement; |
| 551 } | 522 } |
| 552 return super.visitClassTypeAlias(node); | 523 return super.visitClassTypeAlias(node); |
| 553 } | 524 } |
| 554 | 525 |
| 555 @override | 526 @override |
| 556 Object visitComment(Comment node) { | 527 Object visitComment(Comment node) { |
| 557 _isInComment = true; | 528 _isInComment = true; |
| 558 try { | 529 try { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 _checkForReturnOfInvalidType(node.expression, expectedReturnType); | 663 _checkForReturnOfInvalidType(node.expression, expectedReturnType); |
| 693 } | 664 } |
| 694 return super.visitExpressionFunctionBody(node); | 665 return super.visitExpressionFunctionBody(node); |
| 695 } finally { | 666 } finally { |
| 696 _inAsync = wasInAsync; | 667 _inAsync = wasInAsync; |
| 697 _inGenerator = wasInGenerator; | 668 _inGenerator = wasInGenerator; |
| 698 } | 669 } |
| 699 } | 670 } |
| 700 | 671 |
| 701 @override | 672 @override |
| 702 Object visitExtendsClause(ExtendsClause node) { | |
| 703 _checkForImplicitDynamicType(node.superclass); | |
|
Jennifer Messerly
2017/04/24 21:41:02
done in _checkClassInheritance now
| |
| 704 return super.visitExtendsClause(node); | |
| 705 } | |
| 706 | |
| 707 @override | |
| 708 Object visitFieldDeclaration(FieldDeclaration node) { | 673 Object visitFieldDeclaration(FieldDeclaration node) { |
| 709 _isInStaticVariableDeclaration = node.isStatic; | 674 _isInStaticVariableDeclaration = node.isStatic; |
| 710 _isInInstanceVariableDeclaration = !_isInStaticVariableDeclaration; | 675 _isInInstanceVariableDeclaration = !_isInStaticVariableDeclaration; |
| 711 if (_isInInstanceVariableDeclaration) { | 676 if (_isInInstanceVariableDeclaration) { |
| 712 VariableDeclarationList variables = node.fields; | 677 VariableDeclarationList variables = node.fields; |
| 713 if (variables.isConst) { | 678 if (variables.isConst) { |
| 714 _errorReporter.reportErrorForToken( | 679 _errorReporter.reportErrorForToken( |
| 715 CompileTimeErrorCode.CONST_INSTANCE_FIELD, variables.keyword); | 680 CompileTimeErrorCode.CONST_INSTANCE_FIELD, variables.keyword); |
| 716 } | 681 } |
| 717 } | 682 } |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1303 errorCode = CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR; | 1268 errorCode = CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR; |
| 1304 } else { | 1269 } else { |
| 1305 errorCode = CompileTimeErrorCode.YIELD_IN_NON_GENERATOR; | 1270 errorCode = CompileTimeErrorCode.YIELD_IN_NON_GENERATOR; |
| 1306 } | 1271 } |
| 1307 _errorReporter.reportErrorForNode(errorCode, node); | 1272 _errorReporter.reportErrorForNode(errorCode, node); |
| 1308 } | 1273 } |
| 1309 return super.visitYieldStatement(node); | 1274 return super.visitYieldStatement(node); |
| 1310 } | 1275 } |
| 1311 | 1276 |
| 1312 /** | 1277 /** |
| 1278 * Checks the class for problems with the superclass, mixins, or implemented | |
| 1279 * interfaces. | |
| 1280 */ | |
| 1281 void _checkClassInheritance( | |
| 1282 NamedCompilationUnitMember node, | |
| 1283 TypeName superclass, | |
| 1284 WithClause withClause, | |
| 1285 ImplementsClause implementsClause) { | |
| 1286 // Only check for all of the inheritance logic around clauses if there | |
| 1287 // isn't an error code such as "Cannot extend double" already on the | |
| 1288 // class. | |
| 1289 if (!_checkForExtendsDisallowedClass(superclass) && | |
| 1290 !_checkForImplementsDisallowedClass(implementsClause) && | |
| 1291 !_checkForAllMixinErrorCodes(withClause)) { | |
| 1292 _checkForImplicitDynamicType(superclass); | |
| 1293 _checkForExtendsDeferredClass(superclass); | |
| 1294 _checkForImplementsDeferredClass(implementsClause); | |
| 1295 _checkForNonAbstractClassInheritsAbstractMember(node.name); | |
| 1296 _checkForInconsistentMethodInheritance(); | |
| 1297 _checkForRecursiveInterfaceInheritance(_enclosingClass); | |
| 1298 _checkForConflictingGetterAndMethod(); | |
| 1299 _checkForConflictingInstanceGetterAndSuperclassMember(); | |
| 1300 _checkImplementsSuperClass(implementsClause); | |
| 1301 _checkImplementsFunctionWithoutCall(node.name); | |
| 1302 _checkForMixinHasNoConstructors(node); | |
| 1303 | |
| 1304 if (_options.strongMode) { | |
| 1305 _checkForMixinWithConflictingPrivateMember(withClause, superclass); | |
| 1306 } | |
| 1307 } | |
| 1308 } | |
| 1309 | |
| 1310 /** | |
| 1313 * Given a list of [directives] that have the same prefix, generate an error | 1311 * Given a list of [directives] that have the same prefix, generate an error |
| 1314 * if there is more than one import and any of those imports is deferred. | 1312 * if there is more than one import and any of those imports is deferred. |
| 1315 * | 1313 * |
| 1316 * See [CompileTimeErrorCode.SHARED_DEFERRED_PREFIX]. | 1314 * See [CompileTimeErrorCode.SHARED_DEFERRED_PREFIX]. |
| 1317 */ | 1315 */ |
| 1318 void _checkDeferredPrefixCollision(List<ImportDirective> directives) { | 1316 void _checkDeferredPrefixCollision(List<ImportDirective> directives) { |
| 1319 int count = directives.length; | 1317 int count = directives.length; |
| 1320 if (count > 1) { | 1318 if (count > 1) { |
| 1321 for (int i = 0; i < count; i++) { | 1319 for (int i = 0; i < count; i++) { |
| 1322 Token deferredToken = directives[i].deferredKeyword; | 1320 Token deferredToken = directives[i].deferredKeyword; |
| (...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3582 CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, | 3580 CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, |
| 3583 directive, | 3581 directive, |
| 3584 [directive.uri]); | 3582 [directive.uri]); |
| 3585 } | 3583 } |
| 3586 | 3584 |
| 3587 /** | 3585 /** |
| 3588 * Verify that the given extends [clause] does not extend a deferred class. | 3586 * Verify that the given extends [clause] does not extend a deferred class. |
| 3589 * | 3587 * |
| 3590 * See [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]. | 3588 * See [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]. |
| 3591 */ | 3589 */ |
| 3592 void _checkForExtendsDeferredClass(ExtendsClause clause) { | 3590 void _checkForExtendsDeferredClass(TypeName superclass) { |
| 3593 if (clause == null) { | 3591 if (superclass == null) { |
| 3594 return; | 3592 return; |
| 3595 } | 3593 } |
| 3596 _checkForExtendsOrImplementsDeferredClass( | 3594 _checkForExtendsOrImplementsDeferredClass( |
| 3597 clause.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS); | 3595 superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS); |
| 3598 } | 3596 } |
| 3599 | 3597 |
| 3600 /** | 3598 /** |
| 3601 * Verify that the given type [alias] does not extend a deferred class. | |
| 3602 * | |
| 3603 * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]. | |
| 3604 */ | |
| 3605 void _checkForExtendsDeferredClassInTypeAlias(ClassTypeAlias alias) { | |
| 3606 if (alias == null) { | |
| 3607 return; | |
| 3608 } | |
| 3609 _checkForExtendsOrImplementsDeferredClass( | |
| 3610 alias.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS); | |
| 3611 } | |
| 3612 | |
| 3613 /** | |
| 3614 * Verify that the given extends [clause] does not extend classes such as | 3599 * Verify that the given extends [clause] does not extend classes such as |
| 3615 * 'num' or 'String'. | 3600 * 'num' or 'String'. |
| 3616 * | 3601 * |
| 3617 * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]. | 3602 * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]. |
| 3618 */ | 3603 */ |
| 3619 bool _checkForExtendsDisallowedClass(ExtendsClause clause) { | 3604 bool _checkForExtendsDisallowedClass(TypeName superclass) { |
| 3620 if (clause == null) { | 3605 if (superclass == null) { |
| 3621 return false; | 3606 return false; |
| 3622 } | 3607 } |
| 3623 return _checkForExtendsOrImplementsDisallowedClass( | 3608 return _checkForExtendsOrImplementsDisallowedClass( |
| 3624 clause.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS); | 3609 superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS); |
| 3625 } | 3610 } |
| 3626 | 3611 |
| 3627 /** | 3612 /** |
| 3628 * Verify that the given type [alias] does not extend classes such as 'num' or | |
| 3629 * 'String'. | |
| 3630 * | |
| 3631 * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]. | |
| 3632 */ | |
| 3633 bool _checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias alias) { | |
| 3634 if (alias == null) { | |
| 3635 return false; | |
| 3636 } | |
| 3637 return _checkForExtendsOrImplementsDisallowedClass( | |
| 3638 alias.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS); | |
| 3639 } | |
| 3640 | |
| 3641 /** | |
| 3642 * Verify that the given [typeName] does not extend, implement or mixin | 3613 * Verify that the given [typeName] does not extend, implement or mixin |
| 3643 * classes that are deferred. | 3614 * classes that are deferred. |
| 3644 * | 3615 * |
| 3645 * See [_checkForExtendsDeferredClass], | 3616 * See [_checkForExtendsDeferredClass], |
| 3646 * [_checkForExtendsDeferredClassInTypeAlias], | 3617 * [_checkForExtendsDeferredClassInTypeAlias], |
| 3647 * [_checkForImplementsDeferredClass], | 3618 * [_checkForImplementsDeferredClass], |
| 3648 * [_checkForAllMixinErrorCodes], | 3619 * [_checkForAllMixinErrorCodes], |
| 3649 * [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS], | 3620 * [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS], |
| 3650 * [CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS], and | 3621 * [CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS], and |
| 3651 * [CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]. | 3622 * [CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]. |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4889 [mixinElement.name]); | 4860 [mixinElement.name]); |
| 4890 } | 4861 } |
| 4891 return false; | 4862 return false; |
| 4892 } | 4863 } |
| 4893 | 4864 |
| 4894 /** | 4865 /** |
| 4895 * Check for the declaration of a mixin from a library other than the current | 4866 * Check for the declaration of a mixin from a library other than the current |
| 4896 * library that defines a private member that conflicts with a private name | 4867 * library that defines a private member that conflicts with a private name |
| 4897 * from the same library but from a superclass or a different mixin. | 4868 * from the same library but from a superclass or a different mixin. |
| 4898 */ | 4869 */ |
| 4899 void _checkForMixinWithConflictingPrivateMember(ClassDeclaration node) { | 4870 void _checkForMixinWithConflictingPrivateMember( |
| 4900 WithClause withClause = node.withClause; | 4871 WithClause withClause, TypeName superclassName) { |
| 4901 if (withClause == null) { | 4872 if (withClause == null) { |
| 4902 return; | 4873 return; |
| 4903 } | 4874 } |
| 4904 DartType declaredSupertype = node.extendsClause?.superclass?.type; | 4875 DartType declaredSupertype = superclassName?.type; |
| 4905 if (declaredSupertype is! InterfaceType) { | 4876 if (declaredSupertype is! InterfaceType) { |
| 4906 return; | 4877 return; |
| 4907 } | 4878 } |
| 4908 InterfaceType superclass = declaredSupertype; | 4879 InterfaceType superclass = declaredSupertype; |
| 4909 Map<LibraryElement, Map<String, String>> mixedInNames = | 4880 Map<LibraryElement, Map<String, String>> mixedInNames = |
| 4910 <LibraryElement, Map<String, String>>{}; | 4881 <LibraryElement, Map<String, String>>{}; |
| 4911 | 4882 |
| 4912 /** | 4883 /** |
| 4913 * Report an error and return `true` if the given [name] is a private name | 4884 * Report an error and return `true` if the given [name] is a private name |
| 4914 * (which is defined in the given [library]) and it conflicts with another | 4885 * (which is defined in the given [library]) and it conflicts with another |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6187 } | 6158 } |
| 6188 } | 6159 } |
| 6189 } | 6160 } |
| 6190 | 6161 |
| 6191 /** | 6162 /** |
| 6192 * Verify that if the given class [declaration] implements the class Function | 6163 * Verify that if the given class [declaration] implements the class Function |
| 6193 * that it has a concrete implementation of the call method. | 6164 * that it has a concrete implementation of the call method. |
| 6194 * | 6165 * |
| 6195 * See [StaticWarningCode.FUNCTION_WITHOUT_CALL]. | 6166 * See [StaticWarningCode.FUNCTION_WITHOUT_CALL]. |
| 6196 */ | 6167 */ |
| 6197 void _checkImplementsFunctionWithoutCall(ClassDeclaration declaration) { | 6168 void _checkImplementsFunctionWithoutCall(AstNode className) { |
| 6198 if (declaration.isAbstract) { | 6169 ClassElement classElement = _enclosingClass; |
| 6199 return; | |
| 6200 } | |
| 6201 ClassElement classElement = declaration.element; | |
| 6202 if (classElement == null) { | 6170 if (classElement == null) { |
| 6203 return; | 6171 return; |
| 6204 } | 6172 } |
| 6173 if (classElement.isAbstract) { | |
| 6174 return; | |
| 6175 } | |
| 6205 if (!_typeSystem.isSubtypeOf( | 6176 if (!_typeSystem.isSubtypeOf( |
| 6206 classElement.type, _typeProvider.functionType)) { | 6177 classElement.type, _typeProvider.functionType)) { |
| 6207 return; | 6178 return; |
| 6208 } | 6179 } |
| 6209 // If there is a noSuchMethod method, then don't report the warning, | 6180 // If there is a noSuchMethod method, then don't report the warning, |
| 6210 // see dartbug.com/16078 | 6181 // see dartbug.com/16078 |
| 6211 if (_enclosingClass.hasNoSuchMethod) { | 6182 if (_enclosingClass.hasNoSuchMethod) { |
| 6212 return; | 6183 return; |
| 6213 } | 6184 } |
| 6214 ExecutableElement callMethod = _inheritanceManager.lookupMember( | 6185 ExecutableElement callMethod = _inheritanceManager.lookupMember( |
| 6215 classElement, FunctionElement.CALL_METHOD_NAME); | 6186 classElement, FunctionElement.CALL_METHOD_NAME); |
| 6216 if (callMethod == null || | 6187 if (callMethod == null || |
| 6217 callMethod is! MethodElement || | 6188 callMethod is! MethodElement || |
| 6218 (callMethod as MethodElement).isAbstract) { | 6189 (callMethod as MethodElement).isAbstract) { |
| 6219 _errorReporter.reportErrorForNode( | 6190 _errorReporter.reportErrorForNode( |
| 6220 StaticWarningCode.FUNCTION_WITHOUT_CALL, declaration.name); | 6191 StaticWarningCode.FUNCTION_WITHOUT_CALL, className); |
| 6221 } | 6192 } |
| 6222 } | 6193 } |
| 6223 | 6194 |
| 6224 /** | 6195 /** |
| 6225 * Verify that the given class [declaration] does not have the same class in | 6196 * Verify that the given class [declaration] does not have the same class in |
| 6226 * the 'extends' and 'implements' clauses. | 6197 * the 'extends' and 'implements' clauses. |
| 6227 * | 6198 * |
| 6228 * See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]. | 6199 * See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]. |
| 6229 */ | 6200 */ |
| 6230 void _checkImplementsSuperClass(ClassDeclaration declaration) { | 6201 void _checkImplementsSuperClass(ImplementsClause implementsClause) { |
| 6231 // prepare super type | 6202 // prepare super type |
| 6232 InterfaceType superType = _enclosingClass.supertype; | 6203 InterfaceType superType = _enclosingClass.supertype; |
| 6233 if (superType == null) { | 6204 if (superType == null) { |
| 6234 return; | 6205 return; |
| 6235 } | 6206 } |
| 6236 // prepare interfaces | 6207 // prepare interfaces |
| 6237 ImplementsClause implementsClause = declaration.implementsClause; | |
| 6238 if (implementsClause == null) { | 6208 if (implementsClause == null) { |
| 6239 return; | 6209 return; |
| 6240 } | 6210 } |
| 6241 // check interfaces | 6211 // check interfaces |
| 6242 for (TypeName interfaceNode in implementsClause.interfaces) { | 6212 for (TypeName interfaceNode in implementsClause.interfaces) { |
| 6243 if (interfaceNode.type == superType) { | 6213 if (interfaceNode.type == superType) { |
| 6244 _errorReporter.reportErrorForNode( | 6214 _errorReporter.reportErrorForNode( |
| 6245 CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS, | 6215 CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS, |
| 6246 interfaceNode, | 6216 interfaceNode, |
| 6247 [superType.displayName]); | 6217 [superType.displayName]); |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7159 class _InvocationCollector extends RecursiveAstVisitor { | 7129 class _InvocationCollector extends RecursiveAstVisitor { |
| 7160 final List<String> superCalls = <String>[]; | 7130 final List<String> superCalls = <String>[]; |
| 7161 | 7131 |
| 7162 @override | 7132 @override |
| 7163 visitMethodInvocation(MethodInvocation node) { | 7133 visitMethodInvocation(MethodInvocation node) { |
| 7164 if (node.target is SuperExpression) { | 7134 if (node.target is SuperExpression) { |
| 7165 superCalls.add(node.methodName.name); | 7135 superCalls.add(node.methodName.name); |
| 7166 } | 7136 } |
| 7167 } | 7137 } |
| 7168 } | 7138 } |
| OLD | NEW |