diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.java index 1d8fa438216..ce4b59b4d9a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.java @@ -51,5 +51,5 @@ public interface CallableMemberDescriptor extends CallableDescriptor, MemberDesc Kind getKind(); @NotNull - CallableMemberDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides); + CallableMemberDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java index 2fe1e75e63f..ecdea5bfaae 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java @@ -108,7 +108,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements @NotNull @Override - public ConstructorDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { + public ConstructorDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { throw new UnsupportedOperationException("Constructors should not be copied for overriding"); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.java index e98bd8584bd..f6d5ca7fa35 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.java @@ -42,5 +42,5 @@ public interface FunctionDescriptor extends CallableMemberDescriptor { @NotNull @Override - FunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides); + FunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Modality.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Modality.java index b63b6e49fd2..539e7439e4b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Modality.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Modality.java @@ -20,6 +20,7 @@ package org.jetbrains.jet.lang.descriptors; * @author abreslav */ public enum Modality { + // THE ORDER OF ENTRIES MATTERS HERE FINAL(false), OPEN(true), ABSTRACT(true); @@ -33,7 +34,7 @@ public enum Modality { public boolean isOverridable() { return overridable; } - + public static Modality convertFromFlags(boolean _abstract, boolean open) { if (_abstract) return ABSTRACT; if (open) return OPEN; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java index 493ffbccaf4..78a531ba7a9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java @@ -123,7 +123,7 @@ public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorNo @NotNull @Override - public PropertyAccessorDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { + public PropertyAccessorDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { throw new UnsupportedOperationException("Accessors must be copied by the corresponding property"); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java index 88058260e6e..1dca0b9b47b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java @@ -306,8 +306,8 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab @NotNull @Override - public PropertyDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { - return doSubstitute(TypeSubstitutor.EMPTY, newOwner, DescriptorUtils.convertModality(modality, makeNonAbstract), makeInvisible ? Visibilities.INVISIBLE_FAKE : visibility, false, copyOverrides, kind); + public PropertyDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { + return doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, makeInvisible ? Visibilities.INVISIBLE_FAKE : visibility, false, copyOverrides, kind); } public static PropertyDescriptor createDummy() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptCodeDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptCodeDescriptor.java index c7fc25ed105..4653d3b3dcd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptCodeDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptCodeDescriptor.java @@ -17,7 +17,6 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; @@ -50,7 +49,7 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl { @NotNull @Override - public FunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { + public FunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { throw new IllegalStateException("no need to copy script code descriptor"); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptor.java index ab82f429a62..ff5fc691ee2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptor.java @@ -27,7 +27,7 @@ public interface SimpleFunctionDescriptor extends FunctionDescriptor { @NotNull @Override - SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides); + SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides); @NotNull @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptorImpl.java index eae61c11ea4..22966e75344 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/SimpleFunctionDescriptorImpl.java @@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.JetType; @@ -94,9 +93,8 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme @NotNull @Override - public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { - SimpleFunctionDescriptorImpl copy = (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, DescriptorUtils - .convertModality(modality, makeNonAbstract), makeInvisible ? Visibilities.INVISIBLE_FAKE : visibility, false, copyOverrides, kind); + public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { + SimpleFunctionDescriptorImpl copy = (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, makeInvisible ? Visibilities.INVISIBLE_FAKE : visibility, false, copyOverrides, kind); copy.isInline = isInline; return copy; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegationResolver.java index e2efb3d4715..8d4004e7a20 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegationResolver.java @@ -71,7 +71,8 @@ public class DelegationResolver { if (declarationDescriptor instanceof PropertyDescriptor) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) declarationDescriptor; if (propertyDescriptor.getModality().isOverridable()) { - PropertyDescriptor copy = propertyDescriptor.copy(classDescriptor, true, false, CallableMemberDescriptor.Kind.DELEGATION, true); + Modality modality = DescriptorUtils.convertModality(propertyDescriptor.getModality(), true); + PropertyDescriptor copy = propertyDescriptor.copy(classDescriptor, modality, false, CallableMemberDescriptor.Kind.DELEGATION, true); classDescriptor.getBuilder().addPropertyDescriptor(copy); trace.record(DELEGATED, copy); } @@ -79,7 +80,8 @@ public class DelegationResolver { else if (declarationDescriptor instanceof SimpleFunctionDescriptor) { SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) declarationDescriptor; if (functionDescriptor.getModality().isOverridable()) { - SimpleFunctionDescriptor copy = functionDescriptor.copy(classDescriptor, true, false, CallableMemberDescriptor.Kind.DELEGATION, true); + Modality modality = DescriptorUtils.convertModality(functionDescriptor.getModality(), true); + SimpleFunctionDescriptor copy = functionDescriptor.copy(classDescriptor, modality, false, CallableMemberDescriptor.Kind.DELEGATION, true); classDescriptor.getBuilder().addFunctionDescriptor(copy); trace.record(DELEGATED, copy); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/OverrideResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/OverrideResolver.java index 81d2d6a84a9..04d96cf6c2f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/OverrideResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/OverrideResolver.java @@ -177,45 +177,73 @@ public class OverrideResolver { public static void generateOverridesInFunctionGroup( @NotNull Name name, - @NotNull Collection functionsFromSupertypes, - @NotNull Collection functionsFromCurrent, + @NotNull Collection membersFromSupertypes, + @NotNull Collection membersFromCurrent, @NotNull ClassDescriptor current, @NotNull DescriptorSink sink) { - - List fakeOverrideList = Lists.newArrayList(); + List notOverridden = Lists.newArrayList(membersFromSupertypes); + for (CallableMemberDescriptor fromCurrent : membersFromCurrent) { - for (CallableMemberDescriptor functionFromSupertype : functionsFromSupertypes) { - boolean overrides = false; + // Find what this descriptor overrides, bind them and removed from notOverridden + for (Iterator iterator = notOverridden.iterator(); iterator.hasNext(); ) { + CallableMemberDescriptor fromSupertype = iterator.next(); + OverridingUtil.OverrideCompatibilityInfo.Result result = + OverridingUtil.isOverridableBy(fromSupertype, fromCurrent).getResult(); - boolean isVisible = Visibilities.isVisible(functionFromSupertype, current); - - for (CallableMemberDescriptor functionFromCurrent : functionsFromCurrent) { - OverridingUtil.OverrideCompatibilityInfo.Result result = OverridingUtil.isOverridableBy(functionFromSupertype, functionFromCurrent).getResult(); - if (result == OVERRIDABLE) { - - if (isVisible) { - OverridingUtil.bindOverride(functionFromCurrent, functionFromSupertype); + if (Visibilities.isVisible(fromSupertype, current)) { + switch (result) { + case OVERRIDABLE: + OverridingUtil.bindOverride(fromCurrent, fromSupertype); + iterator.remove(); + break; + case CONFLICT: + sink.conflict(fromSupertype, fromCurrent); + break; + case INCOMPATIBLE: + break; } - overrides = true; - } - else if (result == OverridingUtil.OverrideCompatibilityInfo.Result.CONFLICT) { - sink.conflict(functionFromSupertype, functionFromCurrent); } } - - for (CallableMemberDescriptor fakeOverride : fakeOverrideList) { - if (OverridingUtil.isOverridableBy(functionFromSupertype, fakeOverride).getResult() == OVERRIDABLE) { - OverridingUtil.bindOverride(fakeOverride, functionFromSupertype); - overrides = true; + } + + Queue fromSuperQueue = new LinkedList(notOverridden); + while (!fromSuperQueue.isEmpty()) { + CallableMemberDescriptor aFromSuper = fromSuperQueue.remove(); + Collection overridableByA = Lists.newArrayList(); + overridableByA.add(aFromSuper); + for (Iterator iterator = fromSuperQueue.iterator(); iterator.hasNext(); ) { + CallableMemberDescriptor bFromSuper = iterator.next(); + OverridingUtil.OverrideCompatibilityInfo.Result result = + OverridingUtil.isOverridableBy(bFromSuper, aFromSuper).getResult(); + switch (result) { + case OVERRIDABLE: + overridableByA.add(bFromSuper); + iterator.remove(); + break; + case CONFLICT: + sink.conflict(aFromSuper, bFromSuper); + iterator.remove(); + break; + case INCOMPATIBLE: + break; } } - if (!overrides) { - CallableMemberDescriptor fakeOverride = functionFromSupertype.copy(current, false, !isVisible, CallableMemberDescriptor.Kind.FAKE_OVERRIDE, false); - OverridingUtil.bindOverride(fakeOverride, functionFromSupertype); - fakeOverrideList.add(fakeOverride); - sink.addToScope(fakeOverride); + boolean isVisible = true; + Modality modality = Modality.ABSTRACT; + for (CallableMemberDescriptor descriptor : overridableByA) { + isVisible &= Visibilities.isVisible(descriptor, current); + if (descriptor.getModality().compareTo(modality) < 0) { + modality = descriptor.getModality(); + } } + + CallableMemberDescriptor fakeOverride = + aFromSuper.copy(current, modality, !isVisible, CallableMemberDescriptor.Kind.FAKE_OVERRIDE, false); + for (CallableMemberDescriptor descriptor : overridableByA) { + OverridingUtil.bindOverride(fakeOverride, descriptor); + } + sink.addToScope(fakeOverride); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.java index 0eba37a8001..c4e89a099dc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptorImpl; +import org.jetbrains.jet.lang.descriptors.Modality; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.name.Name; @@ -40,7 +41,7 @@ public class ExpressionAsFunctionDescriptor extends FunctionDescriptorImpl { @NotNull @Override - public FunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { + public FunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { throw new IllegalStateException(); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java index a0f6b0e26ce..fd99af0e40f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java @@ -45,7 +45,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI @NotNull @Override - public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, boolean makeInvisible, Kind kind, boolean copyOverrides) { + public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, boolean makeInvisible, Kind kind, boolean copyOverrides) { return this; } diff --git a/compiler/testData/diagnostics/tests/override/InvisiblePotentialOverride.kt b/compiler/testData/diagnostics/tests/override/InvisiblePotentialOverride.kt new file mode 100644 index 00000000000..94867e7289b --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/InvisiblePotentialOverride.kt @@ -0,0 +1,7 @@ +open class A { + private fun foo() : Int = 1 +} + +class B : A() { + fun foo() : String = "" +} \ No newline at end of file diff --git a/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.java b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.java new file mode 100644 index 00000000000..d837abe14a9 --- /dev/null +++ b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.java @@ -0,0 +1,15 @@ +package test; + +import java.util.AbstractList; + +public class ModalityOfFakeOverrides extends AbstractList { + @Override + public String get(int index) { + return ""; + } + + @Override + public int size() { + return 0; + } +} diff --git a/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.kt b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.kt new file mode 100644 index 00000000000..d654c5eea78 --- /dev/null +++ b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.kt @@ -0,0 +1,11 @@ +package test + +import java.util.AbstractList + +public open class ModalityOfFakeOverrides : AbstractList() { + override fun get(p0: Int): String? { + return "" + } + + override fun size(): Int = 0 +} diff --git a/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.txt b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.txt new file mode 100644 index 00000000000..f1de701f0cf --- /dev/null +++ b/compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.txt @@ -0,0 +1,30 @@ +namespace test + +public open class test.ModalityOfFakeOverrides : java.util.AbstractList { + public final /*constructor*/ fun (): test.ModalityOfFakeOverrides + public open override /*1*/ fun add(/*0*/ p0: jet.Int, /*1*/ p1: jet.String?): jet.Tuple0 + public open override /*1*/ fun add(/*0*/ p0: jet.String?): jet.Boolean + public open override /*1*/ fun addAll(/*0*/ p0: java.util.Collection?): jet.Boolean + public open override /*1*/ fun addAll(/*0*/ p0: jet.Int, /*1*/ p1: java.util.Collection?): jet.Boolean + public open override /*1*/ fun clear(): jet.Tuple0 + public open override /*1*/ fun contains(/*0*/ p0: jet.Any?): jet.Boolean + public open override /*1*/ fun containsAll(/*0*/ p0: java.util.Collection?): jet.Boolean + public open override /*1*/ fun get(/*0*/ p0: jet.Int): jet.String? + public open override /*1*/ fun indexOf(/*0*/ p0: jet.Any?): jet.Int + public open override /*1*/ fun isEmpty(): jet.Boolean + public open override /*1*/ fun iterator(): java.util.Iterator? + public open override /*1*/ fun lastIndexOf(/*0*/ p0: jet.Any?): jet.Int + public open override /*1*/ fun listIterator(): java.util.ListIterator? + public open override /*1*/ fun listIterator(/*0*/ p0: jet.Int): java.util.ListIterator? + protected final override /*1*/ var modCount: jet.Int + public open override /*1*/ fun remove(/*0*/ p0: jet.Any?): jet.Boolean + public open override /*1*/ fun remove(/*0*/ p0: jet.Int): jet.String? + public open override /*1*/ fun removeAll(/*0*/ p0: java.util.Collection?): jet.Boolean + protected open override /*1*/ fun removeRange(/*0*/ p0: jet.Int, /*1*/ p1: jet.Int): jet.Tuple0 + public open override /*1*/ fun retainAll(/*0*/ p0: java.util.Collection?): jet.Boolean + public open override /*1*/ fun set(/*0*/ p0: jet.Int, /*1*/ p1: jet.String?): jet.String? + public open override /*1*/ fun size(): jet.Int + public open override /*1*/ fun subList(/*0*/ p0: jet.Int, /*1*/ p1: jet.Int): java.util.List? + public open override /*1*/ fun toArray(): jet.Array? + public open override /*1*/ fun toArray(/*0*/ p0: jet.Array?): jet.Array? +} diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/ReadJavaBinaryClassTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/ReadJavaBinaryClassTestGenerated.java index 1a33f491eda..04ce61b715e 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/ReadJavaBinaryClassTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/ReadJavaBinaryClassTestGenerated.java @@ -15,10 +15,9 @@ */ package org.jetbrains.jet.jvm.compiler; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; import java.io.File; import java.lang.reflect.Method; @@ -26,328 +25,264 @@ import java.util.HashSet; import java.util.Set; /* This class is generated by org.jetbrains.jet.jvm.compiler.ReadJavaBinaryClassTestGenerator. DO NOT MODIFY MANUALLY */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - ReadJavaBinaryClassTestGenerated.ReadJavaBinaryClass.class -}) public class ReadJavaBinaryClassTestGenerated { public static class ReadJavaBinaryClass extends AbstractReadJavaBinaryClassTest { - @Test - public void allTestsPresentInReadJavaBinaryClass() throws Exception { + public void testAllFilesPresentInReadJavaBinaryClass() throws Exception { allTestsPresent(ReadJavaBinaryClass.class, new File("compiler/testData/readJavaBinaryClass"), true); } - @Test public void testAnnotatedAnnotation() throws Exception { doTest("compiler/testData/readJavaBinaryClass/annotation/AnnotatedAnnotation.java"); } - @Test public void testAnnotatedMethod() throws Exception { doTest("compiler/testData/readJavaBinaryClass/annotation/AnnotatedMethod.java"); } - @Test public void testSimpleAnnotation() throws Exception { doTest("compiler/testData/readJavaBinaryClass/annotation/SimpleAnnotation.java"); } - @Test public void testClassDoesNotOverrideMethod() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassDoesNotOverrideMethod.java"); } - @Test public void testClassWithTypeP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassWithTypeP.java"); } - @Test public void testClassWithTypePExtendsIterableP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePExtendsIterableP.java"); } - @Test public void testClassWithTypePP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePP.java"); } - @Test public void testClassWithTypePRefNext() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePRefNext.java"); } - @Test public void testClassWithTypePRefSelf() throws Exception { doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePRefSelf.java"); } - @Test public void testConstructorGenericDeep() throws Exception { doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericDeep.java"); } - @Test public void testConstructorGenericSimple() throws Exception { doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericSimple.java"); } - @Test public void testConstructorGenericUpperBound() throws Exception { doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericUpperBound.java"); } - @Test public void testFieldAsVar() throws Exception { doTest("compiler/testData/readJavaBinaryClass/FieldAsVar.java"); } - @Test public void testFieldOfArrayType() throws Exception { doTest("compiler/testData/readJavaBinaryClass/FieldOfArrayType.java"); } - @Test public void testFinalFieldAsVal() throws Exception { doTest("compiler/testData/readJavaBinaryClass/FinalFieldAsVal.java"); } - @Test public void testInnerClass() throws Exception { doTest("compiler/testData/readJavaBinaryClass/InnerClass.java"); } - @Test public void testInnerClassesInGeneric() throws Exception { doTest("compiler/testData/readJavaBinaryClass/InnerClassesInGeneric.java"); } - @Test public void testInnerClassReferencesOuterTP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/InnerClassReferencesOuterTP.java"); } - @Test public void testDifferentGetterAndSetter() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/DifferentGetterAndSetter.java"); } - @Test public void testJavaBeanAbstractGetter() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanAbstractGetter.java"); } - @Test public void testJavaBeanVal() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVal.java"); } - @Test public void testJavaBeanVar() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVar.java"); } - @Test public void testJavaBeanVarOfGenericType() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVarOfGenericType.java"); } - @Test public void testTwoSetters() throws Exception { doTest("compiler/testData/readJavaBinaryClass/javaBean/TwoSetters.java"); } - @Test public void testAddingNullability() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/AddingNullability.java"); } - @Test public void testExtraUpperBound() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/ExtraUpperBound.java"); } - @Test public void testMissingUpperBound() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/MissingUpperBound.java"); } - @Test public void testNotVarargReplacedWithVararg() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/NotVarargReplacedWithVararg.java"); } - @Test public void testReturnTypeMissing() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/ReturnTypeMissing.java"); } - @Test public void testSyntaxError() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/SyntaxError.java"); } - @Test public void testVarargReplacedWithNotVararg() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/VarargReplacedWithNotVararg.java"); } - @Test public void testWrongMethodName() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongMethodName.java"); } - @Test public void testWrongReturnTypeStructure() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongReturnTypeStructure.java"); } - @Test public void testWrongTypeName1() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName1.java"); } - @Test public void testWrongTypeName2() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName2.java"); } - @Test public void testWrongTypeName3() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName3.java"); } - @Test public void testWrongTypeParameterBoundStructure1() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParameterBoundStructure1.java"); } - @Test public void testWrongTypeParameterBoundStructure2() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParameterBoundStructure2.java"); } - @Test public void testWrongTypeParametersCount() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParametersCount.java"); } - @Test public void testWrongTypeVariance() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeVariance.java"); } - @Test public void testWrongValueParametersCount() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParametersCount.java"); } - @Test public void testWrongValueParameterStructure1() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParameterStructure1.java"); } - @Test public void testWrongValueParameterStructure2() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParameterStructure2.java"); } - @Test public void testMethodWithFunctionTypes() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithFunctionTypes.java"); } - @Test public void testMethodWithGenerics() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithGenerics.java"); } - @Test public void testMethodWithTupleType() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithTupleType.java"); } - @Test public void testMethodWithTypeParameters() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithTypeParameters.java"); } - @Test public void testMethodWithVararg() throws Exception { doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithVararg.java"); } - @Test public void testMethodReferencesOuterClassTP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodReferencesOuterClassTP.java"); } - @Test public void testMethodTypePOneUpperBound() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodTypePOneUpperBound.java"); } - @Test public void testMethodTypePTwoUpperBounds() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodTypePTwoUpperBounds.java"); } - @Test public void testMethodWithTypeP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodWithTypeP.java"); } - @Test public void testMethodWithTypePP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodWithTypePP.java"); } - @Test public void testMethodWithTypePRefClassP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethodWithTypePRefClassP.java"); } - @Test public void testMethosWithPRefTP() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MethosWithPRefTP.java"); } - @Test + public void testModalityOfFakeOverrides() throws Exception { + doTest("compiler/testData/readJavaBinaryClass/modality/ModalityOfFakeOverrides.java"); + } + public void testMyException() throws Exception { doTest("compiler/testData/readJavaBinaryClass/MyException.java"); } - @Test public void testNotNullField() throws Exception { doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullField.java"); } - @Test public void testNotNullMethod() throws Exception { doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullMethod.java"); } - @Test public void testNotNullParameter() throws Exception { doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullParameter.java"); } - @Test public void testSimple() throws Exception { doTest("compiler/testData/readJavaBinaryClass/Simple.java"); } - @Test public void testTwoFields() throws Exception { doTest("compiler/testData/readJavaBinaryClass/TwoFields.java"); } - @Test public void testVarargInt() throws Exception { doTest("compiler/testData/readJavaBinaryClass/vararg/VarargInt.java"); } - @Test public void testVarargString() throws Exception { doTest("compiler/testData/readJavaBinaryClass/vararg/VarargString.java"); } @@ -355,7 +290,7 @@ public class ReadJavaBinaryClassTestGenerated { public static void allTestsPresent(Class clazz, File testDataDir, boolean recursive) { Set methodNames = new HashSet(); for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(Test.class)) { + if (method.getName().startsWith("test")) { methodNames.add(method.getName().toLowerCase() + ".java"); } } @@ -375,4 +310,9 @@ public class ReadJavaBinaryClassTestGenerated { } } + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTestSuite(ReadJavaBinaryClass.class); + return suite; + } }