Inline callable: keep all usages inside annotation entries

#KT-24596 Fixed
This commit is contained in:
Mikhail Glukhikh
2019-07-10 11:23:46 +03:00
parent eb00af6b96
commit ee37a0aa9f
3 changed files with 4 additions and 3 deletions
@@ -81,6 +81,7 @@ class CodeInliner<TCallElement : KtElement>(
&& elementToBeReplaced is KtExpression
&& !elementToBeReplaced.isUsedAsExpression(bindingContext)
&& !codeToInline.mainExpression.shouldKeepValue(usageCount = 0)
&& elementToBeReplaced.getStrictParentOfType<KtAnnotationEntry>() == null
) {
codeToInline.mainExpression = null
}
@@ -21,5 +21,5 @@ annotation class ExprAnn(val value: String)
val inProperty = TAG
fun foo() {
val x = @ExprAnn(TAG) inProperty
@InAnn("Local $TAG") val x = @ExprAnn(TAG) inProperty
}
@@ -10,7 +10,7 @@ annotation class InAnn(val value: String)
@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)
@Retention(AnnotationRetention.SOURCE)
@@ -19,5 +19,5 @@ annotation class ExprAnn(val value: String)
val inProperty = "Tagged"
fun foo() {
val x = @ExprAnn() inProperty
@InAnn("Local Tagged") val x = @ExprAnn("Tagged") inProperty
}