Get type arguments from supertype in supercall
Otherwise, when the function has inline class parameter, we get ICE. We do not get the error without inline class parameter, since we substitute type parameters in limited situations, which includes inline class lowering. #KT-51157 Fixed
This commit is contained in:
+6
@@ -20419,6 +20419,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt48993.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
@@ -509,7 +509,15 @@ val IrFunction.allTypeParameters: List<IrTypeParameter>
|
||||
|
||||
fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameterSymbol, IrType> {
|
||||
val typeParameters = irFunction.allTypeParameters
|
||||
val dispatchReceiverTypeArguments = (dispatchReceiver?.type as? IrSimpleType)?.arguments ?: emptyList()
|
||||
|
||||
val superQualifierSymbol = (this as? IrCallImpl)?.superQualifierSymbol
|
||||
|
||||
val receiverType =
|
||||
if (superQualifierSymbol != null) superQualifierSymbol.defaultType as? IrSimpleType
|
||||
else dispatchReceiver?.type as? IrSimpleType
|
||||
|
||||
val dispatchReceiverTypeArguments = receiverType?.arguments ?: emptyList()
|
||||
|
||||
if (typeParameters.isEmpty() && dispatchReceiverTypeArguments.isEmpty()) {
|
||||
return emptyMap()
|
||||
}
|
||||
@@ -526,7 +534,7 @@ fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction):
|
||||
} else {
|
||||
extractTypeParameters(irFunction.parentClassOrNull!!)
|
||||
}
|
||||
parentTypeParameters.withIndex().forEach { (index, typeParam) ->
|
||||
for ((index, typeParam) in parentTypeParameters.withIndex()) {
|
||||
dispatchReceiverTypeArguments[index].typeOrNull?.let {
|
||||
result[typeParam.symbol] = it
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface ByteArrayParser<Output> : GenericParser<ByteArray, Output> {
|
||||
override fun repExactly(n: UInt): ByteArrayParser<List<Output>> =
|
||||
super.repExactly(n) as ByteArrayParser<List<Output>>
|
||||
}
|
||||
|
||||
interface GenericParser<Input, Output> {
|
||||
fun repExactly(n: UInt): GenericParser<Input, List<Output>> {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val parser = object : ByteArrayParser<String> {}
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -19999,6 +19999,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt48993.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+6
@@ -20419,6 +20419,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt48993.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+5
@@ -16655,6 +16655,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt48993.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||
}
|
||||
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||
|
||||
+6
@@ -15699,6 +15699,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt47762.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+6
@@ -15663,6 +15663,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt47762.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+5
@@ -13197,6 +13197,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt47762.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||
}
|
||||
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||
|
||||
Generated
+6
@@ -17028,6 +17028,12 @@ public class ExternalTestGenerated extends AbstractExternalNativeBlackBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt47762.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51157.kt")
|
||||
public void testKt51157() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt51157.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user