From 587cce4a23dd4a16c36dee112d9dd56bcd7a6cb7 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 8 Apr 2020 19:21:30 +0200 Subject: [PATCH] Avoid asserts in CodegenAnnotatingVisitor.isAdaptedCallableReference In light classes mode, binding context may not have all the information and this can fail, as for example was happening in the test `diagnostics/tests/regressions/ea76264.kt`. --- .../codegen/binding/CodegenAnnotatingVisitor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index 282035414cf..168f5b38e88 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -373,11 +373,13 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { if (!resolvedCall.getValueArguments().isEmpty()) return true; KotlinType callableReferenceType = bindingContext.getType(expression); - assert callableReferenceType != null : "No type for callable reference: " + expression.getText(); - KotlinType callableReferenceReturnType = CollectionsKt.last(callableReferenceType.getArguments()).getType(); - KotlinType functionReturnType = functionDescriptor.getReturnType(); - assert functionReturnType != null : "No return type for function: " + functionDescriptor; - return KotlinBuiltIns.isUnit(callableReferenceReturnType) && !KotlinBuiltIns.isUnit(functionReturnType); + if (callableReferenceType != null) { + KotlinType callableReferenceReturnType = CollectionsKt.last(callableReferenceType.getArguments()).getType(); + KotlinType functionReturnType = functionDescriptor.getReturnType(); + return functionReturnType != null && + KotlinBuiltIns.isUnit(callableReferenceReturnType) && !KotlinBuiltIns.isUnit(functionReturnType); + } + return false; } @Override