[NI] Fix exception, recorded type for function statement can be null
See `checkStatementType`, we return `null` to reduce count of errors. Also, note that named function which is used as last statement in lambda doesn't coerce to Unit, this is a separate bug and will be addressed later, see #KT-25383 #EA-121026 Fixed
This commit is contained in:
+7
-1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DeprecationResolver
|
||||
@@ -139,7 +140,12 @@ class ResolvedAtomCompleter(
|
||||
?: throw AssertionError("No function descriptor for resolved lambda argument")
|
||||
functionDescriptor.setReturnType(returnType)
|
||||
|
||||
val existingLambdaType = trace.getType(ktArgumentExpression) ?: throw AssertionError("No type for resolved lambda argument")
|
||||
val existingLambdaType = trace.getType(ktArgumentExpression)
|
||||
if (existingLambdaType == null) {
|
||||
if (ktFunction is KtNamedFunction && ktFunction.nameIdentifier != null) return // it's a statement
|
||||
|
||||
throw AssertionError("No type for resolved lambda argument: ${ktArgumentExpression.text}")
|
||||
}
|
||||
val substitutedFunctionalType = createFunctionType(
|
||||
builtIns,
|
||||
existingLambdaType.annotations,
|
||||
|
||||
Reference in New Issue
Block a user