FIR2IR: determine type parameters before value parameters

Type parameters can be referred from value parameters,
so we should determine them earlier to be able to set their indexes
This commit is contained in:
Mikhail Glukhikh
2020-02-20 13:24:10 +03:00
parent 334cab7357
commit 8c21f04bf4
8 changed files with 4 additions and 10 deletions
@@ -398,6 +398,9 @@ class Fir2IrDeclarationStorage(
private fun <T : IrFunction> T.declareParameters(function: FirFunction<*>?, containingClass: IrClass?, isStatic: Boolean) {
val parent = this
if (function is FirSimpleFunction) {
setTypeParameters(function)
}
if (function is FirDefaultPropertySetter) {
val type = function.valueParameters.first().returnTypeRef.toIrType(session, this@Fir2IrDeclarationStorage)
declareDefaultSetterParameter(type)
@@ -408,9 +411,6 @@ class Fir2IrDeclarationStorage(
}
if (function !is FirConstructor) {
val thisOrigin = IrDeclarationOrigin.DEFINED
if (function is FirSimpleFunction) {
setTypeParameters(function)
}
val receiverTypeRef = function?.receiverTypeRef
if (receiverTypeRef != null) {
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
@@ -2,7 +2,6 @@
// It doesn't work on JS due to how numbers are represented, but it could be changed in the future.
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND_FIR: JVM_IR
fun <A: Double, B: Any> eq_double_any(a: A, b: B) = a == b
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun <T, R> io(s: R, a: (R) -> T): T {
try {
return a(s)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
fun <K: Any, V: Any> foo(k: K, v: V) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
@@ -86,7 +86,7 @@ FILE fqName:<root> fileName:/typeParameterWithPrimitiveNumericSupertype.kt
then: CONST Boolean type=kotlin.Boolean value=false
FUN name:test5 visibility:public modality:FINAL <T, R> (x:kotlin.Any, y:R of <root>.test5) returnType:kotlin.Boolean
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Float?]
TYPE_PARAMETER name:R index:0 variance: superTypes:[T of <root>.test5]
TYPE_PARAMETER name:R index:1 variance: superTypes:[T of <root>.test5]
VALUE_PARAMETER name:x index:0 type:kotlin.Any
VALUE_PARAMETER name:y index:1 type:R of <root>.test5
BLOCK_BODY