From 73ca75cc0b175ad9b3ad64f155867bee1463192b Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 4 Nov 2014 17:29:27 +0400 Subject: [PATCH] Fixed wrong constructor arguments order --- .../inline/AnonymousObjectGeneration.java | 2 +- .../codegen/boxInline/reified/packages.1.kt | 14 ++++++++++++++ .../codegen/boxInline/reified/packages.2.kt | 19 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 17 ++++++++++++++++- ...otlinAgainstInlineKotlinTestGenerated.java | 17 ++++++++++++++++- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/reified/packages.1.kt create mode 100644 compiler/testData/codegen/boxInline/reified/packages.2.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/inline/AnonymousObjectGeneration.java b/compiler/backend/src/org/jetbrains/jet/codegen/inline/AnonymousObjectGeneration.java index 8fa4f665dc8..6caa2a77cfe 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/inline/AnonymousObjectGeneration.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/inline/AnonymousObjectGeneration.java @@ -73,7 +73,7 @@ public class AnonymousObjectGeneration { boolean isStaticOrigin ) { this( - ownerInternalName, isSameModule, needReification, + ownerInternalName, needReification, isSameModule, new HashMap(), false, alreadyRegenerated, null, isStaticOrigin ); } diff --git a/compiler/testData/codegen/boxInline/reified/packages.1.kt b/compiler/testData/codegen/boxInline/reified/packages.1.kt new file mode 100644 index 00000000000..fc7d111bcd2 --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/packages.1.kt @@ -0,0 +1,14 @@ +import test.* + +fun box(): String { + val x = foo1().javaClass.getGenericSuperclass()?.toString() + if (x != "test.A") return "fail 1: " + x + + if (!foo2("abc")) return "fail 2" + if (foo2("abc")) return "fail 3" + + if (!foo3("abc", "cde")) return "fail 4" + if (foo3("abc", 1)) return "fail 5" + + return "OK" +} diff --git a/compiler/testData/codegen/boxInline/reified/packages.2.kt b/compiler/testData/codegen/boxInline/reified/packages.2.kt new file mode 100644 index 00000000000..e2533d10075 --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/packages.2.kt @@ -0,0 +1,19 @@ +package test + +public abstract class A + +inline fun foo1(): A { + return object : A() { + + } +} + +fun bar(x: T, block: (T) -> Boolean): Boolean = block(x) + +inline fun foo2(x: Any): Boolean { + return bar(x) { it is T } +} + +inline fun foo3(x: Any, y: Any): Boolean { + return bar(x) { it is T && y is T } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxInlineCodegenTestGenerated.java index 70473eb5c88..376b1290f5a 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxInlineCodegenTestGenerated.java @@ -30,7 +30,7 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @TestMetadata("compiler/testData/codegen/boxInline") @TestDataPath("$PROJECT_ROOT") -@InnerTestClasses({BlackBoxInlineCodegenTestGenerated.AnonymousObject.class, BlackBoxInlineCodegenTestGenerated.Builders.class, BlackBoxInlineCodegenTestGenerated.Capture.class, BlackBoxInlineCodegenTestGenerated.Complex.class, BlackBoxInlineCodegenTestGenerated.DefaultValues.class, BlackBoxInlineCodegenTestGenerated.LambdaClassClash.class, BlackBoxInlineCodegenTestGenerated.LambdaTransformation.class, BlackBoxInlineCodegenTestGenerated.LocalFunInLambda.class, BlackBoxInlineCodegenTestGenerated.NoInline.class, BlackBoxInlineCodegenTestGenerated.NonLocalReturns.class, BlackBoxInlineCodegenTestGenerated.Simple.class, BlackBoxInlineCodegenTestGenerated.Special.class, BlackBoxInlineCodegenTestGenerated.Trait.class, BlackBoxInlineCodegenTestGenerated.TryCatchFinally.class}) +@InnerTestClasses({BlackBoxInlineCodegenTestGenerated.AnonymousObject.class, BlackBoxInlineCodegenTestGenerated.Builders.class, BlackBoxInlineCodegenTestGenerated.Capture.class, BlackBoxInlineCodegenTestGenerated.Complex.class, BlackBoxInlineCodegenTestGenerated.DefaultValues.class, BlackBoxInlineCodegenTestGenerated.LambdaClassClash.class, BlackBoxInlineCodegenTestGenerated.LambdaTransformation.class, BlackBoxInlineCodegenTestGenerated.LocalFunInLambda.class, BlackBoxInlineCodegenTestGenerated.NoInline.class, BlackBoxInlineCodegenTestGenerated.NonLocalReturns.class, BlackBoxInlineCodegenTestGenerated.Reified.class, BlackBoxInlineCodegenTestGenerated.Simple.class, BlackBoxInlineCodegenTestGenerated.Special.class, BlackBoxInlineCodegenTestGenerated.Trait.class, BlackBoxInlineCodegenTestGenerated.TryCatchFinally.class}) @RunWith(JUnit3RunnerWithInners.class) public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInBoxInline() throws Exception { @@ -606,6 +606,21 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxCodegenT } } + @TestMetadata("compiler/testData/codegen/boxInline/reified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Reified extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInReified() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/reified"), Pattern.compile("^(.+)\\.1.kt$"), true); + } + + @TestMetadata("packages.1.kt") + public void testPackages() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/packages.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/simple") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java index f1b8fc2d335..fa0253bc5f7 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -30,7 +30,7 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @TestMetadata("compiler/testData/codegen/boxInline") @TestDataPath("$PROJECT_ROOT") -@InnerTestClasses({CompileKotlinAgainstInlineKotlinTestGenerated.AnonymousObject.class, CompileKotlinAgainstInlineKotlinTestGenerated.Builders.class, CompileKotlinAgainstInlineKotlinTestGenerated.Capture.class, CompileKotlinAgainstInlineKotlinTestGenerated.Complex.class, CompileKotlinAgainstInlineKotlinTestGenerated.DefaultValues.class, CompileKotlinAgainstInlineKotlinTestGenerated.LambdaClassClash.class, CompileKotlinAgainstInlineKotlinTestGenerated.LambdaTransformation.class, CompileKotlinAgainstInlineKotlinTestGenerated.LocalFunInLambda.class, CompileKotlinAgainstInlineKotlinTestGenerated.NoInline.class, CompileKotlinAgainstInlineKotlinTestGenerated.NonLocalReturns.class, CompileKotlinAgainstInlineKotlinTestGenerated.Simple.class, CompileKotlinAgainstInlineKotlinTestGenerated.Special.class, CompileKotlinAgainstInlineKotlinTestGenerated.Trait.class, CompileKotlinAgainstInlineKotlinTestGenerated.TryCatchFinally.class}) +@InnerTestClasses({CompileKotlinAgainstInlineKotlinTestGenerated.AnonymousObject.class, CompileKotlinAgainstInlineKotlinTestGenerated.Builders.class, CompileKotlinAgainstInlineKotlinTestGenerated.Capture.class, CompileKotlinAgainstInlineKotlinTestGenerated.Complex.class, CompileKotlinAgainstInlineKotlinTestGenerated.DefaultValues.class, CompileKotlinAgainstInlineKotlinTestGenerated.LambdaClassClash.class, CompileKotlinAgainstInlineKotlinTestGenerated.LambdaTransformation.class, CompileKotlinAgainstInlineKotlinTestGenerated.LocalFunInLambda.class, CompileKotlinAgainstInlineKotlinTestGenerated.NoInline.class, CompileKotlinAgainstInlineKotlinTestGenerated.NonLocalReturns.class, CompileKotlinAgainstInlineKotlinTestGenerated.Reified.class, CompileKotlinAgainstInlineKotlinTestGenerated.Simple.class, CompileKotlinAgainstInlineKotlinTestGenerated.Special.class, CompileKotlinAgainstInlineKotlinTestGenerated.Trait.class, CompileKotlinAgainstInlineKotlinTestGenerated.TryCatchFinally.class}) @RunWith(JUnit3RunnerWithInners.class) public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompileKotlinAgainstKotlinTest { public void testAllFilesPresentInBoxInline() throws Exception { @@ -606,6 +606,21 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi } } + @TestMetadata("compiler/testData/codegen/boxInline/reified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Reified extends AbstractCompileKotlinAgainstKotlinTest { + public void testAllFilesPresentInReified() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/reified"), Pattern.compile("^(.+)\\.1.kt$"), true); + } + + @TestMetadata("packages.1.kt") + public void testPackages() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/packages.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/simple") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)