blob: fb1315cc04be4869f175dd1e1969cf500b9808c5 [file] [edit]
/*
* Copyright 2026 Google LLC
* Copyright 2010-2026 JetBrains s.r.o. and Kotlin Programming Language contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TEST PROCESSOR: VarArgAnnotationApplicationProcessor
// PROCESSOR INPUT: lib.MyLibClass, com.example.MyMainClass, com.example.MyJavaClass
// EXPECTED:
// lib.MyLibClass: @MyAnnotationWithDefault[value:[]]
// lib.MyLibClass: @MyAnnotationWithoutDefault[value:[]]
// lib.MyLibClass: @MyNestedVarArgAnnotation[nested:@MyVarArgAnnotation[value:[]]]
// lib.MyLibClass: @MyVarArgAnnotation[value:[]]
// lib.MyLibClass: @MyVarArgAnnotationPrefix[x:42, value:[]]
// lib.MyLibClass: @MyVarArgAnnotationPrefixDefault[value:[], x:42]
// lib.MyLibClass: @MyVarArgAnnotationSuffix[x:42, value:[]]
// lib.MyLibClass: @MyVarArgAnnotationSuffixDefault[value:[], x:42]
// lib.MyLibClass: @MyVarArgAnnotationPrefixSuffix[x:42, y:true, value:[]]
// lib.MyLibClass: @MyVarArgAnnotationPrefixDefaultSuffix[y:true, value:[], x:42]
// lib.MyLibClass: @MyVarArgAnnotationPrefixDefaultSuffixDefault[value:[], x:42, y:true]
// lib.MyLibClass: @MyVarArgAnnotationPrefixSuffixDefault[x:42, value:[], y:true]
// lib.MyLibClass: @MyJavaAnnotationWithDefault[value:[]]
// lib.MyLibClass: @MyJavaAnnotationWithoutDefault[value:[]]
// lib.MyLibClass: @MyJavaAnnotationPrefix[x:42, value:[]]
// lib.MyLibClass: @MyJavaAnnotationPrefixDefault[value:[], x:42]
// lib.MyLibClass: @MyJavaAnnotationSuffix[x:42, value:[]]
// lib.MyLibClass: @MyJavaAnnotationSuffixDefault[value:[], x:42]
// lib.MyLibClass: @MyJavaAnnotationAppliedSuffixDefault[value:[a, b], x:42]
// lib.MyLibClass: @MyJavaAnnotationPrefixSuffix[x:42, y:true, value:[]]
// lib.MyLibClass: @MyJavaAnnotationPrefixDefaultSuffix[y:true, value:[], x:42]
// lib.MyLibClass: @MyJavaAnnotationPrefixDefaultSuffixDefault[value:[], x:42, y:true]
// lib.MyLibClass: @MyJavaAnnotationPrefixSuffixDefault[x:42, value:[], y:true]
// lib.MyLibClass: @MyAliasedVarArgAnnotation[value:[]]
// lib.MyLibClass: @MyAliasedNestedVarArgAnnotation[value:@MyAliasedVarArgAnnotation[value:[]]]
// com.example.MyMainClass: @MyAnnotationWithDefault[value:[]]
// com.example.MyMainClass: @MyAnnotationWithoutDefault[value:[]]
// com.example.MyMainClass: @MyNestedVarArgAnnotation[nested:@MyVarArgAnnotation[value:[]]]
// com.example.MyMainClass: @MyVarArgAnnotation[value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefix[x:42, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefixDefault[x:42, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationSuffix[x:42, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationSuffixDefault[x:42, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefixSuffix[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefixDefaultSuffix[y:true, x:42, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefixDefaultSuffixDefault[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyVarArgAnnotationPrefixSuffixDefault[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationWithDefault[value:[]]
// com.example.MyMainClass: @MyJavaAnnotationWithoutDefault[value:[]]
// com.example.MyMainClass: @MyJavaAnnotationPrefix[x:42, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationPrefixDefault[x:42, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationSuffix[x:42, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationSuffixDefault[x:42, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationAppliedSuffixDefault[value:[a, b], x:42]
// com.example.MyMainClass: @MyJavaAnnotationPrefixSuffix[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationPrefixDefaultSuffix[y:true, x:42, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationPrefixDefaultSuffixDefault[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyJavaAnnotationPrefixSuffixDefault[x:42, y:true, value:[]]
// com.example.MyMainClass: @MyJavaSourceAnnotationAppliedSuffixDefault[value:[a, b], x:42]
// com.example.MyMainClass: @MyJavaSourceAnnotationWithDefault[value:[a, b, c]]
// com.example.MyMainClass: @MyJavaSourceAnnotationWithoutDefault[value:[]]
// com.example.MyMainClass: @MyTypeAlias[value:[]]
// com.example.MyMainClass: @MyNestedTypeAlias[value:@MyAliasedVarArgAnnotation[value:[]]]
// com.example.MyMainClass: @MyNestedKotlinSourceAnnotation[value:@MyJavaSourceAnnotationWithoutDefault[value:[]]]
// com.example.MyMainClass: @MyVarargNestedKotlinSourceAnnotation[value:[@MyJavaSourceAnnotationWithoutDefault[value:[]]]]
// com.example.MyJavaClass: @JavaApplyToNull[values:null]
// END
// MODULE: annos
// FILE: Annos.kt
package annotations
annotation class MyAnnotationWithDefault(val value: Array<String> = [])
annotation class MyAnnotationWithoutDefault(val value: Array<String>)
annotation class MyVarArgAnnotation(vararg val value: String)
annotation class MyVarArgAnnotationPrefix(val x: Int, vararg val value: Byte)
annotation class MyVarArgAnnotationPrefixDefault(val x: Int = 42, vararg val value: Boolean)
annotation class MyVarArgAnnotationSuffix(vararg val value: Char, val x: Int)
annotation class MyVarArgAnnotationSuffixDefault(vararg val value: String, val x: Int = 42)
annotation class MyVarArgAnnotationPrefixSuffix(val x: Int, vararg val value: String, val y: Boolean)
annotation class MyVarArgAnnotationPrefixDefaultSuffix(val x: Int = 42, vararg val value: String, val y: Boolean)
annotation class MyVarArgAnnotationPrefixDefaultSuffixDefault(val x: Int = 42, vararg val value: String, val y: Boolean = true)
annotation class MyVarArgAnnotationPrefixSuffixDefault(val x: Int, vararg val value: String, val y: Boolean = true)
annotation class MyNestedVarArgAnnotation(val nested: MyVarArgAnnotation)
annotation class MyAliasedVarArgAnnotation(vararg val value: String)
typealias MyTypeAlias = MyAliasedVarArgAnnotation
annotation class MyAliasedNestedVarArgAnnotation(val value: MyTypeAlias)
typealias MyNestedTypeAlias = MyAliasedNestedVarArgAnnotation
// FILE: MyJavaAnnotationWithDefault.java
package annotations;
public @interface MyJavaAnnotationWithDefault {
String[] value() default {};
}
// FILE: MyJavaAnnotationWithoutDefault.java
package annotations;
public @interface MyJavaAnnotationWithoutDefault {
String[] value();
}
// FILE: MyJavaAnnotationPrefix.java
package annotations;
public @interface MyJavaAnnotationPrefix {
int x();
String[] value();
}
// FILE: MyJavaAnnotationPrefixDefault.java
package annotations;
public @interface MyJavaAnnotationPrefixDefault {
int x() default 42;
String[] value();
}
// FILE: MyJavaAnnotationSuffix.java
package annotations;
public @interface MyJavaAnnotationSuffix {
String[] value();
int x();
}
// FILE: MyJavaAnnotationSuffixDefault.java
package annotations;
public @interface MyJavaAnnotationSuffixDefault {
String[] value();
int x() default 42;
}
// FILE: MyJavaAnnotationAppliedSuffixDefault.java
package annotations;
public @interface MyJavaAnnotationAppliedSuffixDefault {
String[] value();
int x() default 42;
}
// FILE: MyJavaAnnotationPrefixSuffix.java
package annotations;
public @interface MyJavaAnnotationPrefixSuffix {
int x();
String[] value();
boolean y();
}
// FILE: MyJavaAnnotationPrefixDefaultSuffix.java
package annotations;
public @interface MyJavaAnnotationPrefixDefaultSuffix {
int x() default 42;
String[] value();
boolean y();
}
// FILE: MyJavaAnnotationPrefixDefaultSuffixDefault.java
package annotations;
public @interface MyJavaAnnotationPrefixDefaultSuffixDefault {
int x() default 42;
String[] value();
boolean y() default true;
}
// FILE: MyJavaAnnotationPrefixSuffixDefault.java
package annotations;
public @interface MyJavaAnnotationPrefixSuffixDefault {
int x();
String[] value();
boolean y() default true;
}
// FILE: JavaApplyToNull.java
package annotations;
public @interface JavaApplyToNull {
String[] values();
}
// MODULE: lib(annos)
// FILE: MyLibClass.kt
package lib
import annotations.MyAnnotationWithDefault
import annotations.MyAnnotationWithoutDefault
import annotations.MyNestedVarArgAnnotation
import annotations.MyVarArgAnnotation
import annotations.MyVarArgAnnotationPrefix
import annotations.MyVarArgAnnotationPrefixDefault
import annotations.MyVarArgAnnotationSuffix
import annotations.MyVarArgAnnotationSuffixDefault
import annotations.MyVarArgAnnotationPrefixSuffix
import annotations.MyVarArgAnnotationPrefixDefaultSuffix
import annotations.MyVarArgAnnotationPrefixDefaultSuffixDefault
import annotations.MyVarArgAnnotationPrefixSuffixDefault
import annotations.MyJavaAnnotationWithDefault
import annotations.MyJavaAnnotationWithoutDefault
import annotations.MyJavaAnnotationPrefix
import annotations.MyJavaAnnotationPrefixDefault
import annotations.MyJavaAnnotationSuffix
import annotations.MyJavaAnnotationSuffixDefault
import annotations.MyJavaAnnotationAppliedSuffixDefault
import annotations.MyJavaAnnotationPrefixSuffix
import annotations.MyJavaAnnotationPrefixDefaultSuffix
import annotations.MyJavaAnnotationPrefixDefaultSuffixDefault
import annotations.MyJavaAnnotationPrefixSuffixDefault
import annotations.MyTypeAlias
import annotations.MyNestedTypeAlias
@MyAnnotationWithDefault
@MyAnnotationWithoutDefault([])
@MyNestedVarArgAnnotation(MyVarArgAnnotation())
@MyVarArgAnnotation
@MyVarArgAnnotationPrefix(42)
@MyVarArgAnnotationPrefixDefault
@MyVarArgAnnotationSuffix(x = 42)
@MyVarArgAnnotationSuffixDefault
@MyVarArgAnnotationPrefixSuffix(x = 42, y = true)
@MyVarArgAnnotationPrefixDefaultSuffix(y = true)
@MyVarArgAnnotationPrefixDefaultSuffixDefault
@MyVarArgAnnotationPrefixSuffixDefault(x = 42)
@MyJavaAnnotationWithDefault
@MyJavaAnnotationWithoutDefault
@MyJavaAnnotationPrefix(x = 42)
@MyJavaAnnotationPrefixDefault
@MyJavaAnnotationSuffix(x = 42)
@MyJavaAnnotationSuffixDefault
@MyJavaAnnotationAppliedSuffixDefault("a", "b")
@MyJavaAnnotationPrefixSuffix(x = 42, y = true)
@MyJavaAnnotationPrefixDefaultSuffix(y = true)
@MyJavaAnnotationPrefixDefaultSuffixDefault
@MyJavaAnnotationPrefixSuffixDefault(x = 42)
@MyTypeAlias
@MyNestedTypeAlias(MyTypeAlias())
class MyLibClass
// MODULE: main(lib, annos)
// FILE: MyMainClass.kt
package com.example
import annotations.MyAnnotationWithDefault
import annotations.MyAnnotationWithoutDefault
import annotations.MyNestedVarArgAnnotation
import annotations.MyVarArgAnnotation
import annotations.MyVarArgAnnotationPrefix
import annotations.MyVarArgAnnotationPrefixDefault
import annotations.MyVarArgAnnotationSuffix
import annotations.MyVarArgAnnotationSuffixDefault
import annotations.MyVarArgAnnotationPrefixSuffix
import annotations.MyVarArgAnnotationPrefixDefaultSuffix
import annotations.MyVarArgAnnotationPrefixDefaultSuffixDefault
import annotations.MyVarArgAnnotationPrefixSuffixDefault
import annotations.MyJavaAnnotationWithDefault
import annotations.MyJavaAnnotationWithoutDefault
import annotations.MyJavaAnnotationPrefix
import annotations.MyJavaAnnotationPrefixDefault
import annotations.MyJavaAnnotationSuffix
import annotations.MyJavaAnnotationSuffixDefault
import annotations.MyJavaAnnotationAppliedSuffixDefault
import annotations.MyJavaAnnotationPrefixSuffix
import annotations.MyJavaAnnotationPrefixDefaultSuffix
import annotations.MyJavaAnnotationPrefixDefaultSuffixDefault
import annotations.MyJavaAnnotationPrefixSuffixDefault
import annotations.MyTypeAlias
import annotations.MyNestedTypeAlias
@MyAnnotationWithDefault
@MyAnnotationWithoutDefault([])
@MyNestedVarArgAnnotation(MyVarArgAnnotation())
@MyVarArgAnnotation
@MyVarArgAnnotationPrefix(42)
@MyVarArgAnnotationPrefixDefault
@MyVarArgAnnotationSuffix(x = 42)
@MyVarArgAnnotationSuffixDefault
@MyVarArgAnnotationPrefixSuffix(x = 42, y = true)
@MyVarArgAnnotationPrefixDefaultSuffix(y = true)
@MyVarArgAnnotationPrefixDefaultSuffixDefault
@MyVarArgAnnotationPrefixSuffixDefault(x = 42)
@MyJavaAnnotationWithDefault
@MyJavaAnnotationWithoutDefault
@MyJavaAnnotationPrefix(x = 42)
@MyJavaAnnotationPrefixDefault
@MyJavaAnnotationSuffix(x = 42)
@MyJavaAnnotationSuffixDefault
@MyJavaAnnotationAppliedSuffixDefault("a", "b")
@MyJavaAnnotationPrefixSuffix(x = 42, y = true)
@MyJavaAnnotationPrefixDefaultSuffix(y = true)
@MyJavaAnnotationPrefixDefaultSuffixDefault
@MyJavaAnnotationPrefixSuffixDefault(x = 42)
@MyJavaSourceAnnotationAppliedSuffixDefault("a", "b")
@MyJavaSourceAnnotationWithDefault
@MyJavaSourceAnnotationWithoutDefault
@MyTypeAlias
@MyNestedTypeAlias(MyTypeAlias())
@MyNestedKotlinSourceAnnotation(MyJavaSourceAnnotationWithoutDefault())
@MyVarargNestedKotlinSourceAnnotation(MyJavaSourceAnnotationWithoutDefault())
class MyMainClass
// FILE: MyJavaClass.java
package com.example;
import annotations.JavaApplyToNull;
@JavaApplyToNull(null)
class MyJavaClass {
}
// FILE: MyJavaSourceAnnotationAppliedSuffixDefault.java
package com.example;
public @interface MyJavaSourceAnnotationAppliedSuffixDefault {
String[] value();
int x() default 42;
}
// FILE: MyJavaSourceAnnotationWithoutDefault.java
package com.example;
public @interface MyJavaSourceAnnotationWithoutDefault {
int[] value();
}
// FILE: MyJavaSourceAnnotationWithDefault.java
package com.example;
public @interface MyJavaSourceAnnotationWithDefault {
String[] value() default { "a", "b", "c" };
}
// FILE: MyNestedKotlinSourceAnnotation.kt
package com.example
annotation class MyNestedKotlinSourceAnnotation(val value: MyJavaSourceAnnotationWithoutDefault)
// FILE: MyVarargNestedKotlinSourceAnnotation.kt
package com.example
annotation class MyVarargNestedKotlinSourceAnnotation(vararg val value: MyJavaSourceAnnotationWithoutDefault)