FIR2IR: fix constructor referencing in return statement

This commit is contained in:
Mikhail Glukhikh
2019-11-28 13:40:37 +03:00
parent 96e6602da2
commit f58af2e4c3
2 changed files with 6 additions and 2 deletions
@@ -649,9 +649,13 @@ class Fir2IrVisitor(
}
return returnExpression.convertWithOffsets { startOffset, endOffset ->
val result = returnExpression.result
val descriptor = irTarget.descriptor
IrReturnImpl(
startOffset, endOffset, nothingType,
symbolTable.referenceSimpleFunction(irTarget.descriptor),
when (descriptor) {
is ClassConstructorDescriptor -> symbolTable.referenceConstructor(descriptor)
else -> symbolTable.referenceSimpleFunction(descriptor)
},
result.toIrExpression()
)
}
@@ -12,7 +12,7 @@ FILE fqName:<root> fileName:/implicitCastInReturnFromConstructor.kt
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Unit
GET_VAR 'x: kotlin.Any? declared in <root>.C.<init>' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public final fun <init> (x: kotlin.Any?): <root>.C declared in <root>.C'
then: RETURN type=kotlin.Nothing from='public constructor <init> (x: kotlin.Any?) declared in <root>.C'
GET_VAR 'x: kotlin.Any? declared in <root>.C.<init>' type=kotlin.Unit origin=null
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]