Issue 3251. Fixes for node type
http://code.google.com/p/dart/issues/detail?id=3251 R=brianwilkerson@google.com BUG= TEST= Review URL: https://chromiumcodereview.appspot.com//10449038 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8064 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -1,24 +1,11 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
/**
|
||||
* Abstract base class for Dart literal values.
|
||||
*/
|
||||
public abstract class DartLiteral extends DartExpression {
|
||||
private Type type;
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package com.google.dart.compiler.ast;
|
||||
import com.google.dart.compiler.common.AbstractNode;
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.type.Type;
|
||||
import com.google.dart.compiler.type.Types;
|
||||
import com.google.dart.compiler.util.DefaultTextOutput;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,10 +15,8 @@ import java.util.List;
|
||||
* Base class for all Dart AST nodes.
|
||||
*/
|
||||
public abstract class DartNode extends AbstractNode {
|
||||
private static final Type dynamicType = Types.newDynamicType();
|
||||
|
||||
private DartNode parent;
|
||||
private Type type = dynamicType;
|
||||
private Type type;
|
||||
|
||||
public final String toSource() {
|
||||
DefaultTextOutput out = new DefaultTextOutput(false);
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DartParameterizedTypeNode extends DartExpression {
|
||||
private DartExpression expression;
|
||||
private final NodeList<DartTypeParameter> typeParameters = NodeList.create(this);
|
||||
private Type type;
|
||||
|
||||
public DartParameterizedTypeNode(DartExpression expression, List<DartTypeParameter> typeParameters) {
|
||||
setExpression(expression);
|
||||
@@ -27,11 +24,6 @@ public class DartParameterizedTypeNode extends DartExpression {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<DartTypeParameter> getTypeParameters() {
|
||||
return typeParameters;
|
||||
}
|
||||
@@ -40,11 +32,6 @@ public class DartParameterizedTypeNode extends DartExpression {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitChildren(ASTVisitor<?> visitor) {
|
||||
getExpression().accept(visitor);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@@ -6,7 +6,6 @@ package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.resolver.NodeElement;
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
/**
|
||||
* Represents a Dart property access expression (a.b).
|
||||
@@ -15,7 +14,6 @@ public class DartPropertyAccess extends DartExpression {
|
||||
|
||||
private DartNode qualifier;
|
||||
private DartIdentifier name;
|
||||
private Type type;
|
||||
|
||||
public DartPropertyAccess(DartNode qualifier, DartIdentifier name) {
|
||||
this.qualifier = becomeParentOf(qualifier);
|
||||
@@ -53,16 +51,6 @@ public class DartPropertyAccess extends DartExpression {
|
||||
return name.getElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitChildren(ASTVisitor<?> visitor) {
|
||||
qualifier.accept(visitor);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,7 +13,6 @@ public class DartTypeNode extends DartNode {
|
||||
|
||||
private DartNode identifier;
|
||||
private NodeList<DartTypeNode> typeArguments = NodeList.create(this);
|
||||
private Type type;
|
||||
|
||||
public DartTypeNode(DartNode identifier) {
|
||||
this(identifier, null);
|
||||
@@ -34,16 +31,6 @@ public class DartTypeNode extends DartNode {
|
||||
return typeArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitChildren(ASTVisitor<?> visitor) {
|
||||
identifier.accept(visitor);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
/**
|
||||
* Represents a type parameter in a class or interface declaration.
|
||||
@@ -13,7 +12,6 @@ import com.google.dart.compiler.type.Type;
|
||||
public class DartTypeParameter extends DartDeclaration<DartIdentifier> {
|
||||
|
||||
private DartTypeNode bound;
|
||||
private Type type;
|
||||
|
||||
public DartTypeParameter(DartIdentifier name, DartTypeNode bound) {
|
||||
super(name);
|
||||
@@ -36,16 +34,6 @@ public class DartTypeParameter extends DartDeclaration<DartIdentifier> {
|
||||
public <R> R accept(ASTVisitor<R> visitor) {
|
||||
return visitor.visitTypeParameter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getElement() {
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler.ast;
|
||||
|
||||
import com.google.dart.compiler.type.InterfaceType;
|
||||
import com.google.dart.compiler.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DartTypedLiteral extends DartExpression {
|
||||
private final boolean isConst;
|
||||
private final NodeList<DartTypeNode> typeArguments = NodeList.create(this);
|
||||
private InterfaceType type;
|
||||
|
||||
DartTypedLiteral(boolean isConst, List<DartTypeNode> typeArguments) {
|
||||
this.isConst = isConst;
|
||||
@@ -27,14 +25,9 @@ public abstract class DartTypedLiteral extends DartExpression {
|
||||
return typeArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
this.type = (InterfaceType) type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceType getType() {
|
||||
return type;
|
||||
return (InterfaceType) super.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1237,6 +1237,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
||||
|
||||
@Override
|
||||
public Type visitIdentifier(DartIdentifier node) {
|
||||
if (node.getType() != null) {
|
||||
return node.getType();
|
||||
}
|
||||
Element element = node.getElement();
|
||||
Type type;
|
||||
switch (ElementKind.of(element)) {
|
||||
@@ -1579,10 +1582,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
||||
|
||||
@Override
|
||||
public Type visitPropertyAccess(DartPropertyAccess node) {
|
||||
Element element = node.getElement();
|
||||
if (node.getType() != null) {
|
||||
return node.getType();
|
||||
}
|
||||
Element element = node.getElement();
|
||||
if (element != null) {
|
||||
return element.getType();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user