| 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);
|
| }
|
| }
|
|
|