Minor. Add tests and comment about copying generic parameters to

constructor, but not function reference to the constructor.

 #KT-32162
This commit is contained in:
Ilmir Usmanov
2022-01-31 06:21:59 +01:00
parent 84ccf412cb
commit 00a08fc6a4
16 changed files with 364 additions and 0 deletions
@@ -23442,6 +23442,30 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -302,6 +302,9 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
val replacement = context.inlineClassReplacements.getReplacementFunction(function)
?: return super.visitFunctionReference(expression)
// In case of callable reference to inline class constructor,
// type parameters of the replacement include class's type parameters,
// however, expression does not. Thus, we should not include them either.
return IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset, expression.type,
replacement.symbol, function.typeParameters.size,
@@ -0,0 +1,6 @@
// CHECK_BYTECODE_LISTING
// LANGUAGE: -JvmInlineValueClasses, +GenericInlineClassParameter
inline class ICIntArray<T: Int>(val value: Array<T>)
fun box(): String = if (ICIntArray(arrayOf(1)).value[0] == 1) "OK" else "FAIL"
@@ -0,0 +1,24 @@
@kotlin.Metadata
public final class ArrayKt {
// source: 'array.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICIntArray {
// source: 'array.kt'
private final @org.jetbrains.annotations.NotNull field value: java.lang.Integer[]
private synthetic method <init>(p0: java.lang.Integer[]): void
public synthetic final static method box-impl(p0: java.lang.Integer[]): ICIntArray
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.Integer[]): java.lang.Integer[]
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: java.lang.Integer[], p1: java.lang.Object): boolean
public final static method equals-impl0(p0: java.lang.Integer[], p1: java.lang.Integer[]): boolean
public final @org.jetbrains.annotations.NotNull method getValue(): java.lang.Integer[]
public method hashCode(): int
public static method hashCode-impl(p0: java.lang.Integer[]): int
public method toString(): java.lang.String
public static method toString-impl(p0: java.lang.Integer[]): java.lang.String
public synthetic final method unbox-impl(): java.lang.Integer[]
}
@@ -0,0 +1,13 @@
// CHECK_BYTECODE_LISTING
// LANGUAGE: -JvmInlineValueClasses, +GenericInlineClassParameter
// IGNORE_BACKEND: JVM
inline class ICStr(val value: String)
inline class ICIStr<T : ICStr>(val value: T)
inline class ICIStrArray<T : ICStr>(val value: Array<T>)
fun box(): String {
val res = ICIStrArray(arrayOf(ICStr("OK"))).value[0].value
if (res != "OK") return res
return ICIStr(ICStr("OK")).value.value
}
@@ -0,0 +1,62 @@
@kotlin.Metadata
public final class ArrayICKt {
// source: 'arrayIC.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICIStr {
// source: 'arrayIC.kt'
private final @org.jetbrains.annotations.NotNull field value: java.lang.String
private synthetic method <init>(p0: java.lang.String): void
public synthetic final static method box-impl(p0: java.lang.String): ICIStr
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean
public final @org.jetbrains.annotations.NotNull method getValue-GZl9MeU(): java.lang.String
public method hashCode(): int
public static method hashCode-impl(p0: java.lang.String): int
public method toString(): java.lang.String
public static method toString-impl(p0: java.lang.String): java.lang.String
public synthetic final method unbox-impl(): java.lang.String
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICIStrArray {
// source: 'arrayIC.kt'
private final @org.jetbrains.annotations.NotNull field value: ICStr[]
private synthetic method <init>(p0: ICStr[]): void
public synthetic final static method box-impl(p0: ICStr[]): ICIStrArray
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: ICStr[]): ICStr[]
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: ICStr[], p1: java.lang.Object): boolean
public final static method equals-impl0(p0: ICStr[], p1: ICStr[]): boolean
public final @org.jetbrains.annotations.NotNull method getValue(): ICStr[]
public method hashCode(): int
public static method hashCode-impl(p0: ICStr[]): int
public method toString(): java.lang.String
public static method toString-impl(p0: ICStr[]): java.lang.String
public synthetic final method unbox-impl(): ICStr[]
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICStr {
// source: 'arrayIC.kt'
private final @org.jetbrains.annotations.NotNull field value: java.lang.String
private synthetic method <init>(p0: java.lang.String): void
public synthetic final static method box-impl(p0: java.lang.String): ICStr
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean
public final @org.jetbrains.annotations.NotNull method getValue(): java.lang.String
public method hashCode(): int
public static method hashCode-impl(p0: java.lang.String): int
public method toString(): java.lang.String
public static method toString-impl(p0: java.lang.String): java.lang.String
public synthetic final method unbox-impl(): java.lang.String
}
@@ -0,0 +1,15 @@
// CHECK_BYTECODE_LISTING
// LANGUAGE: -JvmInlineValueClasses, +GenericInlineClassParameter
// IGNORE_BACKEND: JVM
inline class ICInt<T: Int>(val value: T)
inline class ICIcInt<T: ICInt<Int>>(val value: T)
fun box(): String {
var res = ICInt(1).value
if (res != 1) return "FAIL 1: $res"
res = ICIcInt(ICInt(1)).value.value
if (res != 1) return "FAIL 2: $res"
return "OK"
}
@@ -0,0 +1,43 @@
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICIcInt {
// source: 'primitive.kt'
private final field value: int
private synthetic method <init>(p0: int): void
public synthetic final static method box-impl(p0: int): ICIcInt
public static method constructor-impl(p0: int): int
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: int, p1: int): boolean
public final method getValue-F6dIzHg(): int
public method hashCode(): int
public static method hashCode-impl(p0: int): int
public method toString(): java.lang.String
public static method toString-impl(p0: int): java.lang.String
public synthetic final method unbox-impl(): int
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class ICInt {
// source: 'primitive.kt'
private final field value: int
private synthetic method <init>(p0: int): void
public synthetic final static method box-impl(p0: int): ICInt
public static method constructor-impl(p0: int): int
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: int, p1: int): boolean
public final method getValue(): int
public method hashCode(): int
public static method hashCode-impl(p0: int): int
public method toString(): java.lang.String
public static method toString-impl(p0: int): java.lang.String
public synthetic final method unbox-impl(): int
}
@kotlin.Metadata
public final class PrimitiveKt {
// source: 'primitive.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -0,0 +1,14 @@
// LANGUAGE: -JvmInlineValueClasses, +GenericInlineClassParameter
// IGNORE_BACKED: JVM
inline class ICAny<T>(val value: T)
fun box(): String {
var res = ICAny("OK").value
if (res != "OK") return "FAIL 1: $res"
res = ICAny(ICAny("OK")).value.value
if (res != "OK") return "FAIL 2: $res"
res = ICAny(ICAny(ICAny("OK"))).value.value.value
if (res != "OK") return "FAIL 3: $res"
return "OK"
}
@@ -23016,6 +23016,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -23442,6 +23442,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -19242,6 +19242,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class GenericUnderlyingValue extends AbstractLightAnalysisModeTest {
@TestMetadata("arrayIC.kt")
public void ignoreArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@TestMetadata("primitive.kt")
public void ignorePrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -19250,6 +19260,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/simple.kt");
@@ -18434,6 +18434,30 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -18398,6 +18398,30 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -15564,6 +15564,26 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/simple.kt");
@@ -20609,6 +20609,30 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/array.kt");
}
@Test
@TestMetadata("arrayIC.kt")
public void testArrayIC() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/arrayIC.kt");
}
@Test
@TestMetadata("primitive.kt")
public void testPrimitive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/primitive.kt");
}
@Test
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/genericUnderlyingValue/recursive.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {