Supported complex cases of SAM adapters inheritance/overriding.
This commit is contained in:
+2
-1
@@ -190,7 +190,8 @@ public class SingleAbstractMethodUtils {
|
||||
original.getContainingDeclaration(),
|
||||
original.getAnnotations(),
|
||||
original.getName(),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
original
|
||||
);
|
||||
FunctionInitializer initializer = new FunctionInitializer() {
|
||||
@Override
|
||||
|
||||
+25
-1
@@ -30,12 +30,29 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
|
||||
private boolean isInline = false;
|
||||
|
||||
private final SimpleFunctionDescriptor originalOfSynthesized; // TODO replace with user data
|
||||
|
||||
public SimpleFunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
this(containingDeclaration, annotations, name, kind, null);
|
||||
}
|
||||
|
||||
public SimpleFunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind,
|
||||
@Nullable SimpleFunctionDescriptor originalOfSynthesized
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, kind);
|
||||
this.originalOfSynthesized = originalOfSynthesized;
|
||||
if (originalOfSynthesized != null) {
|
||||
assert kind == Kind.SYNTHESIZED;
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleFunctionDescriptorImpl(
|
||||
@@ -45,6 +62,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
originalOfSynthesized = null;
|
||||
}
|
||||
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@@ -100,4 +118,10 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
public boolean isInline() {
|
||||
return isInline;
|
||||
}
|
||||
|
||||
// TODO replace with user data
|
||||
@Nullable
|
||||
public SimpleFunctionDescriptor getOriginalOfSynthesized() {
|
||||
return originalOfSynthesized;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
|
||||
@@ -183,6 +185,9 @@ public class OverridingUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOverridableSynthesized(superDescriptor, subDescriptor)) {
|
||||
return OverrideCompatibilityInfo.synthesizedAndDeclarationIncompatible();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -296,6 +301,89 @@ public class OverridingUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOverridableSynthesized(@NotNull CallableDescriptor superDescriptor, @NotNull CallableDescriptor subDescriptor) {
|
||||
if (subDescriptor instanceof PropertyDescriptor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor superOriginal = getOriginalOfSamAdapterFunction((SimpleFunctionDescriptor) superDescriptor);
|
||||
SimpleFunctionDescriptor subOriginal = getOriginalOfSamAdapterFunction((SimpleFunctionDescriptor) subDescriptor);
|
||||
if (superOriginal == null || subOriginal == null) { // super or sub is/overrides DECLARATION
|
||||
return subOriginal == null; // DECLARATION can override anything
|
||||
}
|
||||
|
||||
// inheritor if SYNTHESIZED can override inheritor of SYNTHESIZED if their originals have same erasure
|
||||
return equalErasure(superOriginal, subOriginal);
|
||||
}
|
||||
|
||||
private static boolean equalErasure(@NotNull FunctionDescriptor fun1, @NotNull FunctionDescriptor fun2) {
|
||||
List<ValueParameterDescriptor> parameters1 = fun1.getValueParameters();
|
||||
List<ValueParameterDescriptor> parameters2 = fun2.getValueParameters();
|
||||
|
||||
for (ValueParameterDescriptor param1 : parameters1) {
|
||||
ValueParameterDescriptor param2 = parameters2.get(param1.getIndex());
|
||||
if (!TypeUtils.equalClasses(param2.getType(), param1.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// if function is or overrides declaration, returns null; otherwise, return original of sam adapter with substituted type parameters
|
||||
@Nullable
|
||||
private static SimpleFunctionDescriptor getOriginalOfSamAdapterFunction(@NotNull SimpleFunctionDescriptor callable) {
|
||||
DeclarationDescriptor containingDeclaration = callable.getContainingDeclaration();
|
||||
if (!(containingDeclaration instanceof ClassDescriptor)) {
|
||||
return null;
|
||||
}
|
||||
Pair<SimpleFunctionDescriptor, JetType> declarationOrSynthesized =
|
||||
getNearestDeclarationOrSynthesized(callable, ((ClassDescriptor) containingDeclaration).getDefaultType());
|
||||
|
||||
if (declarationOrSynthesized == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor fun = declarationOrSynthesized.first;
|
||||
if (fun.getKind() != CallableMemberDescriptor.Kind.SYNTHESIZED) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor originalOfSynthesized = ((SimpleFunctionDescriptorImpl) fun.getOriginal())
|
||||
.getOriginalOfSynthesized();
|
||||
if (originalOfSynthesized == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((SimpleFunctionDescriptor) originalOfSynthesized.substitute(TypeSubstitutor.create(declarationOrSynthesized.second)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Pair<SimpleFunctionDescriptor, JetType> getNearestDeclarationOrSynthesized(
|
||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||
@NotNull JetType ownerType
|
||||
) {
|
||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return Pair.create(samAdapter, ownerType);
|
||||
}
|
||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
|
||||
for (JetType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Pair<SimpleFunctionDescriptor, JetType> found =
|
||||
getNearestDeclarationOrSynthesized((SimpleFunctionDescriptor) overridden, immediateSupertype);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class OverrideCompatibilityInfo {
|
||||
|
||||
public enum Result {
|
||||
@@ -356,6 +444,11 @@ public class OverridingUtil {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "varOverriddenByVal"); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo synthesizedAndDeclarationIncompatible() {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "synthesizedAndDeclarationIncompatible"); // TODO
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final Result overridable;
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
public interface AdapterDoesntOverrideDeclaration {
|
||||
public interface Super {
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait AdapterDoesntOverrideDeclaration : java.lang.Object {
|
||||
|
||||
public trait Sub : test.AdapterDoesntOverrideDeclaration.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package AdapterDoesntOverrideDeclaration {
|
||||
public /*synthesized*/ fun Super(/*0*/ function: ((() -> jet.Unit)?) -> jet.Unit): test.AdapterDoesntOverrideDeclaration.Super
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
public interface InheritedAdapterAndDeclaration {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAdapterAndDeclaration : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAdapterAndDeclaration.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface InheritedAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAmbiguousAdapters.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface InheritedAndOverriddenAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAndOverriddenAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAndOverriddenAmbiguousAdapters.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
public interface InheritedSameAdapters {
|
||||
public interface Super1 {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
public interface Super2 {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1, Super2 {
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package test
|
||||
|
||||
public trait InheritedSameAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedSameAdapters.Super1, test.InheritedSameAdapters.Super2 {
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2 : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package InheritedSameAdapters {
|
||||
public /*synthesized*/ fun Sub(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Sub
|
||||
public /*synthesized*/ fun Super1(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Super1
|
||||
public /*synthesized*/ fun Super2(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Super2
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package test;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public interface InheritedSameAdaptersWithSubstitution {
|
||||
public interface Super1 {
|
||||
void foo(Comparator<String> r);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
void foo(Comparator<T> r);
|
||||
}
|
||||
|
||||
public interface Super2Substituted extends Super2<String> {
|
||||
}
|
||||
|
||||
public interface Sub extends Super1, Super2Substituted {
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package test
|
||||
|
||||
public trait InheritedSameAdaptersWithSubstitution : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedSameAdaptersWithSubstitution.Super1, test.InheritedSameAdaptersWithSubstitution.Super2Substituted {
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2</*0*/ T> : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.util.Comparator<T>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2Substituted : test.InheritedSameAdaptersWithSubstitution.Super2<jet.String> {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package InheritedSameAdaptersWithSubstitution {
|
||||
public /*synthesized*/ fun Sub(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Sub
|
||||
public /*synthesized*/ fun Super1(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super1
|
||||
public /*synthesized*/ fun </*0*/ T> Super2(/*0*/ function: (java.util.Comparator<T>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super2<T>
|
||||
public /*synthesized*/ fun Super2Substituted(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super2Substituted
|
||||
}
|
||||
+1
-1
@@ -7,4 +7,4 @@ public interface InheritedSimple {
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface OverriddenAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public trait OverriddenAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.OverriddenAmbiguousAdapters.Super {
|
||||
public abstract override /*2*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public final class Sub : test.Super {
|
||||
public constructor Sub()
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: java.io.Closeable?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public/*package*/ open /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ open /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.io.Closeable?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
public class Sub: Super() {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public class Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
@@ -1201,6 +1201,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledJava/sam/adapters")
|
||||
@InnerTestClasses({Adapters.Inheritance.class})
|
||||
public static class Adapters extends AbstractLoadJavaTest {
|
||||
public void testAllFilesPresentInAdapters() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/sam/adapters"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
@@ -1226,21 +1227,6 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/DeepSamLoop.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverridden.java")
|
||||
public void testInheritedOverridden() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedOverridden.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverriddenAdapter.java")
|
||||
public void testInheritedOverriddenAdapter() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedOverriddenAdapter.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSimple.java")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedSimple.java");
|
||||
}
|
||||
|
||||
@TestMetadata("NonTrivialFunctionType.java")
|
||||
public void testNonTrivialFunctionType() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.java");
|
||||
@@ -1271,12 +1257,76 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfOuterClass.java");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance")
|
||||
public static class Inheritance extends AbstractLoadJavaTest {
|
||||
@TestMetadata("AdapterDoesntOverrideDeclaration.java")
|
||||
public void testAdapterDoesntOverrideDeclaration() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/AdapterDoesntOverrideDeclaration.java");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInheritance() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAdapterAndDeclaration.java")
|
||||
public void testInheritedAdapterAndDeclaration() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAdapterAndDeclaration.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAmbiguousAdapters.java")
|
||||
public void testInheritedAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAndOverriddenAmbiguousAdapters.java")
|
||||
public void testInheritedAndOverriddenAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAndOverriddenAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverridden.java")
|
||||
public void testInheritedOverridden() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverridden.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverriddenAdapter.java")
|
||||
public void testInheritedOverriddenAdapter() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSameAdapters.java")
|
||||
public void testInheritedSameAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSameAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSameAdaptersWithSubstitution.java")
|
||||
public void testInheritedSameAdaptersWithSubstitution() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSameAdaptersWithSubstitution.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSimple.java")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSimple.java");
|
||||
}
|
||||
|
||||
@TestMetadata("OverriddenAmbiguousAdapters.java")
|
||||
public void testOverriddenAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
TestSuite suite = new TestSuite("Adapters");
|
||||
suite.addTestSuite(Adapters.class);
|
||||
suite.addTestSuite(Inheritance.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
TestSuite suite = new TestSuite("Sam");
|
||||
suite.addTestSuite(Sam.class);
|
||||
suite.addTestSuite(Adapters.class);
|
||||
suite.addTest(Adapters.innerSuite());
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
@@ -1422,6 +1472,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/javaAgainstKotlin/samAdapters"), Pattern.compile("^(.+)\\.txt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritAmbguousSamAdaptersInKotlin.txt")
|
||||
public void testInheritAmbguousSamAdaptersInKotlin() throws Exception {
|
||||
doTestJavaAgainstKotlin("compiler/testData/loadJava/javaAgainstKotlin/samAdapters/InheritAmbguousSamAdaptersInKotlin.txt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritSamAdapterInKotlin.txt")
|
||||
public void testInheritSamAdapterInKotlin() throws Exception {
|
||||
doTestJavaAgainstKotlin("compiler/testData/loadJava/javaAgainstKotlin/samAdapters/InheritSamAdapterInKotlin.txt");
|
||||
|
||||
Reference in New Issue
Block a user