add ultra-light classes/members that work without backend in simple cases
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/** should load cls */
|
||||
annotation class Anno(val p: String = "", val x: Array<Anno> = arrayOf(Anno(p="a"), Anno(p="b")))
|
||||
|
||||
/** should load cls */
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
@Deprecated("This anno is deprecated, use === instead", ReplaceWith("this === other"))
|
||||
annotation class Fancy
|
||||
|
||||
/** should load cls */
|
||||
annotation class ReplaceWith(val expression: String)
|
||||
|
||||
/** should load cls */
|
||||
annotation class Deprecated(
|
||||
val message: String,
|
||||
val replaceWith: ReplaceWith = ReplaceWith(""))
|
||||
|
||||
/** should load cls */
|
||||
annotation class Ann(val arg1: KClass<*>, val arg2: KClass<out Any>)
|
||||
|
||||
|
||||
@Anno class F: Runnable {
|
||||
@Anno("f") fun f(@Anno p: String) {}
|
||||
@Anno("p") var prop = "x"
|
||||
}
|
||||
|
||||
|
||||
class Foo @Anno constructor(dependency: MyDependency) {
|
||||
var x: String? = null
|
||||
@Anno set
|
||||
|
||||
@Anno
|
||||
fun String.f4() {}
|
||||
}
|
||||
|
||||
@Ann(String::class, Int::class) class MyClass
|
||||
|
||||
class Example(@field:Ann val foo, // annotate Java field
|
||||
@get:Ann val bar, // annotate Java getter
|
||||
@param:Ann val quux) // annotate Java constructor parameter
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
package pkg
|
||||
|
||||
open class Open {
|
||||
private class Private: Open {}
|
||||
protected inner class Private2 {}
|
||||
internal class StaticInternal {}
|
||||
}
|
||||
internal class OuterInternal {}
|
||||
private class TopLevelPrivate {}
|
||||
|
||||
sealed class Season {
|
||||
class Nested: Season()
|
||||
}
|
||||
|
||||
sealed class SealedWithArgs(val a: Int)
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
class TestConstructor private constructor(p: Int = 1)
|
||||
class A(vararg a: Int, f: () -> Unit) {}
|
||||
|
||||
class B {
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
constructor()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/** should load cls */
|
||||
class Foo {
|
||||
suspend fun doSomething(foo: Foo): Bar {}
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
class Bar {
|
||||
fun <T> async(block: suspend () -> T)
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
interface Base {
|
||||
suspend fun foo()
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
class Derived: Base {
|
||||
override suspend fun foo() { ... }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/** should load cls */
|
||||
data class User(val name: String = "", val age: Int = 0)
|
||||
|
||||
/** should load cls */
|
||||
data class Person(val name: String) {
|
||||
var age: Int = 0
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
interface Base {
|
||||
fun printMessage()
|
||||
fun printMessageLine()
|
||||
}
|
||||
|
||||
class BaseImpl(val x: Int) : Base {
|
||||
override fun printMessage() { print(x) }
|
||||
override fun printMessageLine() { println(x) }
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
class Derived(b: Base) : Base by b {
|
||||
override fun printMessage() { print("abc") }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
import java.util.function.*
|
||||
|
||||
/** should load cls */
|
||||
enum class Direction {
|
||||
NORTH, SOUTH, WEST, EAST
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
enum class Color(val rgb: Int) {
|
||||
RED(0xFF0000),
|
||||
GREEN(0x00FF00),
|
||||
BLUE(0x0000FF)
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = TALKING
|
||||
},
|
||||
|
||||
TALKING {
|
||||
override fun signal() = WAITING
|
||||
};
|
||||
|
||||
abstract fun signal(): ProtocolState
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
enum class IntArithmetics : BinaryOperator<Int>, IntBinaryOperator {
|
||||
PLUS {
|
||||
override fun apply(t: Int, u: Int): Int = t + u
|
||||
},
|
||||
TIMES {
|
||||
override fun apply(t: Int, u: Int): Int = t * u
|
||||
};
|
||||
|
||||
override fun applyAsInt(t: Int, u: Int) = apply(t, u)
|
||||
}
|
||||
|
||||
class C {
|
||||
val enumConst: Direction? = Direction.EAST
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
abstract class C<T>(var constructorParam: List<CharSequence>) {
|
||||
fun foo<V, U : V>(p1: V, p2: C<V>, p4: Sequence<V>): T {}
|
||||
|
||||
inline fun <reified T : Enum<T>> printAllValues() {
|
||||
print(enumValues<T>().joinToString { it.name })
|
||||
}
|
||||
|
||||
val <Q : T> Q.w: Q get() = null!!
|
||||
|
||||
var sListProp: List<String>?
|
||||
var sSetProp: Set<String>?
|
||||
var sMutableSetProp: MutableSet<String>?
|
||||
var sHashSetProp: HashSet<String>?
|
||||
var csListProp: List<CharSequence>?
|
||||
|
||||
abstract fun listCS(l: List<CharSequence>): List<CharSequence>
|
||||
abstract fun listS(l: List<String>): List<String>
|
||||
abstract fun mutables(cin: MutableCollection<in Number>, sOut: MutableList<out C<*>>): MutableSet<CharSequence>
|
||||
abstract fun nested(l: List<List<CharSequence>>): Collection<Collection<CharSequence>>
|
||||
|
||||
fun <T : Any?> max(p0 : Collection<T>?): T? where T : Comparable<T>? {}
|
||||
|
||||
}
|
||||
|
||||
open class K<out T: K<T>> { }
|
||||
class Sub: K<K<*>>()
|
||||
@@ -0,0 +1,27 @@
|
||||
import java.util.*
|
||||
|
||||
/** should load cls */
|
||||
class MyList : List<String> {
|
||||
override operator fun get(index: Int): String {}
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
interface ASet<T> : MutableCollection<T> {}
|
||||
|
||||
/** should load cls */
|
||||
abstract class MySet<T> : ASet<T> {
|
||||
override fun remove(elem: String): Boolean {}
|
||||
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
abstract class SmartSet<T> private constructor() : AbstractSet<T>() {
|
||||
override fun iterator(): MutableIterator<T> = unresolved
|
||||
|
||||
override fun add(element: T): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun contains(element: T): Boolean = true
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import kotlin.jvm.JvmStatic as JS
|
||||
|
||||
/** should load cls */
|
||||
object O {
|
||||
@JS fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/** should load cls */
|
||||
class Prop {
|
||||
private val someProp = object { }
|
||||
}
|
||||
|
||||
|
||||
/** should load cls */
|
||||
class Fun {
|
||||
private fun someFun() = object { }
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
class Array {
|
||||
val a1 = arrayOf(
|
||||
object { val fy = "text"}
|
||||
)
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
private class C(val y: Int) {
|
||||
val initChild = { ->
|
||||
object {
|
||||
override fun toString(): String {
|
||||
return "child" + y
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Super {
|
||||
val a: Any?
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
class Sub {
|
||||
override val a = arrayOf(
|
||||
object { val fy = "text"}
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
interface Intf {
|
||||
fun v(): Int
|
||||
}
|
||||
interface IntfWithProp : Intf {
|
||||
val x: Int
|
||||
}
|
||||
abstract class Base(p: Int) {
|
||||
open protected fun v(): Int? { }
|
||||
fun nv() { }
|
||||
abstract fun abs(): Int
|
||||
|
||||
internal open val x: Int get() { }
|
||||
open var y = 1
|
||||
open protected var z = 1
|
||||
}
|
||||
class Derived(p: Int) : Base(p), IntfWithProp {
|
||||
override fun v() = unknown()
|
||||
override val x = 3
|
||||
override fun abs() = 0
|
||||
}
|
||||
abstract class AnotherDerived(override val x: Int, override val y: Int, override val z: Int) : Base(2) {
|
||||
final override fun v() { }
|
||||
abstract fun noReturn(s: String)
|
||||
abstract val abstractProp: Int
|
||||
}
|
||||
|
||||
private class Private {
|
||||
override val overridesNothing: Boolean
|
||||
get() = false
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/** should load cls */
|
||||
inline class UInt(private val value: Int) { }
|
||||
|
||||
/** should load cls */
|
||||
inline enum class Foo(val x: Int) {
|
||||
A(0), B(1);
|
||||
|
||||
fun example() { }
|
||||
}
|
||||
|
||||
/** should load cls */
|
||||
inline class InlinedDelegate<T>(var node: T) {
|
||||
operator fun setValue(thisRef: A, property: KProperty<*>, value: T) {
|
||||
if (node !== value) {
|
||||
thisRef.notify(node, value)
|
||||
}
|
||||
node = value
|
||||
}
|
||||
|
||||
operator fun getValue(thisRef: A, property: KProperty<*>): T {
|
||||
return node
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/** should load cls */
|
||||
class C {
|
||||
var rwProp: Int
|
||||
@JvmName("get_rwProp")
|
||||
get() = 0
|
||||
@JvmName("set_rwProp")
|
||||
set(v) {}
|
||||
|
||||
fun getRwProp(): Int = 123
|
||||
fun setRwProp(v: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/** should load cls */
|
||||
class C @JvmOverloads constructor(
|
||||
val type: String?,
|
||||
val p1: Boolean = false,
|
||||
val p2: String = type
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@JvmStatic fun foo() {}
|
||||
fun bar() {}
|
||||
@JvmStatic var x: String = ""
|
||||
|
||||
var I.c: String
|
||||
@JvmStatic get() = "OK"
|
||||
@JvmStatic set(t: String) {}
|
||||
|
||||
var c1: String
|
||||
get() = "OK"
|
||||
@JvmStatic set(t: String) {}
|
||||
}
|
||||
companion object Factory {}
|
||||
}
|
||||
|
||||
class C1 {
|
||||
private companion object {}
|
||||
}
|
||||
|
||||
interface I {
|
||||
companion object { }
|
||||
}
|
||||
|
||||
object Obj : java.lang.Runnable {
|
||||
@JvmStatic var x: String = ""
|
||||
override fun run() {}
|
||||
@JvmStatic fun zoo(): Int = 2
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Foo(a: Int, val b:Foo, var c:Boolean, private val d: List, protected val e: Long = 2) {
|
||||
val f1 = 2
|
||||
|
||||
val intConst: dynamic = 30
|
||||
val arrayConst: Any = byteArrayOf(1,2)
|
||||
|
||||
protected var f2 = 3
|
||||
|
||||
var name: String = "x"
|
||||
|
||||
val isEmpty get() = false
|
||||
var isEmptyMutable: Boolean?
|
||||
var islowercase: Boolean?
|
||||
var isEmptyInt: Int?
|
||||
var getInt: Int?
|
||||
private var noAccessors: String
|
||||
|
||||
internal var stringRepresentation: String
|
||||
get() = this.toString()
|
||||
set(value) {
|
||||
setDataFromString(value)
|
||||
}
|
||||
|
||||
const val SUBSYSTEM_DEPRECATED: String = "This subsystem is deprecated"
|
||||
|
||||
var counter = 0
|
||||
set(value) {
|
||||
if (value >= 0) field = value
|
||||
}
|
||||
var counter2 : Int?
|
||||
get() = field
|
||||
set(value) {
|
||||
if (value >= 0) field = value
|
||||
}
|
||||
|
||||
lateinit var subject: Unresolved
|
||||
internal lateinit var internalVarPrivateSet: String
|
||||
private set
|
||||
protected lateinit var protectedLateinitVar: String
|
||||
|
||||
var delegatedProp: String by Delegate()
|
||||
var delegatedProp2 by MyProperty()
|
||||
private var privateDelegated: Int by Delegate()
|
||||
var lazyProp: String by lazy { "abc" }
|
||||
|
||||
val Int.intProp: Int
|
||||
get() = 1
|
||||
|
||||
final internal var internalWithPrivateSet: Int = 1
|
||||
private set
|
||||
|
||||
protected var protectedWithPrivateSet: String = ""
|
||||
private set
|
||||
|
||||
private var privateVarWithPrivateSet = { 0 }()
|
||||
private set
|
||||
|
||||
private val privateValWithGet: String?
|
||||
get() = ""
|
||||
|
||||
private var privateVarWithGet: Object = Object()
|
||||
get
|
||||
|
||||
val sum: (Int)->Int = { x: Int -> sum(x - 1) + x }
|
||||
|
||||
companion object {
|
||||
public val prop3: Int = { 12 }()
|
||||
get() {
|
||||
return field
|
||||
}
|
||||
public var prop7 : Int = { 20 }()
|
||||
set(i: Int) {
|
||||
field++
|
||||
}
|
||||
private const val contextBean = Context.BEAN
|
||||
|
||||
val f1 = 4
|
||||
}
|
||||
}
|
||||
|
||||
class MyProperty<T> {
|
||||
operator fun getValue(t: T, p: KProperty<*>): Int = 42
|
||||
operator fun setValue(t: T, p: KProperty<*>, i: Int) {}
|
||||
}
|
||||
|
||||
class Modifiers {
|
||||
@delegate:Transient
|
||||
val plainField: Int = 1
|
||||
|
||||
@delegate:Transient
|
||||
val lazy by lazy { 1 }
|
||||
}
|
||||
|
||||
interface A {
|
||||
public var int1: Int
|
||||
private set
|
||||
protected get
|
||||
public var int2: Int
|
||||
public get
|
||||
internal set
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
open fun bar(a: Int, b:Any, c:Foo): Unit {}
|
||||
internal fun bar2(a: Sequence, b: Unresolved) {}
|
||||
private fun bar3(x: Foo.Inner, vararg y: Inner) = "str"
|
||||
fun bar4() = 42
|
||||
|
||||
public fun nullableVararg(vararg o: Any?): Unit
|
||||
|
||||
operator fun plus(increment: Int): Foo {}
|
||||
fun String.onString(a: (Int) -> Any?): Foo {}
|
||||
|
||||
class Inner {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class MyException : Exception
|
||||
class C @Throws(Exception::class) constructor(a: Int = 1) {
|
||||
@Throws(java.io.IOException::class, MyException::class)
|
||||
fun readFile(name: String): String {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
typealias JO = JvmOverloads
|
||||
|
||||
/** should load cls */
|
||||
object O {
|
||||
@JO fun foo(a: Int = 1, b: String = "") {}
|
||||
}
|
||||
Reference in New Issue
Block a user