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

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

Issue 8948001: Updates dartc to recognize 'default' keyword on interface and updated factory method syntax (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Feedback from mmendez Created 9 years 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 df9aa182272c2faccabf58ea8f33a8edae91a94c..728dac1a931f1a8b875d17b4bf6c431c5280307f 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
@@ -110,7 +110,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.
*/
@@ -119,12 +119,15 @@ public class ResolutionContext implements ResolutionErrorListener {
&& ((InterfaceType) type).getElement() != null;
}
- InterfaceType resolveClass(DartTypeNode node, boolean isStatic) {
+ /**
+ * To resolve the class<typeparameters?> specified for extends on a class definition.
+ */
+ InterfaceType resolveClass(DartTypeNode node, boolean isStatic, boolean isFactory) {
if (node == null) {
return null;
}
- Type type = resolveType(node, isStatic, ResolverErrorCode.NO_SUCH_TYPE);
+ Type type = resolveType(node, isStatic, isFactory, ResolverErrorCode.NO_SUCH_TYPE);
if (!isClassType(type)) {
onError(node.getIdentifier(), ResolverErrorCode.NOT_A_CLASS, type);
type = typeProvider.getDynamicType();
@@ -134,8 +137,8 @@ public class ResolutionContext implements ResolutionErrorListener {
return (InterfaceType) type;
}
- InterfaceType resolveInterface(DartTypeNode node, boolean isStatic) {
- Type type = resolveType(node, isStatic, ResolverErrorCode.NO_SUCH_TYPE);
+ InterfaceType resolveInterface(DartTypeNode node, boolean isStatic, boolean isFactory) {
+ Type type = resolveType(node, isStatic, isFactory, ResolverErrorCode.NO_SUCH_TYPE);
if (type.getKind() != TypeKind.DYNAMIC && !isClassOrInterfaceType(type)) {
onError(node.getIdentifier(), ResolverErrorCode.NOT_A_CLASS_OR_INTERFACE, type);
type = typeProvider.getDynamicType();
@@ -145,22 +148,23 @@ public class ResolutionContext implements ResolutionErrorListener {
return (InterfaceType) type;
}
- Type resolveType(DartTypeNode node, boolean isStatic, ErrorCode errorCode) {
+ Type resolveType(DartTypeNode node, boolean isStatic, boolean isFactory, ErrorCode errorCode) {
if (node == null) {
return null;
} else {
- return resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic, errorCode);
+ return resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic, isFactory,
+ errorCode);
}
}
Type resolveType(DartNode diagnosticNode, DartNode identifier, List<DartTypeNode> typeArguments,
- boolean isStatic, ErrorCode errorCode) {
+ boolean isStatic, boolean isFactory, ErrorCode errorCode) {
Element element = resolveName(identifier);
ElementKind elementKind = ElementKind.of(element);
switch (elementKind) {
case TYPE_VARIABLE: {
TypeVariableElement typeVariableElement = (TypeVariableElement) element;
- if (isStatic &&
+ if (!isFactory && isStatic &&
typeVariableElement.getDeclaringElement().getKind().equals(ElementKind.CLASS)) {
onError(identifier, ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT,
identifier);
@@ -175,6 +179,7 @@ public class ResolutionContext implements ResolutionErrorListener {
diagnosticNode,
typeArguments,
isStatic,
+ isFactory,
errorCode);
case NONE:
if (identifier.toString().equals("void")) {
@@ -194,6 +199,7 @@ public class ResolutionContext implements ResolutionErrorListener {
InterfaceType instantiateParameterizedType(ClassElement element, DartNode node,
List<DartTypeNode> typeArgumentNodes,
boolean isStatic,
+ boolean isFactory,
ErrorCode errorCode) {
List<? extends Type> typeParameters = element.getTypeParameters();
Type[] typeArguments;
@@ -212,7 +218,7 @@ public class ResolutionContext implements ResolutionErrorListener {
int index = 0;
if (typeArgumentNodes != null) {
for (DartTypeNode typeNode : typeArgumentNodes) {
- Type type = resolveType(typeNode, isStatic, errorCode);
+ Type type = resolveType(typeNode, isStatic, isFactory, errorCode);
typeNode.setType(type);
if (index < typeArguments.length) {
typeArguments[index] = type;
@@ -223,7 +229,7 @@ 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, errorCode);
+ typeArguments[i] = resolveType(typeArgumentNodes.get(i), isStatic, isFactory, errorCode);
typeArgumentNodes.get(i).setType(typeArguments[i]);
}
}
@@ -238,6 +244,9 @@ public class ResolutionContext implements ResolutionErrorListener {
return element.getTypeVariable();
}
+ /*
+ * Interpret this node as a name reference,
+ */
Element resolveName(DartNode node) {
return node.accept(new Selector());
}

Powered by Google App Engine
This is Rietveld 408576698