FE: Fix null assertion error when left is CollectionLiteral

#KT-49961 fixed
This commit is contained in:
Xin Wang
2022-05-16 22:33:19 +08:00
committed by Victor Petukhov
parent bd299ed12c
commit eb1d7110ec
9 changed files with 59 additions and 1 deletions
@@ -224,6 +224,10 @@ public class ArgumentTypeResolver {
return null;
}
public static boolean isCollectionLiteralArgument(@NotNull KtExpression expression) {
return expression instanceof KtCollectionLiteralExpression;
}
@NotNull
public KotlinTypeInfo getArgumentTypeInfo(
@Nullable KtExpression expression,
@@ -1303,7 +1303,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
KotlinTypeInfo leftTypeInfo = BindingContextUtils.getRecordedTypeInfo(left, context.trace.getBindingContext());
boolean isLeftFunctionLiteral = ArgumentTypeResolver.isFunctionLiteralArgument(left, context);
boolean isLeftCallableReference = ArgumentTypeResolver.isCallableReferenceArgument(left, context);
if (leftTypeInfo == null && (isLeftFunctionLiteral || isLeftCallableReference)) {
boolean isLeftCollectionLiteral = ArgumentTypeResolver.isCollectionLiteralArgument(left);
if (leftTypeInfo == null && (isLeftFunctionLiteral || isLeftCallableReference || isLeftCollectionLiteral)) {
return TypeInfoFactoryKt.noTypeInfo(context);
}
assert leftTypeInfo != null : "Left expression was not processed: " + expression;