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:
Ilmir Usmanov
2022-02-09 04:50:23 +01:00
parent 02cfc8b821
commit 47ee0e5b0a
10 changed files with 73 additions and 2 deletions
@@ -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
}
+17
View File
@@ -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"
}
@@ -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 {
@@ -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 {
@@ -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());
@@ -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 {
@@ -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 {
@@ -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());
@@ -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 {