Do not check backing field presence in AnnotationSplitter

This code can be invoked early, during body resolution and before the
fact that a property has backing field (which is only known for certain
after body resolution, because an implicit 'field' identifier may be
used). Since split annotations are cached until the end of the program,
they may end up on incorrect elements in the bytecode (or disappear
completely) as in KT-29507 or KT-28182.

Because the FIELD target has the lowest priority among implicit
annotation targets (see TARGET_PRIORITIES), it's safe to always assume
that FIELD is a valid target when splitting annotations. This only
changes the way annotations are split in case of incorrect code, as
changes in test data show.

 #KT-28182 Fixed
 #KT-29507 Fixed
This commit is contained in:
Alexander Udalov
2019-02-13 18:57:25 +01:00
parent 5595a2dd1b
commit 4692247897
6 changed files with 34 additions and 50 deletions
@@ -1,7 +1,7 @@
package
@field:Field public val x: kotlin.Int = 42
@Field public val y: kotlin.Int
@field:Field public val y: kotlin.Int
@Field public final annotation class Another : kotlin.Annotation {
public constructor Another()
@@ -18,8 +18,8 @@ package
}
public interface His {
@Field public abstract val x: kotlin.Int
@Field public open val y: kotlin.Int
@field:Field public abstract val x: kotlin.Int
@field:Field public open val y: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -27,11 +27,11 @@ public interface His {
@Field public abstract class My {
public constructor My(/*0*/ @Field arg: kotlin.Int, /*1*/ w: kotlin.Int)
@Field public final val v: kotlin.Int
@field:Field public final val v: kotlin.Int
@field:Field public final val w: kotlin.Int
@field:Field public final val x: kotlin.Int
@Field public final val y: kotlin.Int
@Field public abstract val z: kotlin.Int
@field:Field public final val y: kotlin.Int
@field:Field public abstract val z: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@Field public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int