[KAPT] Keep original expressions in annotations vararg
#KT-29929 Fixed
This commit is contained in:
+3
-1
@@ -1280,6 +1280,8 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
is KtCollectionLiteralExpression -> singleArg.getInnerExpressions()
|
is KtCollectionLiteralExpression -> singleArg.getInnerExpressions()
|
||||||
|
is KtDotQualifiedExpression -> listOf(singleArg)
|
||||||
|
null -> args
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,7 +1319,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
if (constantValue is List<*>) {
|
if (constantValue is List<*>) {
|
||||||
val callArgs = unwrapArgumentExpression()
|
val callArgs = unwrapArgumentExpression()
|
||||||
// So we make sure something is absent in the constant value
|
// So we make sure something is absent in the constant value
|
||||||
if (callArgs != null && callArgs.size != constantValue.size) {
|
if (callArgs != null && callArgs.size > constantValue.size) {
|
||||||
val literalExpressions = mapJList(callArgs, ::tryParseTypeLiteralExpression)
|
val literalExpressions = mapJList(callArgs, ::tryParseTypeLiteralExpression)
|
||||||
if (literalExpressions.size == callArgs.size) {
|
if (literalExpressions.size == callArgs.size) {
|
||||||
return treeMaker.NewArray(null, null, literalExpressions)
|
return treeMaker.NewArray(null, null, literalExpressions)
|
||||||
|
|||||||
@@ -44,11 +44,26 @@ public class B {
|
|||||||
public final static String a9 = "A";
|
public final static String a9 = "A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FILE: lib/OnClick.java
|
||||||
|
package lib;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface OnClick {
|
||||||
|
int[] value() default {};
|
||||||
|
}
|
||||||
|
|
||||||
//FILE: test.kt
|
//FILE: test.kt
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import lib.R as LibR
|
import lib.R as LibR
|
||||||
import lib.R.id.textView
|
import lib.R.id.textView
|
||||||
|
import lib.OnClick
|
||||||
|
|
||||||
annotation class Bind(val id: Int)
|
annotation class Bind(val id: Int)
|
||||||
|
|
||||||
@@ -133,6 +148,12 @@ class MyActivity {
|
|||||||
@MultiValueByte(ids = byteArrayOf(B.a2))
|
@MultiValueByte(ids = byteArrayOf(B.a2))
|
||||||
fun multi5() {}
|
fun multi5() {}
|
||||||
|
|
||||||
|
@OnClick(B.id.textView)
|
||||||
|
fun multiJava1() {}
|
||||||
|
|
||||||
|
@OnClick(B.id.textView, app.R.layout.mainActivity)
|
||||||
|
fun multiJava2() {}
|
||||||
|
|
||||||
const val propA = B.id.textView
|
const val propA = B.id.textView
|
||||||
val propB = B.id.textView
|
val propB = B.id.textView
|
||||||
var propC = B.id.textView
|
var propC = B.id.textView
|
||||||
|
|||||||
@@ -285,6 +285,14 @@ public final class MyActivity {
|
|||||||
public final void multi5() {
|
public final void multi5() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@lib.OnClick(value = {app.B.id.textView})
|
||||||
|
public final void multiJava1() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@lib.OnClick(value = {app.B.id.textView, app.R.layout.mainActivity})
|
||||||
|
public final void multiJava2() {
|
||||||
|
}
|
||||||
|
|
||||||
public final int getPropB() {
|
public final int getPropB() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -343,6 +351,22 @@ public class R2 {
|
|||||||
|
|
||||||
package lib;
|
package lib;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(value = ElementType.METHOD)
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
public @interface OnClick {
|
||||||
|
|
||||||
|
int[] value() default {};
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
package lib;
|
||||||
|
|
||||||
public class R {
|
public class R {
|
||||||
|
|
||||||
public R() {
|
public R() {
|
||||||
|
|||||||
Reference in New Issue
Block a user