Add accessor tests: inline class <-> companion

KT-26858 was fixed somewhere in the middle.

 #KT26858
This commit is contained in:
Dmitry Petrov
2018-09-24 14:24:24 +03:00
parent 850d72f13f
commit bffe9e45e8
11 changed files with 236 additions and 0 deletions
@@ -0,0 +1,12 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class R(private val r: Int) {
fun test() = ok()
companion object {
private fun ok() = "OK"
}
}
fun box() = R(0).test()
@@ -0,0 +1,12 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class R(private val r: Long) {
fun test() = ok()
companion object {
private fun ok() = "OK"
}
}
fun box() = R(0).test()
@@ -0,0 +1,12 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class R(private val r: Int) {
private fun ok() = "OK"
companion object {
fun test(r: R) = r.ok()
}
}
fun box() = R.test(R(0))
@@ -0,0 +1,12 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class R(private val r: Long) {
private fun ok() = "OK"
companion object {
fun test(r: R) = r.ok()
}
}
fun box() = R.test(R(0))
@@ -0,0 +1,14 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JS, JS_IR, JVM_IR
// WITH_RUNTIME
inline class R(private val r: Int) {
fun test() = ok()
companion object {
@JvmStatic
private fun ok() = "OK"
}
}
fun box() = R(0).test()
@@ -0,0 +1,24 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class Direction(private val direction: Int) {
fun dx() = dx[direction]
fun dy() = dy[direction]
companion object {
private val dx = intArrayOf(0, 1, 0, -1)
private val dy = intArrayOf(-1, 0, 1, 0)
}
}
fun box(): String {
val dirs = arrayOf(Direction(0), Direction(1), Direction(2), Direction(3))
val expectedDx = intArrayOf(0, 1, 0, -1)
val expectedDy = intArrayOf(-1, 0, 1, 0)
for (i in 0 .. 3) {
if (dirs[i].dx() != expectedDx[i]) throw AssertionError()
if (dirs[i].dy() != expectedDy[i]) throw AssertionError()
}
return "OK"
}
@@ -11932,6 +11932,26 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@TestMetadata("accessPrivateInlineClassCompanionMethod.kt")
public void testAccessPrivateInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt");
}
@TestMetadata("accessPrivateInlineClassCompanionMethod2.kt")
public void testAccessPrivateInlineClassCompanionMethod2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion.kt")
public void testAccessPrivateInlineClassMethodFromCompanion() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion2.kt")
public void testAccessPrivateInlineClassMethodFromCompanion2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromInlineLambda.kt")
public void testAccessPrivateInlineClassMethodFromInlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromInlineLambda.kt");
@@ -11952,6 +11972,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt");
}
@TestMetadata("accessPrivateStaticInlineClassCompanionMethod.kt")
public void testAccessPrivateStaticInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt");
}
public void testAllFilesPresentInContextsAndAccessors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@@ -11976,6 +12001,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/inlineLambdaInInlineClassFun.kt");
}
@TestMetadata("kt26858.kt")
public void testKt26858() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
}
@TestMetadata("lambdaInInlineClassFun.kt")
public void testLambdaInInlineClassFun() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
@@ -11932,6 +11932,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@TestMetadata("accessPrivateInlineClassCompanionMethod.kt")
public void testAccessPrivateInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt");
}
@TestMetadata("accessPrivateInlineClassCompanionMethod2.kt")
public void testAccessPrivateInlineClassCompanionMethod2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion.kt")
public void testAccessPrivateInlineClassMethodFromCompanion() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion2.kt")
public void testAccessPrivateInlineClassMethodFromCompanion2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromInlineLambda.kt")
public void testAccessPrivateInlineClassMethodFromInlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromInlineLambda.kt");
@@ -11952,6 +11972,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt");
}
@TestMetadata("accessPrivateStaticInlineClassCompanionMethod.kt")
public void testAccessPrivateStaticInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt");
}
public void testAllFilesPresentInContextsAndAccessors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@@ -11976,6 +12001,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/inlineLambdaInInlineClassFun.kt");
}
@TestMetadata("kt26858.kt")
public void testKt26858() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
}
@TestMetadata("lambdaInInlineClassFun.kt")
public void testLambdaInInlineClassFun() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
@@ -11937,6 +11937,26 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
@TestMetadata("accessPrivateInlineClassCompanionMethod.kt")
public void testAccessPrivateInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt");
}
@TestMetadata("accessPrivateInlineClassCompanionMethod2.kt")
public void testAccessPrivateInlineClassCompanionMethod2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion.kt")
public void testAccessPrivateInlineClassMethodFromCompanion() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion2.kt")
public void testAccessPrivateInlineClassMethodFromCompanion2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromInlineLambda.kt")
public void testAccessPrivateInlineClassMethodFromInlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromInlineLambda.kt");
@@ -11957,6 +11977,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt");
}
@TestMetadata("accessPrivateStaticInlineClassCompanionMethod.kt")
public void testAccessPrivateStaticInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt");
}
public void testAllFilesPresentInContextsAndAccessors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@@ -11981,6 +12006,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/inlineLambdaInInlineClassFun.kt");
}
@TestMetadata("kt26858.kt")
public void testKt26858() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
}
@TestMetadata("lambdaInInlineClassFun.kt")
public void testLambdaInInlineClassFun() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
@@ -10472,6 +10472,26 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
@TestMetadata("accessPrivateInlineClassCompanionMethod.kt")
public void testAccessPrivateInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt");
}
@TestMetadata("accessPrivateInlineClassCompanionMethod2.kt")
public void testAccessPrivateInlineClassCompanionMethod2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion.kt")
public void testAccessPrivateInlineClassMethodFromCompanion() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion2.kt")
public void testAccessPrivateInlineClassMethodFromCompanion2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromInlineLambda.kt")
public void testAccessPrivateInlineClassMethodFromInlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromInlineLambda.kt");
@@ -10492,6 +10512,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt");
}
@TestMetadata("accessPrivateStaticInlineClassCompanionMethod.kt")
public void testAccessPrivateStaticInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt");
}
public void testAllFilesPresentInContextsAndAccessors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@@ -10516,6 +10541,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/inlineLambdaInInlineClassFun.kt");
}
@TestMetadata("kt26858.kt")
public void testKt26858() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
}
@TestMetadata("lambdaInInlineClassFun.kt")
public void testLambdaInInlineClassFun() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");
@@ -11517,6 +11517,26 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
@TestMetadata("accessPrivateInlineClassCompanionMethod.kt")
public void testAccessPrivateInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt");
}
@TestMetadata("accessPrivateInlineClassCompanionMethod2.kt")
public void testAccessPrivateInlineClassCompanionMethod2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion.kt")
public void testAccessPrivateInlineClassMethodFromCompanion() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromCompanion2.kt")
public void testAccessPrivateInlineClassMethodFromCompanion2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromCompanion2.kt");
}
@TestMetadata("accessPrivateInlineClassMethodFromInlineLambda.kt")
public void testAccessPrivateInlineClassMethodFromInlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromInlineLambda.kt");
@@ -11537,6 +11557,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt");
}
@TestMetadata("accessPrivateStaticInlineClassCompanionMethod.kt")
public void testAccessPrivateStaticInlineClassCompanionMethod() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt");
}
public void testAllFilesPresentInContextsAndAccessors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@@ -11561,6 +11586,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/inlineLambdaInInlineClassFun.kt");
}
@TestMetadata("kt26858.kt")
public void testKt26858() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt");
}
@TestMetadata("lambdaInInlineClassFun.kt")
public void testLambdaInInlineClassFun() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/lambdaInInlineClassFun.kt");