Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/error_verifier.dart |
| diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart |
| index b2db829d977544fd6fcaa331d311cfc69ba8b6b6..c3180dc137f97eddedcd9fd688d7a1ff5319eb7d 100644 |
| --- a/pkg/analyzer/lib/src/generated/error_verifier.dart |
| +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart |
| @@ -492,6 +492,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> { |
| _checkForFinalNotInitializedInClass(node); |
| _checkForDuplicateDefinitionInheritance(); |
| _checkForConflictingInstanceMethodSetter(node); |
| + _checkForBadFunctionUse(node); |
| return super.visitClassDeclaration(node); |
| } finally { |
| _isInNativeClass = false; |
| @@ -2941,6 +2942,50 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> { |
| } |
| /** |
| + * Verifies that the class is not named `Function` and that it doesn't |
| + * extends/implements/mixes in `Function`. |
| + */ |
| + void _checkForBadFunctionUse(ClassDeclaration node) { |
| + ExtendsClause extendsClause = node.extendsClause; |
| + ImplementsClause implementsClause = node.implementsClause; |
| + WithClause withClause = node.withClause; |
| + |
| + if (node.name.name == "Function") { |
| + _errorReporter.reportErrorForNode( |
| + HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION, node.name); |
| + } |
| + |
| + if (extendsClause != null) { |
| + InterfaceType superclassType = _enclosingClass.supertype; |
| + ClassElement superclassElement = superclassType?.element; |
| + if (superclassElement != null && superclassElement.name == "Function") { |
| + _errorReporter.reportErrorForNode( |
| + HintCode.DEPRECATED_EXTENDS_FUNCTION, extendsClause); |
|
Brian Wilkerson
2017/01/19 18:16:05
'extendsClause' --> 'extendsClause.superclass'
floitsch
2017/01/19 18:22:49
Done.
|
| + } |
| + } |
| + |
| + if (implementsClause != null) { |
| + for (TypeName type in implementsClause.interfaces) { |
| + ClassElement implementsElement = type.name.staticElement; |
| + if (implementsElement != null && implementsElement.name == "Function") { |
| + _errorReporter.reportErrorForNode( |
| + HintCode.DEPRECATED_IMPLEMENTS_FUNCTION, type); |
| + } |
| + } |
| + } |
| + |
| + if (withClause != null) { |
| + for (TypeName type in withClause.mixinTypes) { |
| + ClassElement mixinElement = type.name.staticElement; |
| + if (mixinElement != null && mixinElement.name == "Function") { |
| + _errorReporter.reportErrorForNode( |
| + HintCode.DEPRECATED_MIXIN_FUNCTION, type); |
| + } |
| + } |
| + } |
| + } |
| + |
| + /** |
| * Verify that the enclosing class does not have an instance member with the |
| * same name as the given static [method] declaration. |
| * |