[FIR-TEST] Add test with type mismatch on receiver with captured type
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
interface ResolvedCall<D : CallableDescriptor> {
|
||||
var d: D
|
||||
}
|
||||
|
||||
interface CallableDescriptor
|
||||
|
||||
fun <D : CallableDescriptor> ResolvedCall<D>.getParameterForArgument(): String = ""
|
||||
|
||||
fun <D : CallableDescriptor> ResolvedCall<D>.updateD(d: D): D {
|
||||
this.d = d
|
||||
return d
|
||||
}
|
||||
|
||||
fun test_1_1(resolvedCall: ResolvedCall<out CallableDescriptor>) {
|
||||
resolvedCall.<!INAPPLICABLE_CANDIDATE!>getParameterForArgument<!>() // should be ok
|
||||
}
|
||||
|
||||
fun test_1_2(resolvedCall: ResolvedCall<in CallableDescriptor>) {
|
||||
resolvedCall.getParameterForArgument() // should be ok
|
||||
}
|
||||
|
||||
fun test_1_3(resolvedCall: ResolvedCall<CallableDescriptor>) {
|
||||
resolvedCall.getParameterForArgument() // should be ok
|
||||
}
|
||||
|
||||
fun test_2_1(resolvedCall: ResolvedCall<out CallableDescriptor>, d: CallableDescriptor) {
|
||||
val x = resolvedCall.<!INAPPLICABLE_CANDIDATE!>updateD<!>(d) // should fail
|
||||
}
|
||||
|
||||
fun test_2_2(resolvedCall: ResolvedCall<in CallableDescriptor>, d: CallableDescriptor) {
|
||||
val x = resolvedCall.updateD(d) // should be ok
|
||||
}
|
||||
|
||||
fun test_2_3(resolvedCall: ResolvedCall<CallableDescriptor>, d: CallableDescriptor) {
|
||||
val x = resolvedCall.updateD(d) // should be ok
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
FILE: receiverWithCapturedType.kt
|
||||
public abstract interface ResolvedCall<D : R|CallableDescriptor|> : R|kotlin/Any| {
|
||||
public abstract var d: R|D|
|
||||
public get(): R|D|
|
||||
public set(value: R|D|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public abstract interface CallableDescriptor : R|kotlin/Any| {
|
||||
}
|
||||
public final fun <D : R|CallableDescriptor|> R|ResolvedCall<D>|.getParameterForArgument(): R|kotlin/String| {
|
||||
^getParameterForArgument String()
|
||||
}
|
||||
public final fun <D : R|CallableDescriptor|> R|ResolvedCall<D>|.updateD(d: R|D|): R|D| {
|
||||
this@R|/updateD|.R|FakeOverride</ResolvedCall.d: R|D|>| = R|<local>/d|
|
||||
^updateD R|<local>/d|
|
||||
}
|
||||
public final fun test_1_1(resolvedCall: R|ResolvedCall<out CallableDescriptor>|): R|kotlin/Unit| {
|
||||
R|<local>/resolvedCall|.<Inapplicable(WRONG_RECEIVER): [/getParameterForArgument]>#()
|
||||
}
|
||||
public final fun test_1_2(resolvedCall: R|ResolvedCall<in CallableDescriptor>|): R|kotlin/Unit| {
|
||||
R|<local>/resolvedCall|.R|/getParameterForArgument|<R|CallableDescriptor|>()
|
||||
}
|
||||
public final fun test_1_3(resolvedCall: R|ResolvedCall<CallableDescriptor>|): R|kotlin/Unit| {
|
||||
R|<local>/resolvedCall|.R|/getParameterForArgument|<R|CallableDescriptor|>()
|
||||
}
|
||||
public final fun test_2_1(resolvedCall: R|ResolvedCall<out CallableDescriptor>|, d: R|CallableDescriptor|): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE REF: Inapplicable(WRONG_RECEIVER): [/updateD]> = R|<local>/resolvedCall|.<Inapplicable(WRONG_RECEIVER): [/updateD]>#(R|<local>/d|)
|
||||
}
|
||||
public final fun test_2_2(resolvedCall: R|ResolvedCall<in CallableDescriptor>|, d: R|CallableDescriptor|): R|kotlin/Unit| {
|
||||
lval x: R|CallableDescriptor| = R|<local>/resolvedCall|.R|/updateD|<R|CallableDescriptor|>(R|<local>/d|)
|
||||
}
|
||||
public final fun test_2_3(resolvedCall: R|ResolvedCall<CallableDescriptor>|, d: R|CallableDescriptor|): R|kotlin/Unit| {
|
||||
lval x: R|CallableDescriptor| = R|<local>/resolvedCall|.R|/updateD|<R|CallableDescriptor|>(R|<local>/d|)
|
||||
}
|
||||
+5
@@ -888,6 +888,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("receiverWithCapturedType.kt")
|
||||
public void testReceiverWithCapturedType() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/receiverWithCapturedType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticsVsNormalProperties.kt")
|
||||
public void testSyntheticsVsNormalProperties() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt");
|
||||
|
||||
Reference in New Issue
Block a user