[FIR2IR] Handle references to constructors separately

This commit is contained in:
Mikhail Glukhikh
2020-03-31 11:20:56 +03:00
parent 282509b0da
commit a377a6fccb
3 changed files with 13 additions and 2 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression
@@ -66,6 +67,15 @@ internal class CallAndReferenceGenerator(
referencedProperty.setter?.symbol
)
}
is IrConstructorSymbol -> {
val constructor = symbol.owner
val klass = constructor.parent as? IrClass
IrFunctionReferenceImpl(
startOffset, endOffset, type, symbol,
typeArgumentsCount = constructor.typeParameters.size + (klass?.typeParameters?.size ?: 0),
reflectionTarget = symbol
)
}
is IrFunctionSymbol -> {
IrFunctionReferenceImpl(
startOffset, endOffset, type, symbol,
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
@@ -85,7 +85,9 @@ FILE fqName:test fileName:/boundInnerGenericConstructor.kt
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [test/foo]>#' type=IrErrorType
CONST String type=kotlin.String value="O"
CONST String type=kotlin.String value="K"
ERROR_EXPR 'Cannot bind 1 type arguments to ??? call with 0 type parameters' type=kotlin.reflect.KFunction2<T of test.Foo, kotlin.Any?, test.Foo.Inner<kotlin.Any?>>
FUNCTION_REFERENCE 'public constructor <init> (a: T of test.Foo, b: P of test.Foo.Inner) [primary] declared in test.Foo.Inner' type=kotlin.reflect.KFunction2<T of test.Foo, kotlin.Any?, test.Foo.Inner<kotlin.Any?>> origin=null reflectionTarget=<same>
<P>: kotlin.Any?
$this: GET_VAR 'val z: test.Foo<kotlin.String> [val] declared in test.box' type=test.Foo<kotlin.String> origin=null
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in test'
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin' type=kotlin.String origin=PLUS
$receiver: ERROR_CALL 'Unresolved reference: <Unresolved name: a>#' type=IrErrorType