Uast: include parameters of reified methods to uast tree (KT-37613)

This commit is contained in:
Nicolay Mitropolsky
2020-03-21 20:18:13 +03:00
parent 4234fa79c0
commit f1d5570ca1
15 changed files with 402 additions and 128 deletions
+7
View File
@@ -0,0 +1,7 @@
inline fun <reified T> functionWithLambda(t: T, process: (T) -> Int): Int = process(t)
inline fun <reified T> functionWithVararg(i: Int?, vararg t: T): T = t[0]
inline fun <reified T> functionWithParamAnnotation(@Suppress("s") t: T): T = t
inline fun <reified T> functionUnresolved(@Suppress("s") t: Unresolved<T>): T = t
+43
View File
@@ -0,0 +1,43 @@
UFile (package = )
UClass (name = ReifiedParametersKt)
UMethod (name = functionWithLambda)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = process)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (process))
USimpleNameReferenceExpression (identifier = invoke, resolvesTo = null)
USimpleNameReferenceExpression (identifier = t)
UMethod (name = functionWithVararg)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UBlockExpression
UReturnExpression
UArrayAccessExpression
USimpleNameReferenceExpression (identifier = t)
ULiteralExpression (value = 0)
UMethod (name = functionWithParamAnnotation)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UAnnotation (fqName = kotlin.Suppress)
UNamedExpression (name = names)
UPolyadicExpression (operator = +)
ULiteralExpression (value = "s")
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = functionUnresolved)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UAnnotation (fqName = kotlin.Suppress)
UNamedExpression (name = names)
UPolyadicExpression (operator = +)
ULiteralExpression (value = "s")
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
@@ -0,0 +1,14 @@
public final class ReifiedParametersKt {
fun functionWithLambda(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull process: kotlin.jvm.functions.Function1<? super T,? extends java.lang.Integer>) : int {
return invoke(t)
}
fun functionWithVararg(@org.jetbrains.annotations.Nullable i: int, @org.jetbrains.annotations.Nullable t: T) : T {
return t[0]
}
fun functionWithParamAnnotation(@org.jetbrains.annotations.Nullable @kotlin.Suppress(names = "s") t: T) : T {
return t
}
fun functionUnresolved(@org.jetbrains.annotations.NotNull @kotlin.Suppress(names = "s") t: <ErrorType>) : T {
return t
}
}
+11 -11
View File
@@ -1,11 +1,11 @@
inline fun <T> function1(t: T) {}
inline fun <T> function2(t: T): T = t
inline fun <reified T> function3(t: T) {}
inline fun <reified T> function4(t: T): T = t
inline fun <reified T> function5(t: T): Int = 42
inline fun <reified T : Activity> T.function6(t: T): T = t
inline fun <reified T> function7(t: T): T = t
private inline fun <reified T> function8(t: T): T = t
internal inline fun <reified T> function9(t: T): T = t
public inline fun <reified T> function10(t: T): T = t
inline fun <reified T> T.function11(t: T): T = t
inline fun <T> function1(t: T, i: Int, s: String) {}
inline fun <T> function2(t: T, i: Int, s: String): T = t
inline fun <reified T> function3(t: T, i: Int, s: String) {}
inline fun <reified T> function4(t: T, i: Int, s: String): T = t
inline fun <reified T> function5(t: T, i: Int, s: String): Int = 42
inline fun <reified T : Activity> T.function6(t: T, i: Int, s: String): T = t
inline fun <reified T> function7(t: T, i: Int, s: String): T = t
private inline fun <reified T> function8(t: T, i: Int, s: String): T = t
internal inline fun <reified T> function9(t: T, i: Int, s: String): T = t
public inline fun <reified T> function10(t: T, i: Int, s: String): T = t
inline fun <reified T> T.function11(t: T, i: Int, s: String): T = t
+104
View File
@@ -0,0 +1,104 @@
UFile (package = )
UClass (name = ReifiedReturnTypeKt)
UMethod (name = function1)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UMethod (name = function2)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function3)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UMethod (name = function4)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function5)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
ULiteralExpression (value = 42)
UMethod (name = function6)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UParameter (name = s)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function7)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function8)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function9)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function10)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UParameter (name = s)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
UMethod (name = function11)
UParameter (name = t)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UParameter (name = i)
UParameter (name = s)
UBlockExpression
UReturnExpression
USimpleNameReferenceExpression (identifier = t)
@@ -0,0 +1,33 @@
public final class ReifiedReturnTypeKt {
public static final fun function1(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : void {
}
public static final fun function2(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function3(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : void {
}
fun function4(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function5(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : int {
return 42
}
fun function6(@org.jetbrains.annotations.Nullable t: T, i: int, s: java.lang.String) : T {
return t
}
fun function7(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function8(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function9(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function10(@org.jetbrains.annotations.Nullable t: T, @org.jetbrains.annotations.NotNull i: int, @org.jetbrains.annotations.NotNull s: java.lang.String) : T {
return t
}
fun function11(@org.jetbrains.annotations.Nullable t: T, i: int, s: java.lang.String) : T {
return t
}
}