From ae3c17d399060cb269d728e4f6d606da67fce038 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 30 Oct 2014 11:10:35 +0300 Subject: [PATCH] Minor, get rid of SAMs in some loadJava tests --- .../loadJava/compiledJava/InnerOfGeneric.java | 6 +++--- .../loadJava/compiledJava/InnerOfGeneric.txt | 10 ++++------ .../loadJava/compiledJava/PrivateMembers.java | 7 ------- .../loadJava/compiledJava/PrivateMembers.txt | 7 ------- .../compiledJava/RawTypeWithUpperBound.java | 3 +++ .../compiledJava/RawTypeWithUpperBound.txt | 4 +--- .../sam/adapters/PrivateSamAdapter.java | 10 ++++++++++ .../sam/adapters/PrivateSamAdapter.txt | 14 ++++++++++++++ .../signaturePropagation/RawSuperType.java | 5 +++++ .../signaturePropagation/RawSuperType.txt | 5 ++--- .../TwoSuperclassesInconsistentGenericTypes.java | 8 +++++++- .../TwoSuperclassesInconsistentGenericTypes.txt | 8 +++----- .../TwoSuperclassesVarargAndNot.java | 6 +++++- .../TwoSuperclassesVarargAndNot.txt | 7 +++---- .../jet/jvm/compiler/LoadJavaTestGenerated.java | 6 ++++++ 15 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.java create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.txt diff --git a/compiler/testData/loadJava/compiledJava/InnerOfGeneric.java b/compiler/testData/loadJava/compiledJava/InnerOfGeneric.java index 3250b9f62c7..360eb1e6bba 100644 --- a/compiler/testData/loadJava/compiledJava/InnerOfGeneric.java +++ b/compiler/testData/loadJava/compiledJava/InnerOfGeneric.java @@ -3,12 +3,12 @@ package test; import java.util.Iterator; public class InnerOfGeneric { - public interface S { - Iterator iterator(); + public class S { + public Iterator iterator() { return null; } } public abstract class A { - public abstract class Inner implements S { + public abstract class Inner extends S { } } diff --git a/compiler/testData/loadJava/compiledJava/InnerOfGeneric.txt b/compiler/testData/loadJava/compiledJava/InnerOfGeneric.txt index b7d4c2d2359..2eaf5dd8f8d 100644 --- a/compiler/testData/loadJava/compiledJava/InnerOfGeneric.txt +++ b/compiler/testData/loadJava/compiledJava/InnerOfGeneric.txt @@ -8,7 +8,7 @@ public open class InnerOfGeneric { public abstract inner class Inner : test.InnerOfGeneric.S { public constructor Inner() - public abstract override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! } } @@ -21,10 +21,8 @@ public open class InnerOfGeneric { } } - public trait S { - public abstract fun iterator(): kotlin.(Mutable)Iterator! + public open inner class S { + public constructor S() + public open fun iterator(): kotlin.(Mutable)Iterator! } - - // Static members - public final /*synthesized*/ fun S(/*0*/ function: () -> kotlin.(Mutable)Iterator!): test.InnerOfGeneric.S } diff --git a/compiler/testData/loadJava/compiledJava/PrivateMembers.java b/compiler/testData/loadJava/compiledJava/PrivateMembers.java index f02f5d4be6f..1f8f7bc4faf 100644 --- a/compiler/testData/loadJava/compiledJava/PrivateMembers.java +++ b/compiler/testData/loadJava/compiledJava/PrivateMembers.java @@ -10,19 +10,12 @@ public class PrivateMembers { private void method() { } - private void samAdapter(SamInterface r) { - } - private static void staticMethod() { } private class Inner { } - private interface SamInterface { - void foo(); - } - private static class Nested { private static void staticMethodInNested() { } diff --git a/compiler/testData/loadJava/compiledJava/PrivateMembers.txt b/compiler/testData/loadJava/compiledJava/PrivateMembers.txt index 5fd7b1e476c..59cd5ed666c 100644 --- a/compiler/testData/loadJava/compiledJava/PrivateMembers.txt +++ b/compiler/testData/loadJava/compiledJava/PrivateMembers.txt @@ -4,8 +4,6 @@ public open class PrivateMembers { private constructor PrivateMembers() private final var field: kotlin.Int private open fun method(): kotlin.Unit - private final /*synthesized*/ fun samAdapter(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit - private open fun samAdapter(/*0*/ p0: test.PrivateMembers.SamInterface!): kotlin.Unit private open inner class Inner { private constructor Inner() @@ -18,12 +16,7 @@ public open class PrivateMembers { private open fun staticMethodInNested(): kotlin.Unit } - private trait SamInterface { - public abstract fun foo(): kotlin.Unit - } - // Static members private final var staticField: kotlin.Int - private final /*synthesized*/ fun SamInterface(/*0*/ function: () -> kotlin.Unit): test.PrivateMembers.SamInterface private open fun staticMethod(): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java b/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java index e53bf24de83..6894dbeb793 100644 --- a/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java +++ b/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java @@ -1,5 +1,7 @@ package test; +import java.util.List; + public interface RawTypeWithUpperBound { public interface Foo { @@ -7,5 +9,6 @@ public interface RawTypeWithUpperBound { interface Bar { void f(Foo f); + void g(List f); } } diff --git a/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.txt b/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.txt index 0a7b6b2ba56..51c84daa8f0 100644 --- a/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.txt +++ b/compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.txt @@ -4,11 +4,9 @@ public trait RawTypeWithUpperBound { public trait Bar { public abstract fun f(/*0*/ p0: test.RawTypeWithUpperBound.Foo!): kotlin.Unit + public abstract fun g(/*0*/ p0: kotlin.(Mutable)List!>!): kotlin.Unit } public trait Foo { } - - // Static members - public final /*synthesized*/ fun Bar(/*0*/ function: (test.RawTypeWithUpperBound.Foo!) -> kotlin.Unit): test.RawTypeWithUpperBound.Bar } diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.java b/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.java new file mode 100644 index 00000000000..3e5c18ff3c7 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.java @@ -0,0 +1,10 @@ +package test; + +public class PrivateSamAdapter { + private void samAdapter(SamInterface r) { + } + + private interface SamInterface { + void foo(); + } +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.txt new file mode 100644 index 00000000000..d09eb4e9fb3 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.txt @@ -0,0 +1,14 @@ +package test + +public open class PrivateSamAdapter { + public constructor PrivateSamAdapter() + private final /*synthesized*/ fun samAdapter(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit + private open fun samAdapter(/*0*/ p0: test.PrivateSamAdapter.SamInterface!): kotlin.Unit + + private trait SamInterface { + public abstract fun foo(): kotlin.Unit + } + + // Static members + private final /*synthesized*/ fun SamInterface(/*0*/ function: () -> kotlin.Unit): test.PrivateSamAdapter.SamInterface +} diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.java b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.java index 22a1c68f1ae..d1e40b4490b 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.java +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.java @@ -8,6 +8,8 @@ public class RawSuperType { public interface Super { void foo(T t); + + void dummy(); // To make it not SAM } public class Derived implements Super { @@ -15,6 +17,9 @@ public class RawSuperType { public void foo(Object o) { throw new UnsupportedOperationException(); } + + @Override + public void dummy() {} } } \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt index e05e1e2b558..0f754af9ee5 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt @@ -5,13 +5,12 @@ public open class RawSuperType { public open inner class Derived : test.RawSuperType.Super { public constructor Derived() + public open override /*1*/ fun dummy(): kotlin.Unit public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!): kotlin.Unit } public trait Super { + public abstract fun dummy(): kotlin.Unit public abstract fun foo(/*0*/ p0: T!): kotlin.Unit } - - // Static members - public final /*synthesized*/ fun Super(/*0*/ function: (T!) -> kotlin.Unit): test.RawSuperType.Super } diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.java b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.java index 3b9a83959ca..910beee9409 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.java +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.java @@ -10,9 +10,13 @@ public interface TwoSuperclassesInconsistentGenericTypes { @KotlinSignature("fun foo(): MutableList") List foo(); + void dummy(); // To make it not SAM + public interface Other { @KotlinSignature("fun foo(): MutableList?") List foo(); + + void dummy(); // To make it not SAM } public class Sub implements TwoSuperclassesInconsistentGenericTypes, Other { @@ -20,5 +24,7 @@ public interface TwoSuperclassesInconsistentGenericTypes { public List foo() { throw new UnsupportedOperationException(); } + + public void dummy() {} } -} \ No newline at end of file +} diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.txt index d63b6058250..4c0551b5d66 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.txt @@ -1,19 +1,17 @@ package test -public /*synthesized*/ fun TwoSuperclassesInconsistentGenericTypes(/*0*/ function: () -> kotlin.(Mutable)List!): test.TwoSuperclassesInconsistentGenericTypes - public trait TwoSuperclassesInconsistentGenericTypes { + public abstract fun dummy(): kotlin.Unit public abstract fun foo(): kotlin.(Mutable)List! public trait Other { + public abstract fun dummy(): kotlin.Unit public abstract fun foo(): kotlin.(Mutable)List! } public open class Sub : test.TwoSuperclassesInconsistentGenericTypes, test.TwoSuperclassesInconsistentGenericTypes.Other { public constructor Sub() + public open override /*2*/ fun dummy(): kotlin.Unit public open override /*2*/ fun foo(): kotlin.(Mutable)List! } - - // Static members - public final /*synthesized*/ fun Other(/*0*/ function: () -> kotlin.(Mutable)List!): test.TwoSuperclassesInconsistentGenericTypes.Other } diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.java b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.java index acafc3c0f87..0ccd2e00a6b 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.java +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.java @@ -11,11 +11,15 @@ import org.jetbrains.jet.jvm.compiler.annotation.ExpectLoadError; public interface TwoSuperclassesVarargAndNot { public interface Super1 { void foo(String... s); + + void dummy(); // To make it not SAM } public interface Super2 { @KotlinSignature("fun foo(s : Array?)") void foo(String[] s); + + void dummy(); // To make it not SAM } public interface Sub extends Super1, Super2 { @@ -24,4 +28,4 @@ public interface TwoSuperclassesVarargAndNot { "Incompatible super methods: some have vararg parameter, some have not|") void foo(String[] s); } -} \ No newline at end of file +} diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.txt index 0670c7f21db..3b4e3c64b87 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.txt @@ -3,18 +3,17 @@ package test public trait TwoSuperclassesVarargAndNot { public trait Sub : test.TwoSuperclassesVarargAndNot.Super1, test.TwoSuperclassesVarargAndNot.Super2 { + public abstract override /*2*/ /*fake_override*/ fun dummy(): kotlin.Unit public abstract override /*2*/ fun foo(/*0*/ s: kotlin.Array<(out) kotlin.String!>!): kotlin.Unit } public trait Super1 { + public abstract fun dummy(): kotlin.Unit public abstract fun foo(/*0*/ vararg p0: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit } public trait Super2 { + public abstract fun dummy(): kotlin.Unit public abstract fun foo(/*0*/ s: kotlin.Array<(out) kotlin.String!>!): kotlin.Unit } - - // Static members - public final /*synthesized*/ fun Super1(/*0*/ function: (kotlin.Array<(out) kotlin.String!>!) -> kotlin.Unit): test.TwoSuperclassesVarargAndNot.Super1 - public final /*synthesized*/ fun Super2(/*0*/ function: (kotlin.Array<(out) kotlin.String!>!) -> kotlin.Unit): test.TwoSuperclassesVarargAndNot.Super2 } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 1bae9673680..1142056777c 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -1524,6 +1524,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava(fileName); } + @TestMetadata("PrivateSamAdapter.java") + public void testPrivateSamAdapter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/PrivateSamAdapter.java"); + doTestCompiledJava(fileName); + } + @TestMetadata("SelfAsParameter.java") public void testSelfAsParameter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/SelfAsParameter.java");