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

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

Issue 10979013: Issue 5292. Unreferenced imported identifiers should not be an error (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 ccf31a6d00d39b916d42724e8f7bb56910eca3f8..d556533a32f0934a2d6266ed7c56f47c718da16e 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -427,6 +427,7 @@ public class Resolver {
boundNode,
false,
false,
+ false,
ResolverErrorCode.NO_SUCH_TYPE,
ResolverErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
boundNode.setType(bound);
@@ -695,7 +696,7 @@ public class Resolver {
{
DartTypeNode rcTypeName = node.getRedirectedTypeName();
if (rcTypeName != null) {
- InterfaceType rcType = (InterfaceType) resolveType(rcTypeName, true, true,
+ InterfaceType rcType = (InterfaceType) resolveType(rcTypeName, true, true, false,
TypeErrorCode.NO_SUCH_TYPE, ResolverErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
switch (TypeKind.of(rcType)) {
case INTERFACE:
@@ -828,6 +829,7 @@ public class Resolver {
node.getTypeNode(),
inStaticContext(currentMethod),
inFactoryContext(currentMethod),
+ true,
TypeErrorCode.NO_SUCH_TYPE,
TypeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
for (DartVariable variable : node.getVariables()) {
@@ -1215,6 +1217,12 @@ public class Resolver {
case TYPE_VARIABLE:
onError(x, ResolverErrorCode.CANNOT_USE_TYPE_VARIABLE, name);
break;
+ case DUPLICATE:
+ DuplicateElement duplicateElement = (DuplicateElement) element;
+ List<String> locations = duplicateElement.getLocations();
+ onError(x, ResolverErrorCode.DUPLICATE_IMPORTED_NAME, element.getName(),
+ locations.size(), locations);
+ return null;
}
}
@@ -1301,7 +1309,7 @@ public class Resolver {
}
}
// do Type resolve
- return resolveType(x, inStaticContext(currentMethod), inFactoryContext(currentMethod),
+ return resolveType(x, inStaticContext(currentMethod), inFactoryContext(currentMethod), false,
errorCode, wrongNumberErrorCode).getElement();
}
@@ -1433,6 +1441,13 @@ public class Resolver {
default:
break;
}
+ if (ElementKind.of(element) == ElementKind.DUPLICATE) {
+ DuplicateElement duplicateElement = (DuplicateElement) element;
+ List<String> locations = duplicateElement.getLocations();
+ onError(x.getName(), ResolverErrorCode.DUPLICATE_IMPORTED_NAME, duplicateElement.getName(),
+ locations.size(), locations);
+ return null;
+ }
return recordElement(x, element);
}
@@ -1536,7 +1551,13 @@ public class Resolver {
element = scope.findElement(scope.getLibrary(), "setter " + x.getTarget().getName());
}
ElementKind kind = ElementKind.of(element);
- if (!INVOKABLE_ELEMENTS.contains(kind)) {
+ if (kind == ElementKind.DUPLICATE) {
+ DuplicateElement duplicateElement = (DuplicateElement) element;
+ List<String> locations = duplicateElement.getLocations();
+ onError(x.getTarget(), ResolverErrorCode.DUPLICATE_IMPORTED_NAME, element.getName(),
+ locations.size(), locations);
+ return null;
+ } else if (!INVOKABLE_ELEMENTS.contains(kind)) {
diagnoseErrorInUnqualifiedInvocation(x);
} else {
checkInvocationTarget(x, currentMethod, element);
@@ -1573,6 +1594,7 @@ public class Resolver {
ErrorCode errorCode = x.isConst() ? ResolverErrorCode.NO_SUCH_TYPE_CONST : TypeErrorCode.NO_SUCH_TYPE;
return recordType(type, resolveType(type, inStaticContext(currentMethod),
inFactoryContext(currentMethod),
+ false,
errorCode,
ResolverErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS));
}

Powered by Google App Engine
This is Rietveld 408576698