Fix KT-47708 in FIR by transferring SAM annotations to synthetic constr.

This commit is contained in:
Mikhail Glukhikh
2022-04-20 12:41:14 +03:00
committed by Space
parent 9b6430d455
commit 6f17a8713c
14 changed files with 160 additions and 32 deletions
@@ -0,0 +1,21 @@
// FIR_DUMP
@RequiresOptIn
annotation class ExperimentalKotlinAnnotation
internal fun interface StableInterface {
@ExperimentalKotlinAnnotation // @ExperimentalStdlibApi
fun experimentalMethod()
}
fun regressionTestOverrides() {
val anonymous: StableInterface = object : StableInterface {
override fun <!OPT_IN_OVERRIDE_ERROR!>experimentalMethod<!>() {} // correctly fails check
}
val lambda = <!OPT_IN_USAGE_ERROR!>StableInterface<!> {} // this does not get flagged
}
@ExperimentalKotlinAnnotation
fun suppressed() {
val lambda = StableInterface {}
}
@@ -0,0 +1,33 @@
FILE: insideSAM.fir.kt
@R|kotlin/RequiresOptIn|() public final annotation class ExperimentalKotlinAnnotation : R|kotlin/Annotation| {
public constructor(): R|ExperimentalKotlinAnnotation| {
super<R|kotlin/Any|>()
}
}
internal abstract fun interface StableInterface : R|kotlin/Any| {
@R|ExperimentalKotlinAnnotation|() public abstract fun experimentalMethod(): R|kotlin/Unit|
}
public final fun regressionTestOverrides(): R|kotlin/Unit| {
lval anonymous: R|StableInterface| = object : R|StableInterface| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public final override fun experimentalMethod(): R|kotlin/Unit| {
}
}
lval lambda: R|StableInterface| = R|/StableInterface|(<L> = StableInterface@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
^@StableInterface Unit
}
)
}
@R|ExperimentalKotlinAnnotation|() public final fun suppressed(): R|kotlin/Unit| {
lval lambda: R|StableInterface| = R|/StableInterface|(<L> = StableInterface@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
^@StableInterface Unit
}
)
}
@@ -0,0 +1,21 @@
// FIR_DUMP
@RequiresOptIn
annotation class ExperimentalKotlinAnnotation
internal fun interface StableInterface {
@ExperimentalKotlinAnnotation // @ExperimentalStdlibApi
fun experimentalMethod()
}
fun regressionTestOverrides() {
val anonymous: StableInterface = object : StableInterface {
override fun <!OPT_IN_OVERRIDE_ERROR!>experimentalMethod<!>() {} // correctly fails check
}
val lambda = StableInterface {} // this does not get flagged
}
@ExperimentalKotlinAnnotation
fun suppressed() {
val lambda = StableInterface {}
}
@@ -0,0 +1,19 @@
package
public fun regressionTestOverrides(): kotlin.Unit
@ExperimentalKotlinAnnotation public fun suppressed(): kotlin.Unit
@kotlin.RequiresOptIn public final annotation class ExperimentalKotlinAnnotation : kotlin.Annotation {
public constructor ExperimentalKotlinAnnotation()
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
}
internal fun interface StableInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@ExperimentalKotlinAnnotation public abstract fun experimentalMethod(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}