KT-13735 NoSuchMethodError for generic typealias acces
Use underlying constructor descriptor for type alias constructor code generation.
This commit is contained in:
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.coroutines.CoroutineUtilKt;
|
|||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
|
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||||
|
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils;
|
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils;
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||||
@@ -2725,6 +2726,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
@NotNull
|
@NotNull
|
||||||
protected FunctionDescriptor accessibleFunctionDescriptor(@NotNull ResolvedCall<?> resolvedCall) {
|
protected FunctionDescriptor accessibleFunctionDescriptor(@NotNull ResolvedCall<?> resolvedCall) {
|
||||||
FunctionDescriptor descriptor = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
FunctionDescriptor descriptor = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
||||||
|
if (descriptor instanceof TypeAliasConstructorDescriptor) {
|
||||||
|
descriptor = ((TypeAliasConstructorDescriptor) descriptor).getUnderlyingConstructorDescriptor();
|
||||||
|
}
|
||||||
FunctionDescriptor originalIfSamAdapter = SamCodegenUtil.getOriginalIfSamAdapter(descriptor);
|
FunctionDescriptor originalIfSamAdapter = SamCodegenUtil.getOriginalIfSamAdapter(descriptor);
|
||||||
if (originalIfSamAdapter != null) {
|
if (originalIfSamAdapter != null) {
|
||||||
descriptor = originalIfSamAdapter;
|
descriptor = originalIfSamAdapter;
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class Cell<T>(val x: T)
|
||||||
|
|
||||||
|
typealias StringCell = Cell<String>
|
||||||
|
|
||||||
|
fun box(): String =
|
||||||
|
StringCell("O").x + Cell("K").x
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class Outer private constructor(public val x: String) {
|
||||||
|
class Nested {
|
||||||
|
fun foo() = OuterAlias("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias OuterAlias = Outer
|
||||||
|
|
||||||
|
fun box(): String =
|
||||||
|
Outer.Nested().foo().x
|
||||||
@@ -15532,6 +15532,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericTypeAliasConstructor.kt")
|
||||||
|
public void testGenericTypeAliasConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("localTypeAlias.kt")
|
@TestMetadata("localTypeAlias.kt")
|
||||||
public void testLocalTypeAlias() throws Exception {
|
public void testLocalTypeAlias() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/localTypeAlias.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/localTypeAlias.kt");
|
||||||
@@ -15550,6 +15556,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeAliasConstructorAccessor.kt")
|
||||||
|
public void testTypeAliasConstructorAccessor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasConstructorAccessor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("typeAliasObject.kt")
|
@TestMetadata("typeAliasObject.kt")
|
||||||
public void testTypeAliasObject() throws Exception {
|
public void testTypeAliasObject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasObject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasObject.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user