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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2650763002: Revert "Deprecate the use of `Function` as a class." (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 _checkForConflictingInstanceGetterAndSuperclassMember(); 485 _checkForConflictingInstanceGetterAndSuperclassMember();
486 _checkImplementsSuperClass(node); 486 _checkImplementsSuperClass(node);
487 _checkImplementsFunctionWithoutCall(node); 487 _checkImplementsFunctionWithoutCall(node);
488 _checkForMixinHasNoConstructors(node); 488 _checkForMixinHasNoConstructors(node);
489 } 489 }
490 } 490 }
491 visitClassDeclarationIncrementally(node); 491 visitClassDeclarationIncrementally(node);
492 _checkForFinalNotInitializedInClass(node); 492 _checkForFinalNotInitializedInClass(node);
493 _checkForDuplicateDefinitionInheritance(); 493 _checkForDuplicateDefinitionInheritance();
494 _checkForConflictingInstanceMethodSetter(node); 494 _checkForConflictingInstanceMethodSetter(node);
495 _checkForBadFunctionUse(node);
496 return super.visitClassDeclaration(node); 495 return super.visitClassDeclaration(node);
497 } finally { 496 } finally {
498 _isInNativeClass = false; 497 _isInNativeClass = false;
499 _initialFieldElementsMap = null; 498 _initialFieldElementsMap = null;
500 _enclosingClass = outerClass; 499 _enclosingClass = outerClass;
501 } 500 }
502 } 501 }
503 502
504 /** 503 /**
505 * Implementation of this method should be synchronized with 504 * Implementation of this method should be synchronized with
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 memberHashMap["${name.name}="] = member; 2936 memberHashMap["${name.name}="] = member;
2938 } else { 2937 } else {
2939 memberHashMap[name.name] = member; 2938 memberHashMap[name.name] = member;
2940 } 2939 }
2941 } 2940 }
2942 } 2941 }
2943 } 2942 }
2944 } 2943 }
2945 2944
2946 /** 2945 /**
2947 * Verifies that the class is not named `Function` and that it doesn't
2948 * extends/implements/mixes in `Function`.
2949 */
2950 void _checkForBadFunctionUse(ClassDeclaration node) {
2951 ExtendsClause extendsClause = node.extendsClause;
2952 ImplementsClause implementsClause = node.implementsClause;
2953 WithClause withClause = node.withClause;
2954
2955 if (node.name.name == "Function") {
2956 _errorReporter.reportErrorForNode(
2957 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION, node.name);
2958 }
2959
2960 if (extendsClause != null) {
2961 InterfaceType superclassType = _enclosingClass.supertype;
2962 ClassElement superclassElement = superclassType?.element;
2963 if (superclassElement != null && superclassElement.name == "Function") {
2964 _errorReporter.reportErrorForNode(
2965 HintCode.DEPRECATED_EXTENDS_FUNCTION, extendsClause.superclass);
2966 }
2967 }
2968
2969 if (withClause != null) {
2970 for (TypeName type in withClause.mixinTypes) {
2971 ClassElement mixinElement = type.name.staticElement;
2972 if (mixinElement != null && mixinElement.name == "Function") {
2973 _errorReporter.reportErrorForNode(
2974 HintCode.DEPRECATED_MIXIN_FUNCTION, type);
2975 }
2976 }
2977 }
2978 }
2979
2980 /**
2981 * Verify that the enclosing class does not have an instance member with the 2946 * Verify that the enclosing class does not have an instance member with the
2982 * same name as the given static [method] declaration. 2947 * same name as the given static [method] declaration.
2983 * 2948 *
2984 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]. 2949 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER].
2985 */ 2950 */
2986 void _checkForConflictingStaticGetterAndInstanceSetter( 2951 void _checkForConflictingStaticGetterAndInstanceSetter(
2987 MethodDeclaration method) { 2952 MethodDeclaration method) {
2988 if (!method.isStatic) { 2953 if (!method.isStatic) {
2989 return; 2954 return;
2990 } 2955 }
(...skipping 4103 matching lines...) Expand 10 before | Expand all | Expand 10 after
7094 class _InvocationCollector extends RecursiveAstVisitor { 7059 class _InvocationCollector extends RecursiveAstVisitor {
7095 final List<String> superCalls = <String>[]; 7060 final List<String> superCalls = <String>[];
7096 7061
7097 @override 7062 @override
7098 visitMethodInvocation(MethodInvocation node) { 7063 visitMethodInvocation(MethodInvocation node) {
7099 if (node.target is SuperExpression) { 7064 if (node.target is SuperExpression) {
7100 superCalls.add(node.methodName.name); 7065 superCalls.add(node.methodName.name);
7101 } 7066 }
7102 } 7067 }
7103 } 7068 }
OLDNEW
« 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