[FIR] Fixed behavior of FirAnnotation.findArgumentByName for resolved annotations
The 'findArgumentByName' function was returning an invalid result for annotation arguments with omitted argument name. #KT-64276
This commit is contained in:
committed by
Space Team
parent
bb8c7dd04c
commit
d69240a2d5
+5
-3
@@ -132,9 +132,11 @@ fun FirAnnotation.findArgumentByName(name: Name): FirExpression? {
|
|||||||
return argument.expression
|
return argument.expression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// I'm lucky today!
|
|
||||||
// TODO: this line is still needed. However it should be replaced with 'return null'
|
// The condition is required for annotation arguments that are not fully resolved. For example, CompilerRequiredAnnotations.
|
||||||
return arguments.singleOrNull()
|
// When the annotation is resolved, and we did not find an argument with the given name,
|
||||||
|
// there is no argument and we should return null.
|
||||||
|
return if (!resolved) arguments.firstOrNull() else null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FirAnnotation.getBooleanArgument(name: Name): Boolean? = getPrimitiveArgumentValue(name)
|
fun FirAnnotation.getBooleanArgument(name: Name): Boolean? = getPrimitiveArgumentValue(name)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// FILE: kotlin.kt
|
||||||
|
@file:OptIn(ExperimentalObjCName::class)
|
||||||
|
|
||||||
|
package kotlin.native
|
||||||
|
|
||||||
|
import kotlin.experimental.ExperimentalObjCName
|
||||||
|
|
||||||
|
fun interface BaseInterface {
|
||||||
|
@ObjCName(name = "close")
|
||||||
|
fun close()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class BaseClass {
|
||||||
|
@ObjCName("close")
|
||||||
|
fun close() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DerivedClass : BaseClass(), BaseInterface {}
|
||||||
+6
@@ -108,6 +108,12 @@ public class DiagnosticsNativeTestGenerated extends AbstractDiagnosticsNativeTes
|
|||||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||||
|
public void testObjCNameWIthDifferentSwiftName() {
|
||||||
|
runTest("compiler/testData/diagnostics/nativeTests/objCNameWIthDifferentSwiftName.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("objCNameWithTwoModules.kt")
|
@TestMetadata("objCNameWithTwoModules.kt")
|
||||||
public void testObjCNameWithTwoModules() {
|
public void testObjCNameWithTwoModules() {
|
||||||
|
|||||||
+6
@@ -112,6 +112,12 @@ public class FirLightTreeOldFrontendNativeDiagnosticsTestGenerated extends Abstr
|
|||||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||||
|
public void testObjCNameWIthDifferentSwiftName() {
|
||||||
|
runTest("compiler/testData/diagnostics/nativeTests/objCNameWIthDifferentSwiftName.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("objCNameWithTwoModules.kt")
|
@TestMetadata("objCNameWithTwoModules.kt")
|
||||||
public void testObjCNameWithTwoModules() {
|
public void testObjCNameWithTwoModules() {
|
||||||
|
|||||||
+6
@@ -112,6 +112,12 @@ public class FirPsiOldFrontendNativeDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||||
|
public void testObjCNameWIthDifferentSwiftName() {
|
||||||
|
runTest("compiler/testData/diagnostics/nativeTests/objCNameWIthDifferentSwiftName.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("objCNameWithTwoModules.kt")
|
@TestMetadata("objCNameWithTwoModules.kt")
|
||||||
public void testObjCNameWithTwoModules() {
|
public void testObjCNameWithTwoModules() {
|
||||||
|
|||||||
Reference in New Issue
Block a user