K2: Do not add extension receiver's constraint twice for references
The job is already done at CheckExtensionReceiver resolution stage And repeating it might only lead to incorrect errors caused by double-capture of receiver type that leads to contradiction because in previous commit we started assuming different capture instantiations as different types.
This commit is contained in:
committed by
Space Team
parent
2b3f34cc52
commit
9af3e5704d
-8
@@ -70,14 +70,6 @@ internal object CheckCallableReferenceExpectedType : CheckerStage() {
|
||||
) {
|
||||
addSubtypeConstraint(resultingType, expectedType, position)
|
||||
}
|
||||
|
||||
val declarationReceiverType: ConeKotlinType? =
|
||||
fir.receiverParameter?.typeRef?.coneType?.let(candidate.substitutor::substituteOrSelf)
|
||||
|
||||
if (resultingReceiverType != null && declarationReceiverType != null) {
|
||||
val capturedReceiver = context.session.typeContext.captureFromExpression(resultingReceiverType) ?: resultingReceiverType
|
||||
addSubtypeConstraint(capturedReceiver, declarationReceiverType, position)
|
||||
}
|
||||
}
|
||||
|
||||
var isApplicable = true
|
||||
|
||||
+10
-10
@@ -26,15 +26,15 @@ fun Float.bar() {}
|
||||
fun <K> id(x: K) = x
|
||||
|
||||
fun test1() {
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo<*>, CapturedType(*), CapturedType(*)>")!>Foo<*>::setX<!>
|
||||
|
||||
val fooSetRef2 = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Cannot infer argument for type parameter K")!><!INAPPLICABLE_CANDIDATE!>id<!>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef2 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo<*>, kotlin.Nothing, kotlin.Number>")!>id(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo<*>, CapturedType(*), CapturedType(*)>")!>Foo<*>::setX<!>
|
||||
)<!>
|
||||
val foo = Foo<Float>(1f)
|
||||
|
||||
fooSetRef.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, 1)
|
||||
fooSetRef2.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, 1)
|
||||
fooSetRef.invoke(foo, <!ARGUMENT_TYPE_MISMATCH!>1<!>)
|
||||
fooSetRef2.invoke(foo, <!ARGUMENT_TYPE_MISMATCH!>1<!>)
|
||||
|
||||
foo.x.bar()
|
||||
}
|
||||
@@ -53,14 +53,14 @@ fun test2() {
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo2<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef2 = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Cannot infer argument for type parameter K")!><!INAPPLICABLE_CANDIDATE!>id<!>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo2<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo2<*>, CapturedType(*), CapturedType(*)>")!>Foo2<*>::setX<!>
|
||||
val fooSetRef2 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo2<*>, kotlin.Nothing, kotlin.Any?>")!>id(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction2<Foo2<*>, CapturedType(*), CapturedType(*)>")!>Foo2<*>::setX<!>
|
||||
)<!>
|
||||
val foo = Foo2<Int>(1)
|
||||
|
||||
fooSetRef.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, "")
|
||||
fooSetRef2.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, "")
|
||||
fooSetRef.invoke(foo, <!ARGUMENT_TYPE_MISMATCH!>""<!>)
|
||||
fooSetRef2.invoke(foo, <!ARGUMENT_TYPE_MISMATCH!>""<!>)
|
||||
|
||||
foo.x.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>bar<!>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user