Move kotlin annotations to negative child index

This commit is contained in:
Tamas Vajk
2022-04-13 11:48:46 +02:00
committed by Chris Smowton
parent 96a407c9c5
commit fed770fcd1
5 changed files with 14 additions and 44 deletions

View File

@@ -460,7 +460,7 @@ open class KotlinFileExtractor(
private fun extractAnnotations(c: IrAnnotationContainer, parent: Label<out DbExprparent>) {
for ((idx, constructorCall: IrConstructorCall) in c.annotations.withIndex()) {
extractAnnotation(constructorCall, parent, idx)
extractAnnotation(constructorCall, parent, -1 - idx)
}
}
@@ -471,7 +471,7 @@ open class KotlinFileExtractor(
): Label<out DbExpr> {
val t = useType(constructorCall.type)
val id = tw.getLabelFor<DbDeclannotation>("@\"annotation;{$parent};{${t.javaResult.id}}\"")
val id = tw.getLabelFor<DbDeclannotation>("@\"annotation_kotlin;{$parent};{${t.javaResult.id}}\"")
tw.writeExprs_declannotation(id, t.javaResult.id, parent, idx)
tw.writeExprsKotlinType(id, t.kotlinResult.id)

View File

@@ -1,2 +0,0 @@
| def.kt:5:1:21:60 | Annot0k | Interface | 0 | duplicate | 0, 1, 2, 3 |
| def.kt:23:1:23:8 | Annot0k | Annotation | 0 | duplicate | 0 |

View File

@@ -1,36 +0,0 @@
[INVALID_KEY_SET] predicate exprs(@expr id, int kind, @type typeid, @exprparent parent, int idx): The key set {parent, idx} does not functionally determine all fields.
Here is a pair of tuples that agree on the key set but differ at index 0:
Tuple 1 in row 10: (103,66,102,88,0)
Tuple 2 in row 116: (521,66,520,88,0)
Relevant element: Tuple 1: id=103
Full ID for 103: @"annotation;(88);(102)". The ID may expand to @"annotation;{@"class;Annot0k"};{@"class;kotlin.annotation.Target"}"
Relevant element: Tuple 2: id=521
Full ID for 521: @"annotation;(88);(520)". The ID may expand to @"annotation;{@"class;Annot0k"};{@"class;java.lang.annotation.Retention"}"
Relevant element: Tuple 1: typeid=102
Full ID for 102: @"class;kotlin.annotation.Target"
Relevant element: Tuple 2: typeid=520
Full ID for 520: @"class;java.lang.annotation.Retention"
Relevant element: parent=88
Full ID for 88: @"class;Annot0k"
[INVALID_KEY_SET] predicate exprs(@expr id, int kind, @type typeid, @exprparent parent, int idx): The key set {parent, idx} does not functionally determine all fields.
Here is a pair of tuples that agree on the key set but differ at index 0:
Tuple 1 in row 28: (172,17,17,170,0)
Tuple 2 in row 130: (558,17,17,170,0)
Relevant element: Tuple 2: id=558
Full ID for 558: @"annotationExpr;(170);0". The ID may expand to @"annotationExpr;{@"annotation;{@"class;Annot1k"};{@"class;Annot0k"}"};0"
Relevant element: typeid=17
Full ID for 17: @"type;int"
Relevant element: Tuple 1: parent=170
Full ID for 170: @"annotation;(151);(88)". The ID may expand to @"annotation;{@"class;Annot1k"};{@"class;Annot0k"}"
Relevant element: Tuple 2: parent=170
Full ID for 170: @"annotation;(151);(88)". The ID may expand to @"annotation;{@"class;Annot1k"};{@"class;Annot0k"}"
[INVALID_KEY] predicate exprs(@expr id, int kind, @type typeid, @exprparent parent, int idx): The key set {id} does not functionally determine all fields.
Here is a pair of tuples that agree on the key set but differ at index 4:
Tuple 1 in row 10: (103,66,102,88,0)
Tuple 2 in row 11: (103,66,102,88,3)
Relevant element: id=103
Full ID for 103: @"annotation;(88);(102)". The ID may expand to @"annotation;{@"class;Annot0k"};{@"class;kotlin.annotation.Target"}"
Relevant element: typeid=102
Full ID for 102: @"class;kotlin.annotation.Target"
Relevant element: parent=88
Full ID for 88: @"class;Annot0k"

View File

@@ -63,6 +63,7 @@ def.kt:
# 21| [Method] a
#-----| 1 -> (Annotations)
#-----| 3 -> [Annotation] JvmName
# 21| [Annotation] JvmName
#-----| 1 -> [StringLiteral] a
@@ -189,6 +190,7 @@ def.kt:
# 42| [Constructor] Z
#-----| 1 -> (Annotations)
#-----| 3 -> [Annotation] Annot0k
#-----| 5 -> [BlockStmt] { ... }
# 41| [BlockStmt] { ... }
@@ -251,11 +253,12 @@ def.kt:
# 46| [Method] fn
#-----| 1 -> (Annotations)
#-----| 2 -> (Generic Parameters)
#-----| 3 -> [Annotation] Annot0k
#-----| 4 -> (Parameters)
#-----| 5 -> [BlockStmt] { ... }
# 46| [TypeVariable] T
#-----| 0 -> [Annotation] Annot0k
#-----| -1 -> [Annotation] Annot0k
# 46| [Annotation] Annot0k
#-----| 1 -> [IntegerLiteral] 0
@@ -264,6 +267,7 @@ def.kt:
# 46| [Parameter] a
#-----| -1 -> (Annotations)
#-----| 0 -> [Annotation] Annot0k
# 46| [Annotation] Annot0k
#-----| 1 -> [IntegerLiteral] 0
@@ -303,6 +307,7 @@ def.kt:
# 57| [Method] getP
#-----| 1 -> (Annotations)
#-----| 3 -> [Annotation] Annot0k
#-----| 5 -> [BlockStmt] { ... }
# 57| [BlockStmt] { ... }
@@ -320,6 +325,7 @@ def.kt:
# 57| [Method] setP
#-----| 1 -> (Annotations)
#-----| 3 -> [Annotation] Annot0k
#-----| 4 -> (Parameters)
#-----| 5 -> [BlockStmt] { ... }
@@ -362,6 +368,7 @@ def.kt:
# 59| [Parameter] <this>
#-----| -1 -> (Annotations)
#-----| 0 -> [Annotation] Annot0k
# 59| [Annotation] Annot0k
#-----| 1 -> [IntegerLiteral] 0
@@ -520,13 +527,13 @@ use.java:
#-----| 0 -> [TypeAccess] Annot0k
#-----| (Annotations)
#-----| 4 -> [Annotation] Target
#-----| 5 -> [Annotation] Target
#-----| (Annotations)
#-----| 1 -> [Annotation] JvmName
#-----| 2 -> [Annotation] JvmName
#-----| (Annotations)
#-----| 3 -> [Annotation] Annot0k
#-----| 4 -> [Annotation] Annot0k
#-----| (Annotations)
#-----| 1 -> [Annotation] Annot0k

View File

@@ -14,6 +14,7 @@ annotationDeclarations
| def.kt:23:1:31:1 | Annot1k | def.kt:29:5:29:32 | e |
| def.kt:23:1:31:1 | Annot1k | def.kt:30:5:30:31 | f |
annotations
| annotation_classes.testproj/test.class.files/Annot1k.class:0:0:0:0 | Annot0k | def.kt:23:1:31:1 | Annot1k | def.kt:5:1:21:60 | Annot0k |
| def.kt:0:0:0:0 | Annot0k | def.kt:39:1:39:40 | Annot1k | def.kt:5:1:21:60 | Annot0k |
| def.kt:23:1:23:8 | Annot0k | def.kt:23:1:31:1 | Annot1k | def.kt:5:1:21:60 | Annot0k |
| def.kt:38:1:38:17 | Annot0k | def.kt:38:1:43:1 | Z | def.kt:5:1:21:60 | Annot0k |