diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index fb8f34b2523..d75ab1ddf36 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -205,7 +205,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetType targetType, ExpressionTypingContext context ) { - if (actualType == null || noExpectedType(targetType)) return; + if (actualType == null || noExpectedType(targetType) || targetType.isError()) return; if (TypesPackage.isDynamic(targetType)) { JetTypeReference right = expression.getRight(); diff --git a/compiler/testData/diagnostics/tests/Casts.kt b/compiler/testData/diagnostics/tests/Casts.kt index 3811dfe4cfa..ce582bc9006 100644 --- a/compiler/testData/diagnostics/tests/Casts.kt +++ b/compiler/testData/diagnostics/tests/Casts.kt @@ -13,4 +13,6 @@ fun test() : Unit { x as? Int? : Int? y as? Int? : Int? Unit + + x as UnresolvedType }