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:
+7
-5
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user