Fix FirAnnotationArgumentChecker (String + ... case) #KT-44995 Fixed
This commit is contained in:
Vendored
+15
@@ -17,3 +17,18 @@ FILE: nonConstValInAnnotationArgument.kt
|
|||||||
public get(): R|kotlin/Int|
|
public get(): R|kotlin/Int|
|
||||||
@R|Ann|(<implicitArrayOf>(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/cnst|.R|kotlin/Any.toString|()))) public final fun test(): R|kotlin/Unit| {
|
@R|Ann|(<implicitArrayOf>(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/cnst|.R|kotlin/Any.toString|()))) public final fun test(): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
|
public final const val A: R|kotlin/String| = String(foo)
|
||||||
|
public get(): R|kotlin/String|
|
||||||
|
public final const val B: R|kotlin/Int| = Int(100)
|
||||||
|
public get(): R|kotlin/Int|
|
||||||
|
public final annotation class S : R|kotlin/Annotation| {
|
||||||
|
public constructor(s: R|kotlin/String|): R|S| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final val s: R|kotlin/String| = R|<local>/s|
|
||||||
|
public get(): R|kotlin/String|
|
||||||
|
|
||||||
|
}
|
||||||
|
@R|S|(R|/A|.R|kotlin/String.plus|(R|/B|)) public final fun foo(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+8
@@ -11,3 +11,11 @@ const val cnst = 2
|
|||||||
)<!>
|
)<!>
|
||||||
)
|
)
|
||||||
fun test() {}
|
fun test() {}
|
||||||
|
|
||||||
|
const val A = "foo"
|
||||||
|
const val B = 100
|
||||||
|
|
||||||
|
annotation class S(val s: String)
|
||||||
|
|
||||||
|
@S(A + B)
|
||||||
|
fun foo() {}
|
||||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
|||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall
|
import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds.primitiveTypesAndString
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -168,7 +169,7 @@ object FirAnnotationArgumentChecker : FirBasicDeclarationChecker() {
|
|||||||
|
|
||||||
if (calleeReference.name == PLUS
|
if (calleeReference.name == PLUS
|
||||||
&& expClassId != receiverClassId
|
&& expClassId != receiverClassId
|
||||||
&& (expClassId !in StandardClassIds.primitiveTypes || receiverClassId !in StandardClassIds.primitiveTypes)
|
&& (expClassId !in primitiveTypesAndString || receiverClassId !in primitiveTypesAndString)
|
||||||
)
|
)
|
||||||
return FirErrors.ANNOTATION_ARGUMENT_MUST_BE_CONST
|
return FirErrors.ANNOTATION_ARGUMENT_MUST_BE_CONST
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ object StandardClassIds {
|
|||||||
Byte, Short, Int, Long,
|
Byte, Short, Int, Long,
|
||||||
Float, Double
|
Float, Double
|
||||||
)
|
)
|
||||||
|
val primitiveTypesAndString = primitiveTypes + String
|
||||||
|
|
||||||
val primitiveArrayTypeByElementType = primitiveTypes.associate { id -> id to id.shortClassName.primitiveArrayId() }
|
val primitiveArrayTypeByElementType = primitiveTypes.associate { id -> id to id.shortClassName.primitiveArrayId() }
|
||||||
val elementTypeByPrimitiveArrayType = primitiveArrayTypeByElementType.inverseMap()
|
val elementTypeByPrimitiveArrayType = primitiveArrayTypeByElementType.inverseMap()
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_FIR_DIAGNOSTICS
|
|
||||||
// WITH_REFLECT
|
// WITH_REFLECT
|
||||||
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|||||||
Reference in New Issue
Block a user