[NI] Add capturing receiver type for callable references
#KT-30292 Fixed
This commit is contained in:
+3
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.captureFromExpression
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
||||
import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
@@ -142,7 +143,8 @@ private fun ConstraintSystemOperation.addReceiverConstraint(
|
||||
}
|
||||
|
||||
val expectedType = toFreshSubstitutor.safeSubstitute(receiverParameter.value.type.unwrap())
|
||||
val receiverType = receiverArgument.receiver.stableType
|
||||
val receiverType = receiverArgument.receiver.stableType.let { captureFromExpression(it) ?: it }
|
||||
|
||||
addSubtypeConstraint(receiverType, expectedType, position)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
fun test(ls: List<String>) {
|
||||
ls.takeIf(Collection<*>::isNotEmpty)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ ls: kotlin.collections.List<kotlin.String>): kotlin.Unit
|
||||
+5
@@ -2696,6 +2696,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30292.kt")
|
||||
public void testKt30292() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt30292.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3458.kt")
|
||||
public void testKt3458() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -2696,6 +2696,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30292.kt")
|
||||
public void testKt30292() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt30292.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3458.kt")
|
||||
public void testKt3458() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt");
|
||||
|
||||
Reference in New Issue
Block a user