Analysis API: add KtType.isDenotable()
This commit is contained in:
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
fun test() {
|
||||
class A
|
||||
@Denotable("A") A()
|
||||
@Denotable("kotlin.collections.List<A>") listOf(A())
|
||||
@Nondenotable("<no name provided>") object {}
|
||||
@Nondenotable("kotlin.collections.List<<no name provided>>") listOf(object {})
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun test() {
|
||||
class A
|
||||
@Denotable("A") A()
|
||||
@Denotable("kotlin.collections.List<A>") listOf(A())
|
||||
@Nondenotable("<anonymous>") object {}
|
||||
@Nondenotable("kotlin.collections.List<<anonymous>>") listOf(object {})
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
interface A
|
||||
fun test(a: A) {
|
||||
@Denotable("kotlin.Int") 1
|
||||
@Denotable("kotlin.String") ""
|
||||
Denotable("A") a
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
fun test(a: Any?) {
|
||||
if (a is String) {
|
||||
(@Denotable("kotlin.String") a).length
|
||||
if (a is Int) {
|
||||
(@Denotable("kotlin.Int") a).inc()
|
||||
}
|
||||
if (a is String) {
|
||||
(@Denotable("kotlin.String") a).length
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
(@Denotable("kotlin.Any") a).hashCode()
|
||||
}
|
||||
if (a == null) {
|
||||
(@Denotable("kotlin.Any?") a).isNothing()
|
||||
}
|
||||
if (a is String || a is Int) {
|
||||
(@Denotable("kotlin.Any?") a).length
|
||||
(@Denotable("kotlin.Any?") a).inc()
|
||||
}
|
||||
@Nondenotable("(kotlin.Comparable<*> & java.io.Serializable)") if (true) {
|
||||
""
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
fun Nothing?.isNothing() {}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
fun test(a: Any?) {
|
||||
if (a is String) {
|
||||
(@Denotable("kotlin.String") a).length
|
||||
if (a is Int) {
|
||||
(@Nondenotable("(kotlin.String&kotlin.Int)") a).inc()
|
||||
}
|
||||
if (a is String) {
|
||||
(@Denotable("kotlin.String") a).length
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
(@Denotable("kotlin.Any") a).hashCode()
|
||||
}
|
||||
if (a == null) {
|
||||
(@Denotable("kotlin.Nothing?") a).isNothing()
|
||||
}
|
||||
if (a is String || a is Int) {
|
||||
(@Nondenotable("(kotlin.Comparable<(kotlin.String&kotlin.Int)>&java.io.Serializable)") a).length
|
||||
(@Nondenotable("(kotlin.Comparable<(kotlin.String&kotlin.Int)>&java.io.Serializable)") a).inc()
|
||||
}
|
||||
@Nondenotable("(kotlin.Comparable<*>&java.io.Serializable)") if (true) {
|
||||
""
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
fun Nothing?.isNothing() {}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
interface A
|
||||
|
||||
fun <T> test(t: T) {
|
||||
@Denotable("T") t
|
||||
if (t != null) {
|
||||
(@Nondenotable("T & Any") t).equals("")
|
||||
}
|
||||
val outs = take(getOutProjection())
|
||||
@Denotable("A") outs
|
||||
|
||||
val ins = take(getInProjection())
|
||||
@Denotable(kotlin.Any?) ins
|
||||
}
|
||||
|
||||
fun getOutProjection(): MutableList<out A> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun getInProjection(): MutableList<in A> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun <T> take(l: MutableList<T>): T {
|
||||
TODO()
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
interface A
|
||||
|
||||
fun <T> test(t: T) {
|
||||
@Denotable("T") t
|
||||
if (t != null) {
|
||||
(@Nondenotable("T!!") t).equals("")
|
||||
}
|
||||
val outs = take(getOutProjection())
|
||||
@Denotable("A") outs
|
||||
|
||||
val ins = take(getInProjection())
|
||||
@Denotable(kotlin.Any?) ins
|
||||
}
|
||||
|
||||
fun getOutProjection(): MutableList<out A> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun getInProjection(): MutableList<in A> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun <T> take(l: MutableList<T>): T {
|
||||
TODO()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Denotable(val type: String)
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Nondenotable(val type: String)
|
||||
|
||||
Reference in New Issue
Block a user