Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2643073002: Deprecate the use of `Function` as a class. (Closed)
Patch Set: Update type. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/error/hint_codes.dart ('k') | pkg/analyzer/test/generated/hint_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2b8d90492de54a499480e95d0e835d5c9125879e..346da5a6c23f5e2fcfded2096a5c41cfc90fb89c 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;
@@ -2943,6 +2944,40 @@ 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.superclass);
+ }
+ }
+
+ if (withClause != null) {
+ for (TypeName type in withClause.mixinTypes) {
+ Element 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.
*
« no previous file with comments | « pkg/analyzer/lib/src/dart/error/hint_codes.dart ('k') | pkg/analyzer/test/generated/hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698