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`.
This commit is contained in:
Alexander Udalov
2020-04-08 19:21:30 +02:00
parent 9f758b4f25
commit 587cce4a23
@@ -373,11 +373,13 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
if (!resolvedCall.getValueArguments().isEmpty()) return true; if (!resolvedCall.getValueArguments().isEmpty()) return true;
KotlinType callableReferenceType = bindingContext.getType(expression); KotlinType callableReferenceType = bindingContext.getType(expression);
assert callableReferenceType != null : "No type for callable reference: " + expression.getText(); if (callableReferenceType != null) {
KotlinType callableReferenceReturnType = CollectionsKt.last(callableReferenceType.getArguments()).getType(); KotlinType callableReferenceReturnType = CollectionsKt.last(callableReferenceType.getArguments()).getType();
KotlinType functionReturnType = functionDescriptor.getReturnType(); KotlinType functionReturnType = functionDescriptor.getReturnType();
assert functionReturnType != null : "No return type for function: " + functionDescriptor; return functionReturnType != null &&
return KotlinBuiltIns.isUnit(callableReferenceReturnType) && !KotlinBuiltIns.isUnit(functionReturnType); KotlinBuiltIns.isUnit(callableReferenceReturnType) && !KotlinBuiltIns.isUnit(functionReturnType);
}
return false;
} }
@Override @Override