Kapt: add some JeElement tests

(cherry picked from commit 948a4b6)
This commit is contained in:
Yan Zhulanow
2016-08-02 22:47:18 +03:00
committed by Yan Zhulanow
parent 0fc92c784b
commit 927280f7ce
51 changed files with 1154 additions and 14 deletions
@@ -0,0 +1,8 @@
@Deprecated("")
class MyClass {
var myProperty: String = "A"
fun myFunction() = object : java.lang.Runnable {
override fun run() {}
}
}
@@ -0,0 +1,13 @@
annotation class Anno(val name: String = "Mary", val age: Int = 20)
@Anno("Tom", 10)
class A
@Anno(name = "Tom")
class B
@Anno(age = 10)
class C
@Anno
class D
@@ -0,0 +1,6 @@
package test
@Deprecated("")
class MyClass
interface MyInterface
@@ -0,0 +1,7 @@
@Deprecated("")
class Depr
class NoDepr
@java.lang.Deprecated
class JavaDepr
@@ -0,0 +1,22 @@
class A {
interface AA {
fun onClick(o: Any)
}
}
enum class B { RED }
interface C {
fun onClick()
}
interface D {
fun onClick()
fun onDoubleClick()
}
interface E : C
interface F : C {
fun onDoubleClick()
}
@@ -0,0 +1,16 @@
@Deprecated("")
open class Parent {
open fun a() {}
}
open class Child : Parent() {
override fun a() {}
fun a(name: String) {}
open fun b() = "A"
}
class ChildOfChild : Child() {
override fun a() {}
override fun b() = "B"
fun a(name: CharSequence) {}
}
@@ -0,0 +1,12 @@
@Deprecated("")
interface Intf {
fun a()
}
open class A {
open fun a() {}
}
class B : A(), Intf {
override fun a() {}
}
@@ -0,0 +1,13 @@
// EnumClass
enum EnumClass {
RED, GREEN, BLUE;
void someMethod() {
System.out.println("Hello, world!")
}
String getStringRepresentation() {
return this.toString();
}
}
@@ -0,0 +1,11 @@
final enum EnumClass {
public static final EnumClass RED
public static final EnumClass GREEN
public static final EnumClass BLUE
void someMethod()
java.lang.String getStringRepresentation()
}
@@ -0,0 +1,13 @@
// MetaAnnotation
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Deprecated
@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface MetaAnnotation {
String strValue();
}
@@ -0,0 +1,6 @@
@java.lang.Deprecated
@java.lang.annotation.Target(value = { CONSTRUCTOR, FIELD })
@java.lang.annotation.Retention(value = RUNTIME)
public abstract @interface MetaAnnotation {
public abstract java.lang.String strValue()
}
@@ -0,0 +1,20 @@
// Simple
@KotlinAnnotation(a = "A", b = 5)
public abstract class Simple {
final String field = "A";
abstract void voidMethod();
static {
System.out.println("A");
}
{
System.out.println("b");
}
protected String strMethod(int param) {
return "A";
}
}
@@ -0,0 +1,12 @@
@KotlinAnnotation(a = "A", b = 5)
public abstract class Simple {
static {}
{}
final java.lang.String field
abstract void voidMethod()
protected java.lang.String strMethod(int param)
}
@@ -0,0 +1,21 @@
// WithNested
class WithNested {
void myClassFun() {}
static class NestedClass {
void nestedClassFun() {}
}
class InnerClass {
void innerClassFun() {}
class InnerInnerClass {
void innerInnerClassFun() {}
}
}
interface NestedInterface {
void nestedInterfaceFun() {}
}
}
@@ -0,0 +1,19 @@
class WithNested {
void myClassFun()
static class NestedClass {
void nestedClassFun()
}
class InnerClass {
void innerClassFun()
class InnerInnerClass {
void innerInnerClassFun()
}
}
static abstract interface NestedInterface {
public abstract void nestedInterfaceFun()
}
}
@@ -0,0 +1 @@
annotation class KotlinAnnotation(val a: String, val b: Int)
@@ -0,0 +1,31 @@
// test.Main
package test
@MainAnno("A", 5)
class Main {
@field:XAnno(color = Color.GREEN)
val x: String
@get:YAnno(arrayOf<String>("Mary", "Tom"), intArrayOf(1, 3, 5), arrayOf<Color>(Color.GREEN, Color.RED))
val y: String
@set:ZAnno(String::class, arrayOf(String::class, Long::class, Main::class))
var z: String
// Property annotations are lost here (we don't create Elements (javac API) for the synthetic propertyName$annotations() methods)
@MainAnno("B", 6)
val zz: String
}
enum class Color {
RED, GREEN, BLUE
}
annotation class MainAnno(val a: String, val b: Int)
annotation class XAnno(val color: Color)
annotation class YAnno(val names: Array<String>, val ints: Array<Int>, val colors: Array<Color>)
annotation class ZAnno(val clazz: Class<*>, val classes = Array<Class<*>>)
@@ -0,0 +1,33 @@
@test.MainAnno(a = "A", b = 5)
public final class Main {
@test.XAnno(color = GREEN)
@org.jetbrains.annotations.NotNull
private final java.lang.String x
@org.jetbrains.annotations.NotNull
private final java.lang.String y
@org.jetbrains.annotations.NotNull
private java.lang.String z
@org.jetbrains.annotations.NotNull
private final java.lang.String zz
@org.jetbrains.annotations.NotNull
public final java.lang.String getX()
@test.YAnno(names = { "Mary", "Tom" }, ints = { 1, 3, 5 }, colors = { GREEN, RED })
@org.jetbrains.annotations.NotNull
public final java.lang.String getY()
@org.jetbrains.annotations.NotNull
public final java.lang.String getZ()
@test.ZAnno(clazz = java.lang.String.class, classes = { java.lang.String.class, long.class, test.Main.class })
public final void setZ(java.lang.String p)
@org.jetbrains.annotations.NotNull
public final java.lang.String getZz()
public void <init>()
}
@@ -0,0 +1,11 @@
// EnumClass
enum class EnumClass {
RED, GREEN, BLUE;
fun someFun() {
System.out.println("Hello, world!")
}
fun stringRepresentation() = this.toString()
}
@@ -0,0 +1,14 @@
public enum EnumClass {
public static final EnumClass RED
public static final EnumClass GREEN
public static final EnumClass BLUE
public final void someFun()
@org.jetbrains.annotations.NotNull
public final java.lang.String stringRepresentation()
protected void <init>()
}
@@ -0,0 +1,7 @@
// Anno
@Repeatable
@Deprecated
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.EXPRESSION)
annotation class Anno
@@ -0,0 +1,9 @@
@kotlin.annotation.Repeatable
@kotlin.Deprecated
@kotlin.annotation.Retention(value = RUNTIME)
@kotlin.annotation.Target(allowedTargets = { CLASS, CONSTRUCTOR, EXPRESSION })
@java.lang.annotation.Retention(value = RUNTIME)
@java.lang.annotation.Target(value = { TYPE, CONSTRUCTOR })
public abstract @interface Anno {
}
@@ -0,0 +1,30 @@
// MyClass
class MyClass {
companion object {
val CONST = 2
}
fun myClassFun() {}
class NestedClass {
companion object A {
val CONSTA = 3
}
fun nestedClassFun() {}
class NestedNestedClass {
fun nestedNestedClassFun() {}
}
}
inner class InnerClass {
fun innerClassFun() {}
}
interface InnerInterface {
fun innerInterfaceFun()
fun innerInterfaceFunWithImpl() = 5
}
}
@@ -0,0 +1,53 @@
public final class MyClass {
private static final int CONST
public static final MyClass.Companion Companion
public final void myClassFun()
public void <init>()
public static final class Companion {
public final int getCONST()
private void <init>()
}
public static final class NestedClass {
private static final int CONSTA
public static final MyClass.NestedClass.A A
public final void nestedClassFun()
public void <init>()
public static final class A {
public final int getCONSTA()
private void <init>()
}
public static final class NestedNestedClass {
public final void nestedNestedClassFun()
public void <init>()
}
}
public final class InnerClass {
public final void innerClassFun()
public void <init>()
}
public static abstract interface InnerInterface {
public abstract void innerInterfaceFun()
public abstract int innerInterfaceFunWithImpl()
public static final class DefaultImpls {
public static int innerInterfaceFunWithImpl(MyClass.InnerInterface $this)
}
}
}
@@ -0,0 +1,8 @@
// MyClass
@Repeatable
annotation class Anno(val name: String)
@Anno("Mary")
@Anno("Tom")
class MyClass
@@ -0,0 +1,5 @@
@Anno(name = "Mary")
@Anno(name = "Tom")
public final class MyClass {
public void <init>()
}
@@ -0,0 +1,10 @@
// test.Simple
package test
abstract class Simple(private val prop: String) {
protected val anotherProp: Int = 5
abstract fun strFun(val x: Long): String
fun voidFun() {}
}
@@ -0,0 +1,14 @@
public abstract class Simple {
private final int anotherProp
private final java.lang.String prop
protected final int getAnotherProp()
@org.jetbrains.annotations.NotNull
public abstract java.lang.String strFun(long x)
public final void voidFun()
public void <init>(java.lang.String prop)
}
@@ -0,0 +1 @@
class Test
@@ -0,0 +1,3 @@
class Test
annotation class Anno
@@ -0,0 +1,11 @@
@Name("Mary")
@Age(18)
class Mary
@Name("Kate")
@Age(22)
class Kate
annotation class Name(val name: String)
annotation class Age(val age: Int)
@@ -0,0 +1,10 @@
annotation class Anno(val name: String)
@Anno("MyClassAnno")
class MyClass {
@Anno("myFuncAnno")
fun myFunc(): String = "Mary"
@field:Anno("myFieldAnno")
val myField: String = "Tom"
}
@@ -0,0 +1,4 @@
@Anno
class MyClass
annotation class Anno
@@ -0,0 +1,5 @@
@Anno2
class MyClass
annotation class Anno
annotation class Anno2