Index: lib/compiler/implementation/ssa/builder.dart |
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart |
index 7e4662fa024edf27adba4eeb118a72d8f8962ef6..5f7c6597eb8bf0ad3f98f367c7fb4087173b5b8f 100644 |
--- a/lib/compiler/implementation/ssa/builder.dart |
+++ b/lib/compiler/implementation/ssa/builder.dart |
@@ -1073,7 +1073,12 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
HInstruction potentiallyCheckType(HInstruction original, |
Element sourceElement) { |
if (!compiler.enableTypeAssertions) return original; |
+ return convertType(original, sourceElement, HTypeConversion.CHECKED); |
+ } |
+ HInstruction convertType(HInstruction original, |
+ Element sourceElement, |
+ int kind) { |
Type type = sourceElement.computeType(compiler); |
if (type === null) return original; |
if (type.element === compiler.dynamicClass) return original; |
@@ -1088,7 +1093,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
} |
HInstruction instruction = |
- new HTypeConversion(convertedType, original, true); |
+ new HTypeConversion(convertedType, original, kind); |
add(instruction); |
return instruction; |
} |
@@ -1959,6 +1964,15 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
} |
push(instruction); |
} |
+ } else if (const SourceString("as") == op.source) { |
+ visit(node.receiver); |
+ HInstruction expression = pop(); |
+ Node argument = node.arguments.head; |
+ TypeAnnotation typeAnnotation = argument.asTypeAnnotation(); |
+ Type type = elements.getType(typeAnnotation); |
+ HInstruction converted = |
+ convertType(expression, type.element, HTypeConversion.CAST); |
+ stack.add(converted); |
} else { |
visit(node.receiver); |
visit(node.argumentsNode); |