019836e9c7
Fake overrides created by K1, as well as fir2ir in K2, use DEFINED. So this gets rid of a lot of differences in IR text dumps between the K2 normal mode and K2 with IR fake overrides, and will ultimately help in implementing and testing KT-61360. The change in AddContinuationLowering is needed to fix tests like kt47549. When creating anonymous classes for SAM implementations, we're reusing the same fake override building machinery. And since we can't extract any meaningful information from the fake override parameter's origin anymore, we have to get the parameter from the original symbol.
60 lines
1.4 KiB
Kotlin
Vendored
60 lines
1.4 KiB
Kotlin
Vendored
// WITH_STDLIB
|
|
// WITH_REFLECT
|
|
// TARGET_BACKEND: JVM_IR
|
|
// FIR_DUMP
|
|
// DUMP_IR
|
|
|
|
// FILE: NoTarget.java
|
|
import java.lang.annotation.*;
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
public @interface NoTarget {
|
|
}
|
|
|
|
// FILE: PropValueField.java
|
|
import java.lang.annotation.*;
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
|
public @interface PropValueField {
|
|
}
|
|
|
|
// FILE: ParameterOnly.java
|
|
import java.lang.annotation.*;
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
@Target({ElementType.PARAMETER})
|
|
public @interface ParameterOnly {
|
|
}
|
|
|
|
// FILE: FieldOnly.java
|
|
import java.lang.annotation.*;
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
@Target({ElementType.FIELD})
|
|
public @interface FieldOnly {
|
|
}
|
|
|
|
// FILE: test.kt
|
|
import kotlin.reflect.full.declaredMemberProperties
|
|
|
|
class Foo(
|
|
@NoTarget
|
|
@PropValueField
|
|
@ParameterOnly
|
|
@FieldOnly
|
|
var param: Int
|
|
)
|
|
|
|
fun box(): String {
|
|
val clazz = Foo::class
|
|
|
|
val parameterAnnotations = clazz.constructors.single().parameters.single().annotations.map { it.annotationClass.simpleName ?: "" }.toSet()
|
|
val fieldAnnotations = Foo::class.java.getDeclaredField("param").annotations.map { it.annotationClass.simpleName ?: "" }.toSet()
|
|
|
|
if (parameterAnnotations != setOf("NoTarget", "PropValueField", "ParameterOnly")) return "Parameters:" + parameterAnnotations
|
|
if (fieldAnnotations != setOf("FieldOnly")) return "Field:" + fieldAnnotations
|
|
|
|
return "OK"
|
|
}
|