Uast: don't throw exception if can't get a receiver parameter for annotation (KT-40494)

This commit is contained in:
Nicolay Mitropolsky
2020-07-22 19:26:54 +03:00
parent 7872b21914
commit f7031e65ba
6 changed files with 55 additions and 4 deletions
+5 -2
View File
@@ -1,3 +1,6 @@
annotation class MyReceiverAnnotation
annotation class MyReceiverAnnotation(val name: String = "")
fun @receiver:MyReceiverAnnotation String.foo() = this.length
fun @receiver:MyReceiverAnnotation String.foo() = this.length
val @receiver:MyReceiverAnnotation("RegExp") String.rx : Regex
get() { return toRegex() }
+22
View File
@@ -0,0 +1,22 @@
UFile (package = )
UClass (name = ReceiverFunKt)
UMethod (name = foo)
UParameter (name = $this$foo)
UAnnotation (fqName = MyReceiverAnnotation)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
UQualifiedReferenceExpression
UThisExpression (label = null)
USimpleNameReferenceExpression (identifier = length)
UMethod (name = getRx)
UParameter (name = $this$getRx)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (toRegex))
USimpleNameReferenceExpression (identifier = toRegex, resolvesTo = null)
UClass (name = MyReceiverAnnotation)
UAnnotationMethod (name = name)
ULiteralExpression (value = "")
+10
View File
@@ -9,4 +9,14 @@ UFile (package = )
UQualifiedReferenceExpression
UThisExpression (label = null)
USimpleNameReferenceExpression (identifier = length)
UMethod (name = getRx)
UParameter (name = $this$rx)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (toRegex))
USimpleNameReferenceExpression (identifier = toRegex, resolvesTo = null)
UClass (name = MyReceiverAnnotation)
UAnnotationMethod (name = name)
ULiteralExpression (value = "")
+12
View File
@@ -0,0 +1,12 @@
public final class ReceiverFunKt {
public static final fun foo(@MyReceiverAnnotation @org.jetbrains.annotations.NotNull $this$foo: java.lang.String) : int {
return this.length
}
public static final fun getRx(@org.jetbrains.annotations.NotNull $this$getRx: java.lang.String) : kotlin.text.Regex {
return toRegex()
}
}
public abstract annotation MyReceiverAnnotation {
public abstract fun name() : java.lang.String = UastEmptyExpression
}
+4
View File
@@ -2,7 +2,11 @@ public final class ReceiverFunKt {
public static final fun foo(@MyReceiverAnnotation @org.jetbrains.annotations.NotNull $this$foo: java.lang.String) : int {
return this.length
}
public static final fun getRx(@org.jetbrains.annotations.NotNull $this$rx: java.lang.String) : kotlin.text.Regex {
return toRegex()
}
}
public abstract annotation MyReceiverAnnotation {
public abstract fun name() : java.lang.String = UastEmptyExpression
}