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

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

Issue 8384012: Make some ErrorCode-s compile-time errors and some just type warnings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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/ResolutionContext.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java b/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
index 06347840027002354d033f0aac19cbd542505763..7ff85abf1502873a3b6c99cbc3dbd7c27c7698e4 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
@@ -109,7 +109,7 @@ public class ResolutionContext implements ResolutionErrorListener {
private boolean isClassType(Type type) {
return isInterfaceEquals(type, false);
}
-
+
/**
* Returns <code>true</code> if the type is a class or interface type.
*/
@@ -123,7 +123,7 @@ public class ResolutionContext implements ResolutionErrorListener {
return null;
}
- Type type = resolveType(node, isStatic);
+ Type type = resolveType(node, isStatic, ResolverErrorCode.NO_SUCH_TYPE_EXTENDS);
if (!isClassType(type)) {
onError(node.getIdentifier(), ResolverErrorCode.NOT_A_CLASS, type);
type = typeProvider.getDynamicType();
@@ -134,12 +134,8 @@ public class ResolutionContext implements ResolutionErrorListener {
}
InterfaceType resolveInterface(DartTypeNode node, boolean isStatic) {
- if (node == null) {
- return null;
- }
-
- Type type = resolveType(node, isStatic);
- if (!isClassOrInterfaceType(type)) {
+ Type type = resolveType(node, isStatic, ResolverErrorCode.NO_SUCH_TYPE_IMPLEMENTS);
+ if (type.getKind() != TypeKind.DYNAMIC && !isClassOrInterfaceType(type)) {
onError(node.getIdentifier(), ResolverErrorCode.NOT_A_CLASS_OR_INTERFACE, type);
type = typeProvider.getDynamicType();
}
@@ -148,16 +144,16 @@ public class ResolutionContext implements ResolutionErrorListener {
return (InterfaceType) type;
}
- Type resolveType(DartTypeNode node, boolean isStatic) {
+ Type resolveType(DartTypeNode node, boolean isStatic, ErrorCode errorCode) {
if (node == null) {
return null;
} else {
- return resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic);
+ return resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic, errorCode);
}
}
Type resolveType(DartNode diagnosticNode, DartNode identifier, List<DartTypeNode> typeArguments,
- boolean isStatic) {
+ boolean isStatic, ErrorCode errorCode) {
Element element = resolveName(identifier);
switch (ElementKind.of(element)) {
case TYPE_VARIABLE: {
@@ -178,13 +174,12 @@ public class ResolutionContext implements ResolutionErrorListener {
if (identifier.toString().equals("void")) {
return typeProvider.getVoidType();
}
+ if (identifier.toString().equals("Dynamic")) {
+ return typeProvider.getDynamicType();
+ }
break;
}
- if (shouldWarnOnNoSuchType()) {
- onError(identifier, TypeErrorCode.NO_SUCH_TYPE, identifier);
- } else {
- onError(identifier, ResolverErrorCode.NO_SUCH_TYPE, identifier);
- }
+ onError(identifier, errorCode, identifier);
return typeProvider.getDynamicType();
}
@@ -204,7 +199,7 @@ public class ResolutionContext implements ResolutionErrorListener {
int index = 0;
if (typeArgumentNodes != null) {
for (DartTypeNode typeNode : typeArgumentNodes) {
- Type type = resolveType(typeNode, isStatic);
+ Type type = resolveType(typeNode, isStatic, TypeErrorCode.NO_SUCH_TYPE_GENERICS_ARGUMENT);
zundel 2011/11/01 13:54:37 Gilad clarified that instantiating a type requires
typeNode.setType(type);
if (index < typeArguments.length) {
typeArguments[index] = type;
@@ -215,7 +210,11 @@ public class ResolutionContext implements ResolutionErrorListener {
} else {
typeArguments = new Type[typeArgumentNodes.size()];
for (int i = 0; i < typeArguments.length; i++) {
- typeArguments[i] = resolveType(typeArgumentNodes.get(i), isStatic);
+ typeArguments[i] =
+ resolveType(
+ typeArgumentNodes.get(i),
+ isStatic,
+ TypeErrorCode.NO_SUCH_TYPE_GENERICS_ARGUMENT);
zundel 2011/11/01 13:54:37 ditto.
typeArgumentNodes.get(i).setType(typeArguments[i]);
}
}

Powered by Google App Engine
This is Rietveld 408576698