Extract type access expression for function return types

This commit is contained in:
Tamas Vajk
2022-04-14 14:01:46 +02:00
committed by Ian Lynagh
parent dcac285a99
commit f557719fe5
2 changed files with 16 additions and 1 deletions

View File

@@ -676,6 +676,8 @@ open class KotlinFileExtractor(
val substReturnType = typeSubstitution?.let { it(f.returnType, TypeContext.RETURN, pluginContext) } ?: f.returnType
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
if (f.symbol is IrConstructorSymbol) {
val unitType = useType(pluginContext.irBuiltIns.unitType, TypeContext.RETURN)
val shortName = when {
@@ -692,9 +694,12 @@ open class KotlinFileExtractor(
val methodId = id.cast<DbMethod>()
tw.writeMethods(methodId, shortName, "$shortName$paramsSignature", returnType.javaResult.id, parentId, sourceDeclaration.cast<DbMethod>())
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
if (!isExternalDeclaration(f)) {
extractTypeAccessRecursive(f.returnType, locId, id, -1)
}
}
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
tw.writeHasLocation(id, locId)
val body = f.body
if (body != null && extractBody) {

View File

@@ -9,6 +9,7 @@ A.kt:
# 3| 0: [SuperConstructorInvocationStmt] super(...)
# 3| 1: [BlockStmt] { ... }
# 4| 2: [Method] fn
# 4| 3: [TypeAccess] Unit
# 4| 5: [BlockStmt] { ... }
# 5| 0: [LocalVariableDeclStmt] var ...;
# 5| 1: [LocalVariableDeclExpr] a
@@ -28,6 +29,7 @@ A.kt:
# 10| -1: [TypeAccess] ConsoleKt
# 10| 0: [StringLiteral]
# 13| 6: [Method] getProp
# 13| 3: [TypeAccess] int
# 13| 5: [BlockStmt] { ... }
# 13| 0: [ReturnStmt] return ...
# 13| 0: [VarAccess] this.prop
@@ -39,14 +41,19 @@ A.kt:
# 13| 0: [TypeAccess] A
# 13| 0: [IntegerLiteral] 1
# 15| 8: [Method] fn
# 15| 3: [TypeAccess] Unit
# 15| 5: [BlockStmt] { ... }
# 16| 9: [Method] fn
# 16| 3: [TypeAccess] C<C<Integer>>
# 16| 0: [TypeAccess] C<Integer>
# 16| 0: [TypeAccess] Integer
#-----| 4: (Parameters)
# 16| 0: [Parameter] i
# 16| 5: [BlockStmt] { ... }
# 16| 0: [ReturnStmt] return ...
# 16| 0: [VarAccess] i
# 17| 10: [Method] fn
# 17| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 17| 0: [Parameter] i
# 17| 5: [BlockStmt] { ... }
@@ -62,7 +69,10 @@ A.kt:
# 20| 0: [IntegerLiteral] 5
# 23| 11: [Class] Enu
# 0| 1: [Method] values
# 0| 3: [TypeAccess] Enu[]
# 0| 0: [TypeAccess] Enu
# 0| 1: [Method] valueOf
# 0| 3: [TypeAccess] Enu
#-----| 4: (Parameters)
# 0| 0: [Parameter] value
# 23| 3: [Constructor] Enu