[JS IR BE]
* Fix type parameters for callable references * Visit IrCallableReference tree as well
This commit is contained in:
+26
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.backend.js.lower
|
package org.jetbrains.kotlin.ir.backend.js.lower
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||||
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.WrappedValueParameterDescriptor
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
@@ -13,10 +14,12 @@ import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
|||||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||||
import org.jetbrains.kotlin.ir.backend.js.utils.Namer
|
import org.jetbrains.kotlin.ir.backend.js.utils.Namer
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.types.toIrType
|
import org.jetbrains.kotlin.ir.types.toIrType
|
||||||
@@ -50,6 +53,7 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
|||||||
|
|
||||||
inner class CallableReferenceLowerTransformer : IrElementTransformerVoid() {
|
inner class CallableReferenceLowerTransformer : IrElementTransformerVoid() {
|
||||||
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
|
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
|
||||||
|
expression.transformChildrenVoid(this)
|
||||||
val declaration = expression.symbol.owner
|
val declaration = expression.symbol.owner
|
||||||
if (declaration.origin == JsIrBackendContext.callableClosureOrigin) return expression
|
if (declaration.origin == JsIrBackendContext.callableClosureOrigin) return expression
|
||||||
val key = makeCallableKey(declaration, expression)
|
val key = makeCallableKey(declaration, expression)
|
||||||
@@ -58,6 +62,7 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
|
override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
|
||||||
|
expression.transformChildrenVoid(this)
|
||||||
val declaration = expression.getter!!.owner
|
val declaration = expression.getter!!.owner
|
||||||
val key = makeCallableKey(declaration, expression)
|
val key = makeCallableKey(declaration, expression)
|
||||||
val factory = callableToGetterFunction.getOrPut(key) { lowerKPropertyReference(declaration, expression) }
|
val factory = callableToGetterFunction.getOrPut(key) { lowerKPropertyReference(declaration, expression) }
|
||||||
@@ -65,6 +70,7 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
|
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
|
||||||
|
expression.transformChildrenVoid(this)
|
||||||
val key = makeCallableKey(expression.getter.owner, expression)
|
val key = makeCallableKey(expression.getter.owner, expression)
|
||||||
val factory = callableToGetterFunction.getOrPut(key) { lowerLocalKPropertyReference(expression) }
|
val factory = callableToGetterFunction.getOrPut(key) { lowerLocalKPropertyReference(expression) }
|
||||||
return redirectToFunction(expression, factory)
|
return redirectToFunction(expression, factory)
|
||||||
@@ -446,6 +452,26 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val typeParameters =
|
||||||
|
if (declaration is IrConstructor) (declaration.parent as IrClass).typeParameters else declaration.typeParameters
|
||||||
|
|
||||||
|
for (t in typeParameters) {
|
||||||
|
val descriptor = WrappedTypeParameterDescriptor()
|
||||||
|
refGetDeclaration.typeParameters += IrTypeParameterImpl(
|
||||||
|
t.startOffset,
|
||||||
|
t.endOffset,
|
||||||
|
t.origin,
|
||||||
|
IrTypeParameterSymbolImpl(descriptor),
|
||||||
|
t.name,
|
||||||
|
t.index,
|
||||||
|
t.isReified,
|
||||||
|
t.variance
|
||||||
|
).also {
|
||||||
|
descriptor.bind(it)
|
||||||
|
it.parent = refGetDeclaration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return refGetDeclaration
|
return refGetDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
class Wrapper<T>(val value: T)
|
class Wrapper<T>(val value: T)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// IGNORE_BACKEND: NATIVE
|
// IGNORE_BACKEND: NATIVE
|
||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
//For KT-6020
|
//For KT-6020
|
||||||
import kotlin.reflect.KProperty1
|
import kotlin.reflect.KProperty1
|
||||||
import kotlin.reflect.KMutableProperty1
|
import kotlin.reflect.KMutableProperty1
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
var recivier : Any? = "fail"
|
var recivier : Any? = "fail"
|
||||||
var value2 : Any? = "fail2"
|
var value2 : Any? = "fail2"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
//WITH_RUNTIME
|
//WITH_RUNTIME
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Reference in New Issue
Block a user