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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10574024: Issue 2379. Can't use type variable with const constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index c2dc5ac5801446f873fd7960e82b140a898476a1..34dc319f31b878f4b088404db256c5ee4ae657c1 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -1314,11 +1314,23 @@ public class Resolver {
// try to lookup the constructor in the default class.
constructor = resolveInterfaceConstructorInDefaultClass(x.getConstructor(), constructor);
- // Check for using "const" to non-const constructor.
+ // Check constructor.
if (constructor != null) {
- if (x.isConst() && !constructor.getModifiers().isConstant()) {
+ boolean constConstructor = constructor.getModifiers().isConstant();
+ // Check for using "const" to non-const constructor.
+ if (x.isConst() && !constConstructor) {
onError(x, ResolverErrorCode.CONST_AND_NONCONST_CONSTRUCTOR);
}
+ // Check for using "const" with type variables as type arguments.
+ if (x.isConst() && constConstructor) {
+ DartTypeNode typeNode = Types.constructorTypeNode(x);
+ List<DartTypeNode> typeArguments = typeNode.getTypeArguments();
+ for (DartTypeNode typeArgument : typeArguments) {
+ if (typeArgument.getType() instanceof TypeVariable) {
+ onError(typeArgument, ResolverErrorCode.CONST_WITH_TYPE_VARIABLE);
+ }
+ }
+ }
}
return recordElement(x, constructor);

Powered by Google App Engine
This is Rietveld 408576698