KT-5087 Private members of Java classes should be marked as invisible, not unresolved
#KT-5087 fixed
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
public class PrivateMembers {
|
||||||
|
private PrivateMembers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private int field = 1;
|
||||||
|
private static int staticField = 2;
|
||||||
|
|
||||||
|
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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public open class PrivateMembers : java.lang.Object {
|
||||||
|
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 : java.lang.Object {
|
||||||
|
private constructor Inner()
|
||||||
|
}
|
||||||
|
|
||||||
|
private open class Nested : java.lang.Object {
|
||||||
|
private constructor Nested()
|
||||||
|
}
|
||||||
|
|
||||||
|
private trait SamInterface : java.lang.Object {
|
||||||
|
public abstract fun foo(): kotlin.Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package test.PrivateMembers {
|
||||||
|
private var staticField: kotlin.Int
|
||||||
|
private /*synthesized*/ fun SamInterface(/*0*/ function: () -> kotlin.Unit): test.PrivateMembers.SamInterface
|
||||||
|
private open fun staticMethod(): kotlin.Unit
|
||||||
|
|
||||||
|
package test.PrivateMembers.Nested {
|
||||||
|
private open fun staticMethodInNested(): kotlin.Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
public class PrivateMembersInHierarchy {
|
||||||
|
public static class Super {
|
||||||
|
private int field = 1;
|
||||||
|
private int field2 = 1;
|
||||||
|
|
||||||
|
private void method() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Sub extends Super {
|
||||||
|
private int field = 1;
|
||||||
|
|
||||||
|
private void method() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public open class PrivateMembersInHierarchy : java.lang.Object {
|
||||||
|
public constructor PrivateMembersInHierarchy()
|
||||||
|
|
||||||
|
public open class Sub : test.PrivateMembersInHierarchy.Super {
|
||||||
|
public constructor Sub()
|
||||||
|
private final var field: kotlin.Int
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var field2: kotlin.Int
|
||||||
|
private open fun method(): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class Super : java.lang.Object {
|
||||||
|
public constructor Super()
|
||||||
|
private final var field: kotlin.Int
|
||||||
|
private final var field2: kotlin.Int
|
||||||
|
private open fun method(): kotlin.Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -2,9 +2,12 @@ package test
|
|||||||
|
|
||||||
public abstract class ClassDoesNotOverrideMethod : java.util.Date {
|
public abstract class ClassDoesNotOverrideMethod : java.util.Date {
|
||||||
public constructor ClassDoesNotOverrideMethod()
|
public constructor ClassDoesNotOverrideMethod()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var cdate: sun.util.calendar.BaseCalendar.Date?
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var fastTime: kotlin.Long
|
||||||
public open override /*1*/ /*fake_override*/ fun after(/*0*/ p0: java.util.Date): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun after(/*0*/ p0: java.util.Date): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun before(/*0*/ p0: java.util.Date): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun before(/*0*/ p0: java.util.Date): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: java.util.Date): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: java.util.Date): kotlin.Int
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarDate(): sun.util.calendar.BaseCalendar.Date?
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getDate(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getDate(): kotlin.Int
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getDay(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getDay(): kotlin.Int
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getHours(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getHours(): kotlin.Int
|
||||||
@@ -12,8 +15,12 @@ public abstract class ClassDoesNotOverrideMethod : java.util.Date {
|
|||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getMonth(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getMonth(): kotlin.Int
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getSeconds(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getSeconds(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun getTime(): kotlin.Long
|
public open override /*1*/ /*fake_override*/ fun getTime(): kotlin.Long
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ fun getTimeImpl(): kotlin.Long
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getTimezoneOffset(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getTimezoneOffset(): kotlin.Int
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getYear(): kotlin.Int
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun getYear(): kotlin.Int
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ fun normalize(): sun.util.calendar.BaseCalendar.Date?
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ fun normalize(/*0*/ p0: sun.util.calendar.BaseCalendar.Date?): sun.util.calendar.BaseCalendar.Date?
|
||||||
|
invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream?): kotlin.Unit
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setDate(/*0*/ p0: kotlin.Int): kotlin.Unit
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setDate(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setHours(/*0*/ p0: kotlin.Int): kotlin.Unit
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setHours(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setMinutes(/*0*/ p0: kotlin.Int): kotlin.Unit
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setMinutes(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
@@ -23,4 +30,5 @@ public abstract class ClassDoesNotOverrideMethod : java.util.Date {
|
|||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setYear(/*0*/ p0: kotlin.Int): kotlin.Unit
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun setYear(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun toGMTString(): kotlin.String
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun toGMTString(): kotlin.String
|
||||||
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun toLocaleString(): kotlin.String
|
kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open override /*1*/ /*fake_override*/ fun toLocaleString(): kotlin.String
|
||||||
|
invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream?): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -17,6 +17,8 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList<kotlin.String
|
|||||||
public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator<kotlin.String>
|
public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator<kotlin.String>
|
||||||
public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator<kotlin.String>
|
public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator<kotlin.String>
|
||||||
|
invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String?
|
||||||
|
invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String
|
||||||
public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package test
|
|||||||
public final class InheritJavaField : test.Super {
|
public final class InheritJavaField : test.Super {
|
||||||
public constructor InheritJavaField()
|
public constructor InheritJavaField()
|
||||||
public final override /*1*/ /*fake_override*/ var field: kotlin.Int
|
public final override /*1*/ /*fake_override*/ var field: kotlin.Int
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var privateField: kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun method(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun method(): kotlin.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
public open class Super : java.lang.Object {
|
public open class Super : java.lang.Object {
|
||||||
public constructor Super()
|
public constructor Super()
|
||||||
public final var field: kotlin.Int
|
public final var field: kotlin.Int
|
||||||
|
private final var privateField: kotlin.Int
|
||||||
public open fun method(): kotlin.Int
|
public open fun method(): kotlin.Int
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -64,6 +64,16 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
|||||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/PackageLocalVisibility.java");
|
doTestCompiledJava("compiler/testData/loadJava/compiledJava/PackageLocalVisibility.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PrivateMembers.java")
|
||||||
|
public void testPrivateMembers() throws Exception {
|
||||||
|
doTestCompiledJava("compiler/testData/loadJava/compiledJava/PrivateMembers.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PrivateMembersInHierarchy.java")
|
||||||
|
public void testPrivateMembersInHierarchy() throws Exception {
|
||||||
|
doTestCompiledJava("compiler/testData/loadJava/compiledJava/PrivateMembersInHierarchy.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("RawTypeWithUpperBound.java")
|
@TestMetadata("RawTypeWithUpperBound.java")
|
||||||
public void testRawTypeWithUpperBound() throws Exception {
|
public void testRawTypeWithUpperBound() throws Exception {
|
||||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java");
|
doTestCompiledJava("compiler/testData/loadJava/compiledJava/RawTypeWithUpperBound.java");
|
||||||
|
|||||||
+1
-7
@@ -41,13 +41,7 @@ object EMPTY_MEMBER_INDEX : MemberIndex {
|
|||||||
override fun getAllFieldNames() = listOf<Name>()
|
override fun getAllFieldNames() = listOf<Name>()
|
||||||
}
|
}
|
||||||
|
|
||||||
open class ClassMemberIndex(val jClass: JavaClass, filter: (JavaMember) -> Boolean) : MemberIndex {
|
open class ClassMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember) -> Boolean) : MemberIndex {
|
||||||
private val memberFilter = {
|
|
||||||
(m: JavaMember) ->
|
|
||||||
filter(m) &&
|
|
||||||
m.getVisibility() != Visibilities.PRIVATE
|
|
||||||
}
|
|
||||||
|
|
||||||
private val methodFilter = {
|
private val methodFilter = {
|
||||||
(m: JavaMethod) ->
|
(m: JavaMethod) ->
|
||||||
memberFilter(m) &&
|
memberFilter(m) &&
|
||||||
|
|||||||
@@ -346,9 +346,10 @@ public class OverridingUtil {
|
|||||||
@NotNull DescriptorSink sink
|
@NotNull DescriptorSink sink
|
||||||
) {
|
) {
|
||||||
Collection<CallableMemberDescriptor> visibleOverridables = filterVisibleFakeOverrides(current, overridables);
|
Collection<CallableMemberDescriptor> visibleOverridables = filterVisibleFakeOverrides(current, overridables);
|
||||||
Modality modality = getMinimalModality(visibleOverridables);
|
|
||||||
boolean allInvisible = visibleOverridables.isEmpty();
|
boolean allInvisible = visibleOverridables.isEmpty();
|
||||||
Collection<CallableMemberDescriptor> effectiveOverridden = allInvisible ? overridables : visibleOverridables;
|
Collection<CallableMemberDescriptor> effectiveOverridden = allInvisible ? overridables : visibleOverridables;
|
||||||
|
|
||||||
|
Modality modality = getMinimalModality(effectiveOverridden);
|
||||||
Visibility visibility = allInvisible ? Visibilities.INVISIBLE_FAKE : Visibilities.INHERITED;
|
Visibility visibility = allInvisible ? Visibilities.INVISIBLE_FAKE : Visibilities.INHERITED;
|
||||||
CallableMemberDescriptor mostSpecific = selectMostSpecificMemberFromSuper(effectiveOverridden);
|
CallableMemberDescriptor mostSpecific = selectMostSpecificMemberFromSuper(effectiveOverridden);
|
||||||
CallableMemberDescriptor fakeOverride =
|
CallableMemberDescriptor fakeOverride =
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ public class GenerateMockJdk {
|
|||||||
"javax/swing/SwingConstants.class",
|
"javax/swing/SwingConstants.class",
|
||||||
"javax/swing/SwingUtilities.class",
|
"javax/swing/SwingUtilities.class",
|
||||||
"javax/swing/table/TableModel.class",
|
"javax/swing/table/TableModel.class",
|
||||||
|
"sun/util/calendar/BaseCalendar.class",
|
||||||
"META-INF/",
|
"META-INF/",
|
||||||
"META-INF/MANIFEST.MF",
|
"META-INF/MANIFEST.MF",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user