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

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

Issue 2641213002: Issue 28100. In strong mode verify that TypeParameter bound has required type arguments. (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 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 return super.visitTypeName(node); 1216 return super.visitTypeName(node);
1217 } 1217 }
1218 1218
1219 @override 1219 @override
1220 Object visitTypeParameter(TypeParameter node) { 1220 Object visitTypeParameter(TypeParameter node) {
1221 _checkForBuiltInIdentifierAsName(node.name, 1221 _checkForBuiltInIdentifierAsName(node.name,
1222 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME); 1222 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME);
1223 _checkForTypeParameterSupertypeOfItsBound(node); 1223 _checkForTypeParameterSupertypeOfItsBound(node);
1224 _checkForTypeAnnotationDeferredClass(node.bound); 1224 _checkForTypeAnnotationDeferredClass(node.bound);
1225 _checkForImplicitDynamicType(node.bound); 1225 _checkForImplicitDynamicType(node.bound);
1226 _checkForNotInstantiatedBound(node.bound);
1226 return super.visitTypeParameter(node); 1227 return super.visitTypeParameter(node);
1227 } 1228 }
1228 1229
1229 @override 1230 @override
1230 Object visitTypeParameterList(TypeParameterList node) { 1231 Object visitTypeParameterList(TypeParameterList node) {
1231 _checkDuplicateDefinitionInTypeParameterList(node); 1232 _checkDuplicateDefinitionInTypeParameterList(node);
1232 return super.visitTypeParameterList(node); 1233 return super.visitTypeParameterList(node);
1233 } 1234 }
1234 1235
1235 @override 1236 @override
(...skipping 3953 matching lines...) Expand 10 before | Expand all | Expand 10 after
5189 void _checkForNonVoidReturnTypeForSetter(TypeAnnotation typeName) { 5190 void _checkForNonVoidReturnTypeForSetter(TypeAnnotation typeName) {
5190 if (typeName != null) { 5191 if (typeName != null) {
5191 DartType type = typeName.type; 5192 DartType type = typeName.type;
5192 if (type != null && !type.isVoid) { 5193 if (type != null && !type.isVoid) {
5193 _errorReporter.reportErrorForNode( 5194 _errorReporter.reportErrorForNode(
5194 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, typeName); 5195 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, typeName);
5195 } 5196 }
5196 } 5197 }
5197 } 5198 }
5198 5199
5200 void _checkForNotInstantiatedBound(TypeAnnotation node) {
5201 if (!_options.strongMode ||
5202 node == null ||
5203 (node is TypeName && node.typeArguments != null)) {
5204 return;
5205 }
5206 DartType type = node.type;
5207 if (type is InterfaceType && type.element.typeParameters.isNotEmpty) {
Leaf 2017/01/20 01:43:16 I don't think this handles nested types. This per
scheglov 2017/01/20 15:36:26 ACK. https://codereview.chromium.org/2646983003 wi
5208 _errorReporter.reportErrorForNode(
5209 StrongModeCode.NOT_INSTANTIATED_BOUND, node, [type]);
5210 }
5211 }
5212
5199 /** 5213 /**
5200 * Verify the given operator-method [declaration], does not have an optional 5214 * Verify the given operator-method [declaration], does not have an optional
5201 * parameter. This method assumes that the method declaration was tested to be 5215 * parameter. This method assumes that the method declaration was tested to be
5202 * an operator declaration before being called. 5216 * an operator declaration before being called.
5203 * 5217 *
5204 * See [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]. 5218 * See [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR].
5205 */ 5219 */
5206 void _checkForOptionalParameterInOperator(MethodDeclaration declaration) { 5220 void _checkForOptionalParameterInOperator(MethodDeclaration declaration) {
5207 FormalParameterList parameterList = declaration.parameters; 5221 FormalParameterList parameterList = declaration.parameters;
5208 if (parameterList == null) { 5222 if (parameterList == null) {
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
7038 class _InvocationCollector extends RecursiveAstVisitor { 7052 class _InvocationCollector extends RecursiveAstVisitor {
7039 final List<String> superCalls = <String>[]; 7053 final List<String> superCalls = <String>[];
7040 7054
7041 @override 7055 @override
7042 visitMethodInvocation(MethodInvocation node) { 7056 visitMethodInvocation(MethodInvocation node) {
7043 if (node.target is SuperExpression) { 7057 if (node.target is SuperExpression) {
7044 superCalls.add(node.methodName.name); 7058 superCalls.add(node.methodName.name);
7045 } 7059 }
7046 } 7060 }
7047 } 7061 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/test/generated/resolver_test_case.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698