@@ -2614,7 +2614,12 @@ open class KotlinFileExtractor(
26142614 val callId = tw.getFreshIdLabel<DbNewexpr >()
26152615 tw.writeExprs_newexpr(callId, callType.javaResult.id, retId, 0 )
26162616 tw.writeExprsKotlinType(callId, callType.kotlinResult.id)
2617- extractTypeAccessRecursive(expressionTypeArgs.first(), locId, callId, - 3 , labels.methodId, retId)
2617+
2618+ val typeAccessId = extractTypeAccess(callType, locId, callId, - 3 , labels.methodId, retId)
2619+ if (returnType is IrSimpleType ) {
2620+ // Only extract type arguments relating to the constructed type, not the constructor itself:
2621+ extractTypeArguments(returnType.arguments.take(target.owner.parentAsClass.typeParameters.size).filterIsInstance<IrType >(), locId, typeAccessId, labels.methodId, retId)
2622+ }
26182623 callId
26192624 } else {
26202625 var callId = tw.getFreshIdLabel<DbMethodaccess >()
@@ -2949,7 +2954,23 @@ open class KotlinFileExtractor(
29492954 tw.writeStatementEnclosingExpr(idMemberRef, exprParent.enclosingStmt)
29502955 tw.writeCallableBinding(idMemberRef, ids.constructor )
29512956
2952- extractTypeAccessRecursive(fnInterfaceType, locId, idMemberRef, - 3 , callable, exprParent.enclosingStmt)
2957+ var typeAccessArguments = if (isBigArity) listOf (parameterTypes.last()) else parameterTypes
2958+ if (target is IrConstructorSymbol ) {
2959+ val returnType = typeAccessArguments.last()
2960+
2961+ val typeAccessId = extractTypeAccess(useType(fnInterfaceType, TypeContext .OTHER ), locId, idMemberRef, - 3 , callable, exprParent.enclosingStmt)
2962+ typeAccessArguments.dropLast(1 ).forEachIndexed { argIdx, arg ->
2963+ extractTypeAccessRecursive(arg, locId, typeAccessId, argIdx, callable, exprParent.enclosingStmt, TypeContext .GENERIC_ARGUMENT )
2964+ }
2965+
2966+ val returnTypeAccessId = extractTypeAccess(useType(returnType), locId, typeAccessId, typeAccessArguments.count() - 1 , callable, exprParent.enclosingStmt)
2967+ if (returnType is IrSimpleType ) {
2968+ // Only extract type arguments relating to the constructed type, not the constructor itself:
2969+ extractTypeArguments(returnType.arguments.take(target.owner.parentAsClass.typeParameters.size).filterIsInstance<IrType >(), locId, returnTypeAccessId, callable, exprParent.enclosingStmt)
2970+ }
2971+ } else {
2972+ extractTypeAccessRecursive(fnInterfaceType, locId, idMemberRef, - 3 , callable, exprParent.enclosingStmt)
2973+ }
29532974
29542975 tw.writeMemberRefBinding(idMemberRef, targetCallableId)
29552976
0 commit comments