Fix deserialization of default property accessor flags
In MemberDeserializer.loadProperty, we incorrectly passed 0 to getAnnotations when loading annotations on property accessors in case the protobuf field getter_flags/setter_flags was not present. The correct behavior, as described in metadata.proto, was to pass a special "default accessor flags" value, constructed from the main property flags. Otherwise in case there were annotations both on the property and on the accessor (as in PropertyAndAccessor.kt) and the accessor was otherwise default, we would assume that it had no annotations and would not load them in compiler and reflection #KT-25499 In Progress
This commit is contained in:
+3
-23
@@ -3,25 +3,6 @@
|
||||
|
||||
// Please make sure that this test is consistent with the diagnostic test "annotationsTargetingNonExistentAccessor.kt"
|
||||
|
||||
// FILE: Temporary.java
|
||||
|
||||
// see https://youtrack.jetbrains.com/issue/KT-25499
|
||||
|
||||
class Temporary {
|
||||
public static void checkX2FromStaticsHasAnnotations() {
|
||||
try {
|
||||
if (Statics.Companion.getClass().getDeclaredMethod("getX2").getAnnotations().length == 0) {
|
||||
throw new RuntimeException("there are no annotations");
|
||||
}
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
import kotlin.reflect.KAnnotatedElement
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@@ -152,9 +133,9 @@ class Statics {
|
||||
check(::x0.getter, annotationExists = false)
|
||||
check(::x1.getter, annotationExists = false)
|
||||
|
||||
check(::x2.getter, annotationExists = false) // https://youtrack.jetbrains.com/issue/KT-25499
|
||||
check(::x2.setter, annotationExists = false)
|
||||
check(::x2.setter.parameters.first(), annotationExists = false)
|
||||
check(::x2.getter, annotationExists = true)
|
||||
check(::x2.setter, annotationExists = true)
|
||||
check(::x2.setter.parameters.first(), annotationExists = false /* TODO */)
|
||||
|
||||
check(::x3.getter, annotationExists = false)
|
||||
|
||||
@@ -185,7 +166,6 @@ fun box(): String {
|
||||
PrivateProperties(0, "").test()
|
||||
EffetivelyPrivate.test()
|
||||
Statics().test()
|
||||
Temporary.checkX2FromStaticsHasAnnotations()
|
||||
Delegate().test()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user