Uast: parsing primary constructors superCalls (KT-21409)

This commit is contained in:
Nicolay Mitropolsky
2017-11-24 13:02:01 +03:00
committed by xiexed
parent a39f2f8271
commit 3bfa5c4706
8 changed files with 149 additions and 13 deletions
+25
View File
@@ -0,0 +1,25 @@
open class A(val str: String) {
constructor(i: Int) : this(i.toString())
open fun foo(a: Long) {}
}
class B(param: String) : A(param)
class C : A {
constructor(p: String) : super(p)
constructor(i: Int) : super(i)
override fun foo(a: Long) {
super.foo(a)
}
}
object O : A("text")
val anon = object : A("textForAnon") {
fun bar() {}
}
+60
View File
@@ -0,0 +1,60 @@
UFile (package = )
UClass (name = SuperCallsKt)
UField (name = anon)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UObjectLiteralExpression
ULiteralExpression (value = "textForAnon")
UClass (name = null)
UAnnotationMethod (name = bar)
UBlockExpression
UAnnotationMethod (name = SuperCallsKt$anon$1)
UAnnotationMethod (name = getAnon)
UClass (name = A)
UField (name = str)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UAnnotationMethod (name = foo)
UParameter (name = a)
UAnnotation (fqName = null)
UBlockExpression
UAnnotationMethod (name = getStr)
UAnnotationMethod (name = A)
UParameter (name = str)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UAnnotationMethod (name = A)
UParameter (name = i)
UAnnotation (fqName = null)
UClass (name = B)
UAnnotationMethod (name = B)
UParameter (name = param)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
UIdentifier (Identifier (A))
USimpleNameReferenceExpression (identifier = <init>)
USimpleNameReferenceExpression (identifier = param)
UClass (name = C)
UAnnotationMethod (name = foo)
UParameter (name = a)
UAnnotation (fqName = null)
UBlockExpression
UQualifiedReferenceExpression
USuperExpression (label = null)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (foo))
USimpleNameReferenceExpression (identifier = foo)
USimpleNameReferenceExpression (identifier = a)
UAnnotationMethod (name = C)
UParameter (name = p)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UAnnotationMethod (name = C)
UParameter (name = i)
UAnnotation (fqName = null)
UClass (name = O)
UField (name = INSTANCE)
UAnnotation (fqName = null)
UAnnotationMethod (name = O)
UBlockExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
UIdentifier (Identifier (A))
USimpleNameReferenceExpression (identifier = <init>)
ULiteralExpression (value = "text")
+36
View File
@@ -0,0 +1,36 @@
public final class SuperCallsKt {
private static final var anon: A = anonymous object : A ("textForAnon"){
fun bar(){}
}
public static final fun getAnon() : A = UastEmptyExpression
}
public class A {
private final var str: java.lang.String
public fun foo(a: long) : void {
}
public final fun getStr() : java.lang.String = UastEmptyExpression
public fun A(str: java.lang.String) = UastEmptyExpression
public fun A(i: int) = UastEmptyExpression
}
public final class B : A {
public fun B(param: java.lang.String) {
<init>(param)
}
}
public final class C : A {
public fun foo(a: long) : void {
super.foo(a)
}
public fun C(p: java.lang.String) = UastEmptyExpression
public fun C(i: int) = UastEmptyExpression
}
public final class O : A {
public static final var INSTANCE: O
private fun O() {
<init>("text")
}
}