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

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

Issue 2639883005: Add parser support for covariant parameters (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
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 732
733 @override 733 @override
734 Object visitForEachStatement(ForEachStatement node) { 734 Object visitForEachStatement(ForEachStatement node) {
735 _checkForInIterable(node); 735 _checkForInIterable(node);
736 return super.visitForEachStatement(node); 736 return super.visitForEachStatement(node);
737 } 737 }
738 738
739 @override 739 @override
740 Object visitFormalParameterList(FormalParameterList node) { 740 Object visitFormalParameterList(FormalParameterList node) {
741 _checkDuplicateDefinitionInParameterList(node); 741 _checkDuplicateDefinitionInParameterList(node);
742 _checkUseOfCovariantInParameters(node);
742 return super.visitFormalParameterList(node); 743 return super.visitFormalParameterList(node);
743 } 744 }
744 745
745 @override 746 @override
746 Object visitForStatement(ForStatement node) { 747 Object visitForStatement(ForStatement node) {
747 if (node.condition != null) { 748 if (node.condition != null) {
748 _checkForNonBoolCondition(node.condition); 749 _checkForNonBoolCondition(node.condition);
749 } 750 }
750 if (node.variables != null) { 751 if (node.variables != null) {
751 _checkDuplicateVariables(node.variables); 752 _checkDuplicateVariables(node.variables);
(...skipping 5411 matching lines...) Expand 10 before | Expand all | Expand 10 after
6163 if (shouldSubstitute) { 6164 if (shouldSubstitute) {
6164 boundType = boundType.substitute2(argumentTypes, parameterTypes); 6165 boundType = boundType.substitute2(argumentTypes, parameterTypes);
6165 } 6166 }
6166 if (!_typeSystem.isSubtypeOf(argType, boundType)) { 6167 if (!_typeSystem.isSubtypeOf(argType, boundType)) {
6167 reportError(argument, argType, boundType); 6168 reportError(argument, argType, boundType);
6168 } 6169 }
6169 } 6170 }
6170 } 6171 }
6171 } 6172 }
6172 6173
6174 void _checkUseOfCovariantInParameters(FormalParameterList node) {
6175 AstNode parent = node.parent;
6176 if (parent is MethodDeclaration && !parent.isStatic) {
6177 return;
6178 }
6179 NodeList<FormalParameter> parameters = node.parameters;
6180 int length = parameters.length;
6181 for (int i = 0; i < length; i++) {
6182 FormalParameter parameter = parameters[i];
6183 Token keyword = parameter.covariantKeyword;
6184 if (keyword != null) {
6185 _errorReporter.reportErrorForToken(
6186 CompileTimeErrorCode.INVALID_USE_OF_COVARIANT, keyword);
6187 }
6188 }
6189 }
6190
6173 DartType _computeReturnTypeForMethod(Expression returnExpression) { 6191 DartType _computeReturnTypeForMethod(Expression returnExpression) {
6174 // This method should never be called for generators, since generators are 6192 // This method should never be called for generators, since generators are
6175 // never allowed to contain return statements with expressions. 6193 // never allowed to contain return statements with expressions.
6176 assert(!_inGenerator); 6194 assert(!_inGenerator);
6177 if (returnExpression == null) { 6195 if (returnExpression == null) {
6178 if (_enclosingFunction.isAsynchronous) { 6196 if (_enclosingFunction.isAsynchronous) {
6179 return _typeProvider.futureNullType; 6197 return _typeProvider.futureNullType;
6180 } else { 6198 } else {
6181 return VoidTypeImpl.instance; 6199 return VoidTypeImpl.instance;
6182 } 6200 }
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
7020 class _InvocationCollector extends RecursiveAstVisitor { 7038 class _InvocationCollector extends RecursiveAstVisitor {
7021 final List<String> superCalls = <String>[]; 7039 final List<String> superCalls = <String>[];
7022 7040
7023 @override 7041 @override
7024 visitMethodInvocation(MethodInvocation node) { 7042 visitMethodInvocation(MethodInvocation node) {
7025 if (node.target is SuperExpression) { 7043 if (node.target is SuperExpression) {
7026 superCalls.add(node.methodName.name); 7044 superCalls.add(node.methodName.name);
7027 } 7045 }
7028 } 7046 }
7029 } 7047 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698