Add more tests for inline classes
#KT-27416 #KT-27513
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class A(val b: String) {
|
||||
override fun toString(): String =
|
||||
buildString { append(b) }
|
||||
}
|
||||
|
||||
fun box() = A("OK").toString()
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class Z(val int: Int)
|
||||
inline class L(val long: Long)
|
||||
inline class Str(val string: String)
|
||||
inline class Obj(val obj: Any)
|
||||
|
||||
inline class Host(val xx: Int) {
|
||||
inline fun <R> withDefaultZ(fn: (Z) -> R, x: Z = Z(xx)) = fn(x)
|
||||
inline fun <R> withDefaultL(fn: (L) -> R, x: L = L(xx.toLong())) = fn(x)
|
||||
inline fun <R> withDefaultL2(x: L = L(xx.toLong()), fn: (L) -> R) = fn(x)
|
||||
inline fun <R> withDefaultStr(fn: (Str) -> R, x: Str = Str(xx.toString())) = fn(x)
|
||||
inline fun <R> withDefaultObj(fn: (Obj) -> R, x: Obj = Obj(xx.toString())) = fn(x)
|
||||
inline fun <R> withDefaultObj2(x: Obj = Obj(xx.toString()), fn: (Obj) -> R) = fn(x)
|
||||
|
||||
fun testWithDefaultZ() = withDefaultZ({ Z(it.int + 1) })
|
||||
fun testWithDefaultL() = withDefaultL({ L(it.long + 1L) })
|
||||
fun testWithDefaultL2() = withDefaultL2(fn = { L(it.long + 1L) })
|
||||
fun testWithDefaultStr() = withDefaultStr({ Str(it.string + "1") })
|
||||
fun testWithDefaultObj() = withDefaultObj({ Obj(it.obj.toString() + "1") })
|
||||
fun testWithDefaultObj2() = withDefaultObj2(fn = { Obj(it.obj.toString() + "1") })
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val h = Host(42)
|
||||
if (h.testWithDefaultZ().int != 43) throw AssertionError()
|
||||
if (h.testWithDefaultL().long != 43L) throw AssertionError()
|
||||
if (h.testWithDefaultL2().long != 43L) throw AssertionError()
|
||||
if (h.testWithDefaultStr().string != "421") throw AssertionError()
|
||||
if (h.testWithDefaultObj().obj != "421") throw AssertionError()
|
||||
if (h.testWithDefaultObj2().obj != "421") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class A(val i: Int) {
|
||||
fun foo(s: String = "OK") = s
|
||||
}
|
||||
|
||||
fun box() = A(42).foo()
|
||||
+15
@@ -12111,6 +12111,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27513.kt")
|
||||
public void testKt27513() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt27513.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInInlineClassFun.kt")
|
||||
public void testLambdaInInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
|
||||
@@ -12169,6 +12174,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFunInInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassFun.kt")
|
||||
public void testInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/inlineClassFun.kt");
|
||||
@@ -12188,6 +12198,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testKt26554() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt26554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27416.kt")
|
||||
public void testKt27416() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
+15
@@ -12111,6 +12111,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27513.kt")
|
||||
public void testKt27513() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt27513.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInInlineClassFun.kt")
|
||||
public void testLambdaInInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
|
||||
@@ -12169,6 +12174,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFunInInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassFun.kt")
|
||||
public void testInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/inlineClassFun.kt");
|
||||
@@ -12188,6 +12198,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
public void testKt26554() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt26554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27416.kt")
|
||||
public void testKt27416() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
+15
@@ -12116,6 +12116,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27513.kt")
|
||||
public void testKt27513() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt27513.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInInlineClassFun.kt")
|
||||
public void testLambdaInInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
|
||||
@@ -12174,6 +12179,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFunInInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultValueOfInlineClassTypeInInlineFunInInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassFun.kt")
|
||||
public void testInlineClassFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/inlineClassFun.kt");
|
||||
@@ -12193,6 +12203,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
public void testKt26554() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt26554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27416.kt")
|
||||
public void testKt27416() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
Reference in New Issue
Block a user