[AllOpen] Do not open members of non-class type classes
The logic of the AllOpen compiler plugin for opening classes and opening declarations of classes does not match. This leads to declarations being open when the containing class is not open. There is a warning reported, for exactly this situation. However, creating meta-annotations of AllOpen annotation is quite common in certain ecosystems. In particular, Spring. This can lead to a warning if the meta-annotation has properties. Align the class kind check for members, so they are not opened if the containing class cannot be opened. ^KT-63507 Fixed
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ class FirAllOpenStatusTransformer(session: FirSession) : FirStatusTransformerExt
|
||||
if (parentClassId.isLocal) return false
|
||||
val parentClassSymbol = session.symbolProvider.getClassLikeSymbolByClassId(parentClassId) as? FirRegularClassSymbol
|
||||
?: return false
|
||||
session.allOpenPredicateMatcher.isAnnotated(parentClassSymbol)
|
||||
parentClassSymbol.classKind == ClassKind.CLASS && session.allOpenPredicateMatcher.isAnnotated(parentClassSymbol)
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-63507
|
||||
|
||||
annotation class AllOpen
|
||||
|
||||
@AllOpen
|
||||
annotation class SubComponent(
|
||||
val <!NON_FINAL_MEMBER_IN_FINAL_CLASS!>scope<!>: String
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-63507
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class AllOpen
|
||||
|
||||
@AllOpen
|
||||
annotation class ConsoleCommands(
|
||||
val <!NON_FINAL_MEMBER_IN_FINAL_CLASS!>value<!>: String = "",
|
||||
val <!NON_FINAL_MEMBER_IN_FINAL_CLASS!>scope<!>: String
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class AllOpen
|
||||
|
||||
Reference in New Issue
Block a user