Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f557719

Browse files
tamasvajkigfoo
authored andcommitted
Extract type access expression for function return types
1 parent dcac285 commit f557719

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ open class KotlinFileExtractor(
676676

677677
val substReturnType = typeSubstitution?.let { it(f.returnType, TypeContext.RETURN, pluginContext) } ?: f.returnType
678678

679+
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
680+
679681
if (f.symbol is IrConstructorSymbol) {
680682
val unitType = useType(pluginContext.irBuiltIns.unitType, TypeContext.RETURN)
681683
val shortName = when {
@@ -692,9 +694,12 @@ open class KotlinFileExtractor(
692694
val methodId = id.cast<DbMethod>()
693695
tw.writeMethods(methodId, shortName, "$shortName$paramsSignature", returnType.javaResult.id, parentId, sourceDeclaration.cast<DbMethod>())
694696
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
697+
698+
if (!isExternalDeclaration(f)) {
699+
extractTypeAccessRecursive(f.returnType, locId, id, -1)
700+
}
695701
}
696702

697-
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
698703
tw.writeHasLocation(id, locId)
699704
val body = f.body
700705
if (body != null && extractBody) {

java/ql/test/kotlin/library-tests/exprs_typeaccess/PrintAst.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A.kt:
99
# 3| 0: [SuperConstructorInvocationStmt] super(...)
1010
# 3| 1: [BlockStmt] { ... }
1111
# 4| 2: [Method] fn
12+
# 4| 3: [TypeAccess] Unit
1213
# 4| 5: [BlockStmt] { ... }
1314
# 5| 0: [LocalVariableDeclStmt] var ...;
1415
# 5| 1: [LocalVariableDeclExpr] a
@@ -28,6 +29,7 @@ A.kt:
2829
# 10| -1: [TypeAccess] ConsoleKt
2930
# 10| 0: [StringLiteral]
3031
# 13| 6: [Method] getProp
32+
# 13| 3: [TypeAccess] int
3133
# 13| 5: [BlockStmt] { ... }
3234
# 13| 0: [ReturnStmt] return ...
3335
# 13| 0: [VarAccess] this.prop
@@ -39,14 +41,19 @@ A.kt:
3941
# 13| 0: [TypeAccess] A
4042
# 13| 0: [IntegerLiteral] 1
4143
# 15| 8: [Method] fn
44+
# 15| 3: [TypeAccess] Unit
4245
# 15| 5: [BlockStmt] { ... }
4346
# 16| 9: [Method] fn
47+
# 16| 3: [TypeAccess] C<C<Integer>>
48+
# 16| 0: [TypeAccess] C<Integer>
49+
# 16| 0: [TypeAccess] Integer
4450
#-----| 4: (Parameters)
4551
# 16| 0: [Parameter] i
4652
# 16| 5: [BlockStmt] { ... }
4753
# 16| 0: [ReturnStmt] return ...
4854
# 16| 0: [VarAccess] i
4955
# 17| 10: [Method] fn
56+
# 17| 3: [TypeAccess] int
5057
#-----| 4: (Parameters)
5158
# 17| 0: [Parameter] i
5259
# 17| 5: [BlockStmt] { ... }
@@ -62,7 +69,10 @@ A.kt:
6269
# 20| 0: [IntegerLiteral] 5
6370
# 23| 11: [Class] Enu
6471
# 0| 1: [Method] values
72+
# 0| 3: [TypeAccess] Enu[]
73+
# 0| 0: [TypeAccess] Enu
6574
# 0| 1: [Method] valueOf
75+
# 0| 3: [TypeAccess] Enu
6676
#-----| 4: (Parameters)
6777
# 0| 0: [Parameter] value
6878
# 23| 3: [Constructor] Enu

0 commit comments

Comments
 (0)