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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 10536031: Fix for issue 3401: Implement casts in Analyzer (Closed) Base URL: http://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/type/TypeAnalyzer.java
===================================================================
--- compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java (revision 8336)
+++ compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java (working copy)
@@ -424,6 +424,9 @@
nonVoidTypeOf(rhsNode);
return boolType;
+ case AS:
+ return typeOf(rhsNode);
+
case IS:
if (rhsNode instanceof DartUnaryExpression) {
assert ((DartUnaryExpression) rhsNode).getOperator() == Token.NOT;
@@ -525,14 +528,14 @@
@Override
public Void visitBinaryExpression(DartBinaryExpression node) {
// don't infer type if condition negated
- if (!negation && node.getOperator() == Token.IS) {
+ if (!negation && (node.getOperator() == Token.IS || node.getOperator() == Token.AS)) {
DartExpression arg1 = node.getArg1();
DartExpression arg2 = node.getArg2();
if (arg1 instanceof DartIdentifier && arg1.getElement() instanceof VariableElement
&& arg2 instanceof DartTypeExpression) {
VariableElement variableElement = (VariableElement) arg1.getElement();
- Type isType = arg2.getType();
- Type varType = Types.makeInferred(isType);
+ Type rhsType = arg2.getType();
+ Type varType = Types.makeInferred(rhsType);
variableRestorer.setType(variableElement, varType);
}
}

Powered by Google App Engine
This is Rietveld 408576698