KT-5971 Missing error when fun argument is safe call
#KT-5971 Fixed
This commit is contained in:
@@ -246,7 +246,7 @@ public class CallCompleter(
|
||||
updatedType = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context as ResolutionContext<*>, expression)
|
||||
}
|
||||
|
||||
updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace)
|
||||
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace)
|
||||
|
||||
// While the expected type is not known, the function literal arguments are not analyzed (to analyze function literal bodies once),
|
||||
// but they should be analyzed when the expected type is known (during the call completion).
|
||||
@@ -294,8 +294,8 @@ public class CallCompleter(
|
||||
recordedType: JetType?,
|
||||
argumentExpression: JetExpression,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
if (recordedType == updatedType) return
|
||||
): JetType? {
|
||||
if (recordedType == updatedType || updatedType == null) return updatedType
|
||||
|
||||
fun deparenthesizeOrGetSelector(expression: JetExpression?): JetExpression? {
|
||||
val deparenthesized = JetPsiUtil.deparenthesizeOnce(expression, /* deparenthesizeBinaryExpressionWithTypeRHS = */ false)
|
||||
@@ -315,6 +315,7 @@ public class CallCompleter(
|
||||
BindingContextUtils.updateRecordedType(
|
||||
updatedType, expression, trace, /* shouldBeMadeNullable = */ hasNecessarySafeCall(expression, trace))
|
||||
}
|
||||
return trace[BindingContext.EXPRESSION_TYPE, argumentExpression]
|
||||
}
|
||||
|
||||
private fun hasNecessarySafeCall(expression: JetExpression, trace: BindingTrace): Boolean {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
//KT-5971 Missing error when fun argument is safe call
|
||||
|
||||
fun foo(i: Int) {}
|
||||
|
||||
fun test(s: String?) {
|
||||
foo(<!TYPE_MISMATCH!>s?.length<!>)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
internal fun test(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
@@ -8967,6 +8967,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt5971NestedSafeCall.kt")
|
||||
public void testKt5971NestedSafeCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/resolve/specialConstructions")
|
||||
|
||||
@@ -279,7 +279,7 @@ public class Converter private(val project: Project,
|
||||
annotations,
|
||||
modifiers,
|
||||
typeConverter.convertType(field.getType(), Nullability.NotNull),
|
||||
ExpressionList(convertExpressions(argumentList?.getExpressions())).assignPrototype(argumentList))
|
||||
ExpressionList(convertExpressions(argumentList?.getExpressions() ?: array())).assignPrototype(argumentList))
|
||||
}
|
||||
else {
|
||||
val isVal = isVal(referenceSearcher, field)
|
||||
|
||||
Reference in New Issue
Block a user