Use accessible get/set arguments for collection element receiver
When generating collection element receiver (such as 'a[i]'), accessible descriptor for get/set operator should be used. Otherwise, if the corresponding get/set operator fun is called via an accessor, its argument types may be different in case of generic fun specialized with primitive types. #KT-20387 Fixed
This commit is contained in:
@@ -3914,7 +3914,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
boolean isGetter = OperatorNameConventions.GET.equals(operationDescriptor.getName());
|
||||
|
||||
Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall);
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = isGetter ? resolvedGetCall : resolvedSetCall;
|
||||
assert resolvedCall != null : "No resolved call for " + operationDescriptor;
|
||||
Callable callable = resolveToCallable(accessibleFunctionDescriptor(resolvedCall), false, resolvedCall);
|
||||
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false);
|
||||
Type[] argumentTypes = callableMethod.getParameterTypes();
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: test.kt
|
||||
import base.*
|
||||
|
||||
class Derived : Base<Long>() {
|
||||
inner class Inner {
|
||||
fun foo() = this@Derived[0L]
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Derived().Inner().foo()
|
||||
|
||||
// FILE: Base.kt
|
||||
package base
|
||||
|
||||
open class Base<K> {
|
||||
protected operator fun get(key: K) = "OK"
|
||||
}
|
||||
+6
@@ -12194,6 +12194,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt20387.kt")
|
||||
public void testKt20387() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4152.kt")
|
||||
public void testKt4152() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt");
|
||||
|
||||
@@ -12194,6 +12194,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt20387.kt")
|
||||
public void testKt20387() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4152.kt")
|
||||
public void testKt4152() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt");
|
||||
|
||||
@@ -12194,6 +12194,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt20387.kt")
|
||||
public void testKt20387() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4152.kt")
|
||||
public void testKt4152() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt");
|
||||
|
||||
@@ -13454,6 +13454,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt20387.kt")
|
||||
public void testKt20387() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4152.kt")
|
||||
public void testKt4152() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt");
|
||||
|
||||
Reference in New Issue
Block a user