From 4870b2e6ba96150c52b5ea1a21e7080694880e89 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 5 Mar 2019 21:30:02 +0300 Subject: [PATCH] Fix asmTypeForAnonymousClassOrNull(): it should not throw an exception if a class name isn't found --- .../jetbrains/kotlin/codegen/binding/CodegenBinding.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java index 9b403e99710..bb8d7705013 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java @@ -116,7 +116,8 @@ public class CodegenBinding { public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull KtElement expression) { Type result = asmTypeForAnonymousClassOrNull(bindingContext, expression); if (result == null) { - throw new IllegalStateException("Type must not be null: " + expression.getText()); + throw new KotlinExceptionWithAttachments("Couldn't compute ASM type for expression") + .withAttachment("expression.kt", PsiUtilsKt.getElementTextWithContext(expression)); } return result; @@ -143,8 +144,7 @@ public class CodegenBinding { return asmTypeForAnonymousClassOrNull(bindingContext, variableDescriptor); } - throw new KotlinExceptionWithAttachments("Couldn't compute ASM type for expression") - .withAttachment("expression.kt", PsiUtilsKt.getElementTextWithContext(expression)); + return null; } @NotNull