Inline callable: keep all usages inside annotation entries
#KT-24596 Fixed
This commit is contained in:
@@ -81,6 +81,7 @@ class CodeInliner<TCallElement : KtElement>(
|
|||||||
&& elementToBeReplaced is KtExpression
|
&& elementToBeReplaced is KtExpression
|
||||||
&& !elementToBeReplaced.isUsedAsExpression(bindingContext)
|
&& !elementToBeReplaced.isUsedAsExpression(bindingContext)
|
||||||
&& !codeToInline.mainExpression.shouldKeepValue(usageCount = 0)
|
&& !codeToInline.mainExpression.shouldKeepValue(usageCount = 0)
|
||||||
|
&& elementToBeReplaced.getStrictParentOfType<KtAnnotationEntry>() == null
|
||||||
) {
|
) {
|
||||||
codeToInline.mainExpression = null
|
codeToInline.mainExpression = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ annotation class ExprAnn(val value: String)
|
|||||||
val inProperty = TAG
|
val inProperty = TAG
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val x = @ExprAnn(TAG) inProperty
|
@InAnn("Local $TAG") val x = @ExprAnn(TAG) inProperty
|
||||||
}
|
}
|
||||||
+2
-2
@@ -10,7 +10,7 @@ annotation class InAnn(val value: String)
|
|||||||
|
|
||||||
@InAnn("This is also Tagged") fun bar() {}
|
@InAnn("This is also Tagged") fun bar() {}
|
||||||
|
|
||||||
fun baz(@InAnn("This is ${} too") x: Int) {}
|
fun baz(@InAnn("This is Tagged too") x: Int) {}
|
||||||
|
|
||||||
@Target(AnnotationTarget.EXPRESSION)
|
@Target(AnnotationTarget.EXPRESSION)
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
@@ -19,5 +19,5 @@ annotation class ExprAnn(val value: String)
|
|||||||
val inProperty = "Tagged"
|
val inProperty = "Tagged"
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val x = @ExprAnn() inProperty
|
@InAnn("Local Tagged") val x = @ExprAnn("Tagged") inProperty
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user