FIR: use captureFromTypeParameterUpperBoundIfNeeded for argument types
#KT-48161 Fixed
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
FILE: WithSpeedSearch.kt
|
||||
public final class JList<E> : R|kotlin/Any| {
|
||||
public constructor<E>(): R|JList<E>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class ListSpeedSearch<T> : R|kotlin/Any| {
|
||||
public constructor<T>(list: R|JList<T>|): R|ListSpeedSearch<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class XThreadsFramesView : R|kotlin/Any| {
|
||||
public constructor(): R|XThreadsFramesView| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun <J : R|JList<*>|> R|J|.withSpeedSearch(): R|J| {
|
||||
lval search: R|ListSpeedSearch<out kotlin/Any?>| = R|/ListSpeedSearch.ListSpeedSearch|<R|CapturedType(*)|>(this@R|/XThreadsFramesView.withSpeedSearch|)
|
||||
^withSpeedSearch this@R|/XThreadsFramesView.withSpeedSearch|
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class JList<E>
|
||||
|
||||
class ListSpeedSearch<T>(list: JList<T>)
|
||||
|
||||
class XThreadsFramesView {
|
||||
private fun <J> J.withSpeedSearch(): J where J : JList<*> {
|
||||
val search = ListSpeedSearch(this)
|
||||
return this
|
||||
}
|
||||
}
|
||||
+6
@@ -5056,6 +5056,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("WithSpeedSearch.kt")
|
||||
public void testWithSpeedSearch() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/WithSpeedSearch.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -5056,6 +5056,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("WithSpeedSearch.kt")
|
||||
public void testWithSpeedSearch() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/WithSpeedSearch.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.SmartcastStability
|
||||
import org.jetbrains.kotlin.types.model.CaptureStatus
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
@@ -347,7 +346,7 @@ fun isArgumentTypeMismatchDueToNullability(
|
||||
private fun checkApplicabilityForArgumentType(
|
||||
csBuilder: ConstraintSystemBuilder,
|
||||
argument: FirExpression,
|
||||
argumentType: ConeKotlinType,
|
||||
argumentTypeBeforeCapturing: ConeKotlinType,
|
||||
expectedType: ConeKotlinType?,
|
||||
position: SimpleConstraintSystemConstraintPosition,
|
||||
isReceiver: Boolean,
|
||||
@@ -357,6 +356,9 @@ private fun checkApplicabilityForArgumentType(
|
||||
) {
|
||||
if (expectedType == null) return
|
||||
|
||||
// todo run this approximation only once for call
|
||||
val argumentType = captureFromTypeParameterUpperBoundIfNeeded(argumentTypeBeforeCapturing, expectedType, context.session)
|
||||
|
||||
fun subtypeError(actualExpectedType: ConeKotlinType): ResolutionDiagnostic {
|
||||
if (argument.isNullLiteral && actualExpectedType.nullability == ConeNullability.NOT_NULL) {
|
||||
return NullForNotNullType(argument)
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
interface Inv<T>
|
||||
|
||||
fun <Y: X, X : Inv<out String>> foo(x: X, y: Y) {
|
||||
val rX = bar(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
rX.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
val rX = bar(x)
|
||||
rX.length
|
||||
|
||||
val rY = bar(<!ARGUMENT_TYPE_MISMATCH!>y<!>)
|
||||
rY.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
|
||||
+6
@@ -5056,6 +5056,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("WithSpeedSearch.kt")
|
||||
public void testWithSpeedSearch() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/WithSpeedSearch.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user