[JS IR BE] Fix Ir Copier
* use symbol table to allocate classifier for IrType
This commit is contained in:
+14
-10
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol
|
|||||||
import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
|
import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.DeepCopyIrTree
|
import org.jetbrains.kotlin.ir.util.DeepCopyIrTree
|
||||||
|
import org.jetbrains.kotlin.ir.util.withScope
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
@@ -508,16 +509,19 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
|||||||
|
|
||||||
//---------------------------------------------------------------------//
|
//---------------------------------------------------------------------//
|
||||||
|
|
||||||
override fun visitFunction(declaration: IrFunction): IrFunction =
|
override fun visitFunction(declaration: IrFunction) =
|
||||||
IrFunctionImpl(
|
context.symbolTable.withScope(mapFunctionDeclaration(declaration.descriptor)) { descriptor ->
|
||||||
startOffset = declaration.startOffset,
|
IrFunctionImpl(
|
||||||
endOffset = declaration.endOffset,
|
startOffset = declaration.startOffset,
|
||||||
origin = mapDeclarationOrigin(declaration.origin),
|
endOffset = declaration.endOffset,
|
||||||
descriptor = mapFunctionDeclaration(declaration.descriptor),
|
origin = mapDeclarationOrigin(declaration.origin),
|
||||||
body = declaration.body?.transform(this, null)
|
descriptor = descriptor,
|
||||||
).also {
|
body = declaration.body?.transform(this@InlineCopyIr, null)
|
||||||
it.setOverrides(context.symbolTable)
|
).also {
|
||||||
}.transformParameters(declaration)
|
it.setOverrides(context.symbolTable)
|
||||||
|
it.transformParameters(declaration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------//
|
//---------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,6 @@ fun KotlinType.toIrType(symbolTable: SymbolTable? = null): IrType? {
|
|||||||
// TODO: this function creates unbound symbol which is the great source of problems
|
// TODO: this function creates unbound symbol which is the great source of problems
|
||||||
private fun ClassifierDescriptor.getSymbol(symbolTable: SymbolTable?): IrClassifierSymbol = when (this) {
|
private fun ClassifierDescriptor.getSymbol(symbolTable: SymbolTable?): IrClassifierSymbol = when (this) {
|
||||||
is ClassDescriptor -> symbolTable?.referenceClass(this) ?: IrClassSymbolImpl(this)
|
is ClassDescriptor -> symbolTable?.referenceClass(this) ?: IrClassSymbolImpl(this)
|
||||||
is TypeParameterDescriptor -> /*symbolTable?.referenceTypeParameter(this) ?: */IrTypeParameterSymbolImpl(this)
|
is TypeParameterDescriptor -> symbolTable?.referenceTypeParameter(this) ?: IrTypeParameterSymbolImpl(this)
|
||||||
else -> TODO()
|
else -> TODO()
|
||||||
}
|
}
|
||||||
@@ -413,9 +413,9 @@ open class SymbolTable : ReferenceSymbolTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T> SymbolTable.withScope(owner: DeclarationDescriptor, block: SymbolTable.() -> T): T {
|
inline fun <T, D: DeclarationDescriptor> SymbolTable.withScope(owner: D, block: SymbolTable.(D) -> T): T {
|
||||||
enterScope(owner)
|
enterScope(owner)
|
||||||
val result = block(this)
|
val result = block(owner)
|
||||||
leaveScope(owner)
|
leaveScope(owner)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user