Do not hide synthetic properties except isEmpty from Java
In order to hide synthetic property isEmpty from JDK 15, there was
added additional logic in 5cc12b49fc but
it also lead to the fact that now it's impossible to call synthetic
property `declaringClass` on `Enum` as it's in the same list as method
isEmpty(). Note that it's questionable behavior, probably we should
also hide `declaringClass` as well but for now we turn it back to
preserve compatibility
#KT-42467 Fixed
This commit is contained in:
Generated
+5
@@ -11045,6 +11045,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declaringClassOnEnumObject.kt")
|
||||
public void testDeclaringClassOnEnumObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/declaringClassOnEnumObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deepInnerClassInEnumEntryClass.kt")
|
||||
public void testDeepInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt");
|
||||
|
||||
+2
-2
@@ -162,7 +162,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
return descriptor.valueParameters.isEmpty()
|
||||
&& descriptor.typeParameters.isEmpty()
|
||||
&& descriptor.visibility.isVisibleOutside()
|
||||
&& !descriptor.isHiddenForResolutionEverywhereBesideSupercalls
|
||||
&& !(descriptor.isHiddenForResolutionEverywhereBesideSupercalls && descriptor.name.asString() == "isEmpty") // CharSequence.isEmpty() from JDK15
|
||||
}
|
||||
|
||||
private fun isGoodSetMethod(descriptor: FunctionDescriptor, getMethod: FunctionDescriptor): Boolean {
|
||||
@@ -179,7 +179,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
return parameter.varargElementType == null
|
||||
&& descriptor.typeParameters.isEmpty()
|
||||
&& descriptor.visibility.isVisibleOutside()
|
||||
&& !descriptor.isHiddenForResolutionEverywhereBesideSupercalls
|
||||
&& !(descriptor.isHiddenForResolutionEverywhereBesideSupercalls && descriptor.name.asString() == "isEmpty") // CharSequence.isEmpty() from JDK15
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.findOverridden(condition: (FunctionDescriptor) -> Boolean): FunctionDescriptor? {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
enum class KEnum { A }
|
||||
|
||||
fun test(e: KEnum): String {
|
||||
return e.declaringClass.toString()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = test(KEnum.A)
|
||||
return if (result == "class KEnum") "OK" else "fail: $result"
|
||||
}
|
||||
+5
@@ -12440,6 +12440,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declaringClassOnEnumObject.kt")
|
||||
public void testDeclaringClassOnEnumObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/declaringClassOnEnumObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deepInnerClassInEnumEntryClass.kt")
|
||||
public void testDeepInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt");
|
||||
|
||||
+5
@@ -12440,6 +12440,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declaringClassOnEnumObject.kt")
|
||||
public void testDeclaringClassOnEnumObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/declaringClassOnEnumObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deepInnerClassInEnumEntryClass.kt")
|
||||
public void testDeepInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt");
|
||||
|
||||
+5
@@ -11045,6 +11045,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declaringClassOnEnumObject.kt")
|
||||
public void testDeclaringClassOnEnumObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/declaringClassOnEnumObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deepInnerClassInEnumEntryClass.kt")
|
||||
public void testDeepInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user