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

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

Issue 2188403002: Revert "fix #26141, add support for type arguments to constants" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 ConstructorName constructorName = node.constructorName; 861 ConstructorName constructorName = node.constructorName;
862 TypeName typeName = constructorName.type; 862 TypeName typeName = constructorName.type;
863 DartType type = typeName.type; 863 DartType type = typeName.type;
864 if (type is InterfaceType) { 864 if (type is InterfaceType) {
865 _checkForConstOrNewWithAbstractClass(node, typeName, type); 865 _checkForConstOrNewWithAbstractClass(node, typeName, type);
866 _checkForConstOrNewWithEnum(node, typeName, type); 866 _checkForConstOrNewWithEnum(node, typeName, type);
867 if (_isInConstInstanceCreation) { 867 if (_isInConstInstanceCreation) {
868 _checkForConstWithNonConst(node); 868 _checkForConstWithNonConst(node);
869 _checkForConstWithUndefinedConstructor( 869 _checkForConstWithUndefinedConstructor(
870 node, constructorName, typeName); 870 node, constructorName, typeName);
871 if (!_options.strongMode) { 871 _checkForConstWithTypeParameters(typeName);
872 _checkForConstWithTypeParameters(typeName);
873 }
874 _checkForConstDeferredClass(node, constructorName, typeName); 872 _checkForConstDeferredClass(node, constructorName, typeName);
875 } else { 873 } else {
876 _checkForNewWithUndefinedConstructor(node, constructorName, typeName); 874 _checkForNewWithUndefinedConstructor(node, constructorName, typeName);
877 } 875 }
878 } 876 }
879 _checkForImplicitDynamicType(typeName); 877 _checkForImplicitDynamicType(typeName);
880 return super.visitInstanceCreationExpression(node); 878 return super.visitInstanceCreationExpression(node);
881 } finally { 879 } finally {
882 _isInConstInstanceCreation = wasInConstInstanceCreation; 880 _isInConstInstanceCreation = wasInConstInstanceCreation;
883 } 881 }
884 } 882 }
885 883
886 @override 884 @override
887 Object visitIsExpression(IsExpression node) { 885 Object visitIsExpression(IsExpression node) {
888 _checkForTypeAnnotationDeferredClass(node.type); 886 _checkForTypeAnnotationDeferredClass(node.type);
889 return super.visitIsExpression(node); 887 return super.visitIsExpression(node);
890 } 888 }
891 889
892 @override 890 @override
893 Object visitListLiteral(ListLiteral node) { 891 Object visitListLiteral(ListLiteral node) {
894 TypeArgumentList typeArguments = node.typeArguments; 892 TypeArgumentList typeArguments = node.typeArguments;
895 if (typeArguments != null) { 893 if (typeArguments != null) {
896 if (!_options.strongMode && node.constKeyword != null) { 894 if (node.constKeyword != null) {
897 NodeList<TypeName> arguments = typeArguments.arguments; 895 NodeList<TypeName> arguments = typeArguments.arguments;
898 if (arguments.isNotEmpty) { 896 if (arguments.length != 0) {
899 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, 897 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments,
900 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST); 898 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST);
901 } 899 }
902 } 900 }
903 _checkForExpectedOneListTypeArgument(node, typeArguments); 901 _checkForExpectedOneListTypeArgument(node, typeArguments);
904 } 902 }
905 _checkForImplicitDynamicTypedLiteral(node); 903 _checkForImplicitDynamicTypedLiteral(node);
906 _checkForListElementTypeNotAssignable(node); 904 _checkForListElementTypeNotAssignable(node);
907 return super.visitListLiteral(node); 905 return super.visitListLiteral(node);
908 } 906 }
909 907
910 @override 908 @override
911 Object visitMapLiteral(MapLiteral node) { 909 Object visitMapLiteral(MapLiteral node) {
912 TypeArgumentList typeArguments = node.typeArguments; 910 TypeArgumentList typeArguments = node.typeArguments;
913 if (typeArguments != null) { 911 if (typeArguments != null) {
914 NodeList<TypeName> arguments = typeArguments.arguments; 912 NodeList<TypeName> arguments = typeArguments.arguments;
915 if (!_options.strongMode && arguments.isNotEmpty) { 913 if (arguments.length != 0) {
916 if (node.constKeyword != null) { 914 if (node.constKeyword != null) {
917 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, 915 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments,
918 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP); 916 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP);
919 } 917 }
920 } 918 }
921 _checkExpectedTwoMapTypeArguments(typeArguments); 919 _checkExpectedTwoMapTypeArguments(typeArguments);
922 } 920 }
923 _checkForImplicitDynamicTypedLiteral(node); 921 _checkForImplicitDynamicTypedLiteral(node);
924 _checkForMapTypeNotAssignable(node); 922 _checkForMapTypeNotAssignable(node);
925 _checkForNonConstMapAsExpressionStatement(node); 923 _checkForNonConstMapAsExpressionStatement(node);
(...skipping 5531 matching lines...) Expand 10 before | Expand all | Expand 10 after
6457 class _InvocationCollector extends RecursiveAstVisitor { 6455 class _InvocationCollector extends RecursiveAstVisitor {
6458 final List<String> superCalls = <String>[]; 6456 final List<String> superCalls = <String>[];
6459 6457
6460 @override 6458 @override
6461 visitMethodInvocation(MethodInvocation node) { 6459 visitMethodInvocation(MethodInvocation node) {
6462 if (node.target is SuperExpression) { 6460 if (node.target is SuperExpression) {
6463 superCalls.add(node.methodName.name); 6461 superCalls.add(node.methodName.name);
6464 } 6462 }
6465 } 6463 }
6466 } 6464 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/value.dart ('k') | pkg/analyzer/test/src/dart/constant/evaluation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698