IR: fix compiler warnings
This commit is contained in:
+8
-8
@@ -271,25 +271,25 @@ internal abstract class HeaderInfoBuilder(context: CommonBackendContext, private
|
|||||||
override fun visitElement(element: IrElement, data: IrCall?): HeaderInfo? = null
|
override fun visitElement(element: IrElement, data: IrCall?): HeaderInfo? = null
|
||||||
|
|
||||||
/** Builds a [HeaderInfo] for iterable expressions that are calls (e.g., `.reversed()`, `.indices`. */
|
/** Builds a [HeaderInfo] for iterable expressions that are calls (e.g., `.reversed()`, `.indices`. */
|
||||||
override fun visitCall(iterable: IrCall, iteratorCall: IrCall?): HeaderInfo? {
|
override fun visitCall(expression: IrCall, data: IrCall?): HeaderInfo? {
|
||||||
// Return the HeaderInfo from the first successful match.
|
// Return the HeaderInfo from the first successful match.
|
||||||
// First, try to match a `reversed()` or `withIndex()` call.
|
// First, try to match a `reversed()` or `withIndex()` call.
|
||||||
val callHeaderInfo = callHandlers.firstNotNullResult { it.handle(iterable, iteratorCall, null, scopeOwnerSymbol()) }
|
val callHeaderInfo = callHandlers.firstNotNullResult { it.handle(expression, data, null, scopeOwnerSymbol()) }
|
||||||
if (callHeaderInfo != null)
|
if (callHeaderInfo != null)
|
||||||
return callHeaderInfo
|
return callHeaderInfo
|
||||||
|
|
||||||
// Try to match a call to build a progression (e.g., `.indices`, `downTo`).
|
// Try to match a call to build a progression (e.g., `.indices`, `downTo`).
|
||||||
val progressionType = ProgressionType.fromIrType(iterable.type, symbols)
|
val progressionType = ProgressionType.fromIrType(expression.type, symbols)
|
||||||
val progressionHeaderInfo =
|
val progressionHeaderInfo =
|
||||||
progressionType?.run { progressionHandlers.firstNotNullResult { it.handle(iterable, iteratorCall, this, scopeOwnerSymbol()) } }
|
progressionType?.run { progressionHandlers.firstNotNullResult { it.handle(expression, data, this, scopeOwnerSymbol()) } }
|
||||||
|
|
||||||
return progressionHeaderInfo ?: super.visitCall(iterable, iteratorCall)
|
return progressionHeaderInfo ?: super.visitCall(expression, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Builds a [HeaderInfo] for iterable expressions not handled in [visitCall]. */
|
/** Builds a [HeaderInfo] for iterable expressions not handled in [visitCall]. */
|
||||||
override fun visitExpression(iterable: IrExpression, iteratorCall: IrCall?): HeaderInfo? {
|
override fun visitExpression(expression: IrExpression, data: IrCall?): HeaderInfo? {
|
||||||
return expressionHandlers.firstNotNullResult { it.handle(iterable, iteratorCall, null, scopeOwnerSymbol()) }
|
return expressionHandlers.firstNotNullResult { it.handle(expression, data, null, scopeOwnerSymbol()) }
|
||||||
?: super.visitExpression(iterable, iteratorCall)
|
?: super.visitExpression(expression, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ fun <Data, Context> makeVerifyAction(verifier: (Context, Data) -> Unit): Action<
|
|||||||
verifier(context, data)
|
verifier(context, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dumpIrElement(actionState: ActionState, data: IrElement, context: Any?): String {
|
fun dumpIrElement(actionState: ActionState, data: IrElement, @Suppress("UNUSED_PARAMETER") context: Any?): String {
|
||||||
val beforeOrAfterStr = actionState.beforeOrAfter.name.toLowerCaseAsciiOnly()
|
val beforeOrAfterStr = actionState.beforeOrAfter.name.toLowerCaseAsciiOnly()
|
||||||
|
|
||||||
var dumpText: String = ""
|
var dumpText: String = ""
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
|||||||
private var restricted: Boolean = false
|
private var restricted: Boolean = false
|
||||||
private var declarationListsRestricted = false
|
private var declarationListsRestricted = false
|
||||||
|
|
||||||
private inline fun <T> (() -> T).withRestrictions(
|
private fun <T> (() -> T).withRestrictions(
|
||||||
newRestrictedToDeclaration: IrDeclaration? = null,
|
newRestrictedToDeclaration: IrDeclaration? = null,
|
||||||
newBodiesEnabled: Boolean? = null,
|
newBodiesEnabled: Boolean? = null,
|
||||||
newRestricted: Boolean? = null,
|
newRestricted: Boolean? = null,
|
||||||
|
|||||||
+1
-1
@@ -140,7 +140,7 @@ class ExportModelGenerator(val context: JsIrBackendContext) {
|
|||||||
klass: IrClass
|
klass: IrClass
|
||||||
): ExportedDeclaration? {
|
): ExportedDeclaration? {
|
||||||
when (val exportability = classExportability(klass)) {
|
when (val exportability = classExportability(klass)) {
|
||||||
is Exportability.Prohibited -> return error(exportability.reason)
|
is Exportability.Prohibited -> error(exportability.reason)
|
||||||
is Exportability.NotNeeded -> return null
|
is Exportability.NotNeeded -> return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -357,7 +357,7 @@ class CallableReferenceLowering(private val context: CommonBackendContext) : Bod
|
|||||||
fun build(): Pair<IrClass, IrConstructor> {
|
fun build(): Pair<IrClass, IrConstructor> {
|
||||||
val clazz = buildReferenceClass()
|
val clazz = buildReferenceClass()
|
||||||
val ctor = createConstructor(clazz)
|
val ctor = createConstructor(clazz)
|
||||||
val invoke = createInvokeMethod(clazz)
|
createInvokeMethod(clazz)
|
||||||
createNameProperty(clazz)
|
createNameProperty(clazz)
|
||||||
// TODO: create name property for KFunction*
|
// TODO: create name property for KFunction*
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -44,7 +44,7 @@ class EnumUsageLowering(val context: JsIrBackendContext) : BodyLoweringPass {
|
|||||||
override fun visitGetEnumValue(expression: IrGetEnumValue): IrExpression {
|
override fun visitGetEnumValue(expression: IrGetEnumValue): IrExpression {
|
||||||
val enumEntry = expression.symbol.owner
|
val enumEntry = expression.symbol.owner
|
||||||
val klass = enumEntry.parent as IrClass
|
val klass = enumEntry.parent as IrClass
|
||||||
return if (klass.isExternal) lowerExternalEnumEntry(enumEntry, klass) else lowerEnumEntry(enumEntry, klass)
|
return if (klass.isExternal) lowerExternalEnumEntry(enumEntry, klass) else lowerEnumEntry(enumEntry)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ class EnumUsageLowering(val context: JsIrBackendContext) : BodyLoweringPass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun lowerEnumEntry(enumEntry: IrEnumEntry, klass: IrClass) =
|
private fun lowerEnumEntry(enumEntry: IrEnumEntry) =
|
||||||
enumEntry.getInstanceFun!!.run { JsIrBuilder.buildCall(symbol) }
|
enumEntry.getInstanceFun!!.run { JsIrBuilder.buildCall(symbol) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ class EnumEntryInstancesBodyLowering(val context: JsIrBackendContext) : BodyLowe
|
|||||||
val index = (irBody as IrBlockBody).statements
|
val index = (irBody as IrBlockBody).statements
|
||||||
.indexOfFirst { it is IrTypeOperatorCall && it.argument is IrDelegatingConstructorCall } + 1
|
.indexOfFirst { it is IrTypeOperatorCall && it.argument is IrDelegatingConstructorCall } + 1
|
||||||
|
|
||||||
(irBody as IrBlockBody).statements.add(index, context.createIrBuilder(container.symbol).run {
|
irBody.statements.add(index, context.createIrBuilder(container.symbol).run {
|
||||||
irSetField(null, entry.correspondingField!!, irGet(entryClass.thisReceiver!!))
|
irSetField(null, entry.correspondingField!!, irGet(entryClass.thisReceiver!!))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -52,6 +52,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
|||||||
|
|
||||||
protected abstract fun IrBlockBodyBuilder.generateCoroutineStart(invokeSuspendFunction: IrFunction, receiver: IrExpression)
|
protected abstract fun IrBlockBodyBuilder.generateCoroutineStart(invokeSuspendFunction: IrFunction, receiver: IrExpression)
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
protected fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration) {
|
protected fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration) {
|
||||||
// Do nothing by default
|
// Do nothing by default
|
||||||
// TODO find out if Kotlin/Native needs this method.
|
// TODO find out if Kotlin/Native needs this method.
|
||||||
|
|||||||
+1
-1
@@ -187,7 +187,7 @@ class JsIntrinsicTransformers(backendContext: JsIrBackendContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add(intrinsics.jsBoxIntrinsic) { call, context ->
|
add(intrinsics.jsBoxIntrinsic) { call, context ->
|
||||||
val arg = translateCallArguments(call as IrCall, context).single()
|
val arg = translateCallArguments(call, context).single()
|
||||||
val inlineClass = call.getTypeArgument(0)!!.getInlinedClass()!!
|
val inlineClass = call.getTypeArgument(0)!!.getInlinedClass()!!
|
||||||
val constructor = inlineClass.declarations.filterIsInstance<IrConstructor>().single { it.isPrimary }
|
val constructor = inlineClass.declarations.filterIsInstance<IrConstructor>().single { it.isPrimary }
|
||||||
JsNew(context.getNameForConstructor(constructor).makeRef(), listOf(arg))
|
JsNew(context.getNameForConstructor(constructor).makeRef(), listOf(arg))
|
||||||
|
|||||||
@@ -324,9 +324,6 @@ class NameTables(
|
|||||||
return sanitizeName(field.name.asString()) + "__error"
|
return sanitizeName(field.name.asString()) + "__error"
|
||||||
}
|
}
|
||||||
|
|
||||||
require(name != null) {
|
|
||||||
"Can't find name for member field ${field.render()}"
|
|
||||||
}
|
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,10 +337,6 @@ class NameTables(
|
|||||||
return sanitizeName(function.name.asString()) + "__error" // TODO one case is a virtual method of an abstract class with no implementation
|
return sanitizeName(function.name.asString()) + "__error" // TODO one case is a virtual method of an abstract class with no implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO report backend error
|
|
||||||
require(name != null) {
|
|
||||||
"Can't find name for member function ${function.render()}"
|
|
||||||
}
|
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -631,6 +631,7 @@ class ExpressionCodegen(
|
|||||||
|
|
||||||
private fun handlePlusMinus(expression: IrSetVariable, value: IrExpression?, isMinus: Boolean): Boolean {
|
private fun handlePlusMinus(expression: IrSetVariable, value: IrExpression?, isMinus: Boolean): Boolean {
|
||||||
if (value is IrConst<*> && value.kind == IrConstKind.Int) {
|
if (value is IrConst<*> && value.kind == IrConstKind.Int) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val delta = (value as IrConst<Int>).value
|
val delta = (value as IrConst<Int>).value
|
||||||
val upperBound = Byte.MAX_VALUE.toInt() + (if (isMinus) 1 else 0)
|
val upperBound = Byte.MAX_VALUE.toInt() + (if (isMinus) 1 else 0)
|
||||||
val lowerBound = Byte.MIN_VALUE.toInt() + (if (isMinus) 1 else 0)
|
val lowerBound = Byte.MIN_VALUE.toInt() + (if (isMinus) 1 else 0)
|
||||||
|
|||||||
+1
-1
@@ -249,7 +249,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
SamEqualsHashCodeMethodsGenerator(backendContext, functionReferenceClass, samSuperType) { receiver ->
|
SamEqualsHashCodeMethodsGenerator(backendContext, functionReferenceClass, samSuperType) {
|
||||||
val internalClass = when {
|
val internalClass = when {
|
||||||
isAdaptedReference -> backendContext.ir.symbols.adaptedFunctionReference
|
isAdaptedReference -> backendContext.ir.symbols.adaptedFunctionReference
|
||||||
else -> backendContext.ir.symbols.functionReferenceImpl
|
else -> backendContext.ir.symbols.functionReferenceImpl
|
||||||
|
|||||||
+13
-13
@@ -78,25 +78,25 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
// in another class then the one it is nested under in the IR.
|
// in another class then the one it is nested under in the IR.
|
||||||
// TODO: Loosen this up for local functions for lambdas passed as an inline lambda
|
// TODO: Loosen this up for local functions for lambdas passed as an inline lambda
|
||||||
// argument to an inline function. In that case the code does end up in the current class.
|
// argument to an inline function. In that case the code does end up in the current class.
|
||||||
override fun visitFunction(declaration: IrFunction, currentClass: IrClass?): IrStatement {
|
override fun visitFunction(declaration: IrFunction, data: IrClass?): IrStatement {
|
||||||
val codeMightBeGeneratedInDifferentClass = declaration.isSuspend ||
|
val codeMightBeGeneratedInDifferentClass = declaration.isSuspend ||
|
||||||
declaration.isInline ||
|
declaration.isInline ||
|
||||||
declaration.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
declaration.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||||
declaration.transformChildren(this, currentClass.takeUnless { codeMightBeGeneratedInDifferentClass })
|
declaration.transformChildren(this, data.takeUnless { codeMightBeGeneratedInDifferentClass })
|
||||||
return declaration
|
return declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitCall(expression: IrCall, currentClass: IrClass?): IrExpression {
|
override fun visitCall(expression: IrCall, data: IrClass?): IrExpression {
|
||||||
expression.transformChildren(this, currentClass)
|
expression.transformChildren(this, data)
|
||||||
|
|
||||||
removeIntTypeSafeCastsForEquality(expression)
|
removeIntTypeSafeCastsForEquality(expression)
|
||||||
|
|
||||||
if (expression.symbol.owner.origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR) {
|
if (expression.symbol.owner.origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR) {
|
||||||
if (currentClass == null) return expression
|
if (data == null) return expression
|
||||||
val simpleFunction = (expression.symbol.owner as? IrSimpleFunction) ?: return expression
|
val simpleFunction = (expression.symbol.owner as? IrSimpleFunction) ?: return expression
|
||||||
val property = simpleFunction.correspondingPropertySymbol?.owner ?: return expression
|
val property = simpleFunction.correspondingPropertySymbol?.owner ?: return expression
|
||||||
if (property.isLateinit) return expression
|
if (property.isLateinit) return expression
|
||||||
return optimizePropertyAccess(expression, simpleFunction, property, currentClass)
|
return optimizePropertyAccess(expression, simpleFunction, property, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNegation(expression, context) && isNegation(expression.dispatchReceiver!!, context)) {
|
if (isNegation(expression, context) && isNegation(expression.dispatchReceiver!!, context)) {
|
||||||
@@ -185,9 +185,9 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
return expression
|
return expression
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitWhen(expression: IrWhen, currentClass: IrClass?): IrExpression {
|
override fun visitWhen(expression: IrWhen, data: IrClass?): IrExpression {
|
||||||
val isCompilerGenerated = expression.origin == null
|
val isCompilerGenerated = expression.origin == null
|
||||||
expression.transformChildren(this, currentClass)
|
expression.transformChildren(this, data)
|
||||||
// Remove all branches with constant false condition.
|
// Remove all branches with constant false condition.
|
||||||
expression.branches.removeIf {
|
expression.branches.removeIf {
|
||||||
it.condition.isFalseConst() && isCompilerGenerated
|
it.condition.isFalseConst() && isCompilerGenerated
|
||||||
@@ -329,19 +329,19 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitBlockBody(body: IrBlockBody, currentClass: IrClass?): IrBody {
|
override fun visitBlockBody(body: IrBlockBody, data: IrClass?): IrBody {
|
||||||
body.transformChildren(this, currentClass)
|
body.transformChildren(this, data)
|
||||||
removeUnnecessaryTemporaryVariables(body.statements)
|
removeUnnecessaryTemporaryVariables(body.statements)
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitContainerExpression(expression: IrContainerExpression, currentClass: IrClass?): IrExpression {
|
override fun visitContainerExpression(expression: IrContainerExpression, data: IrClass?): IrExpression {
|
||||||
expression.transformChildren(this, currentClass)
|
expression.transformChildren(this, data)
|
||||||
removeUnnecessaryTemporaryVariables(expression.statements)
|
removeUnnecessaryTemporaryVariables(expression.statements)
|
||||||
return expression
|
return expression
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitGetValue(expression: IrGetValue, currentClass: IrClass?): IrExpression {
|
override fun visitGetValue(expression: IrGetValue, data: IrClass?): IrExpression {
|
||||||
// Replace IrGetValue of an immutable temporary variable with a constant
|
// Replace IrGetValue of an immutable temporary variable with a constant
|
||||||
// initializer with the constant initializer.
|
// initializer with the constant initializer.
|
||||||
val variable = expression.symbol.owner
|
val variable = expression.symbol.owner
|
||||||
|
|||||||
+2
-6
@@ -9,9 +9,7 @@ import org.jetbrains.kotlin.backend.common.ir.Ir
|
|||||||
import org.jetbrains.kotlin.backend.common.ir.Symbols
|
import org.jetbrains.kotlin.backend.common.ir.Symbols
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsMapping
|
import org.jetbrains.kotlin.ir.backend.js.JsMapping
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsSharedVariablesManager
|
import org.jetbrains.kotlin.ir.backend.js.JsSharedVariablesManager
|
||||||
@@ -21,19 +19,17 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
|||||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
|
||||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
class WasmBackendContext(
|
class WasmBackendContext(
|
||||||
val module: ModuleDescriptor,
|
val module: ModuleDescriptor,
|
||||||
override val irBuiltIns: IrBuiltIns,
|
override val irBuiltIns: IrBuiltIns,
|
||||||
symbolTable: SymbolTable,
|
@Suppress("UNUSED_PARAMETER") symbolTable: SymbolTable,
|
||||||
irModuleFragment: IrModuleFragment,
|
@Suppress("UNUSED_PARAMETER") irModuleFragment: IrModuleFragment,
|
||||||
val additionalExportedDeclarations: Set<FqName>,
|
val additionalExportedDeclarations: Set<FqName>,
|
||||||
override val configuration: CompilerConfiguration
|
override val configuration: CompilerConfiguration
|
||||||
) : JsCommonBackendContext {
|
) : JsCommonBackendContext {
|
||||||
|
|||||||
+2
-2
@@ -106,8 +106,8 @@ class ExpressionTransformer : BaseTransformer<WasmInstruction, WasmCodegenContex
|
|||||||
|
|
||||||
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: WasmCodegenContext): WasmInstruction {
|
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: WasmCodegenContext): WasmInstruction {
|
||||||
val wasmArgument = expressionToWasmInstruction(expression.argument, data)
|
val wasmArgument = expressionToWasmInstruction(expression.argument, data)
|
||||||
when (expression.operator) {
|
if (expression.operator == IrTypeOperator.IMPLICIT_COERCION_TO_UNIT) {
|
||||||
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> return wasmArgument
|
return wasmArgument
|
||||||
}
|
}
|
||||||
TODO("IrTypeOperatorCall:\n ${expression.dump()}")
|
TODO("IrTypeOperatorCall:\n ${expression.dump()}")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -245,7 +245,7 @@ private fun StatementGenerator.generateReceiverForCalleeImportedFromObject(
|
|||||||
private fun StatementGenerator.generateVarargExpressionUsing(
|
private fun StatementGenerator.generateVarargExpressionUsing(
|
||||||
varargArgument: VarargValueArgument,
|
varargArgument: VarargValueArgument,
|
||||||
valueParameter: ValueParameterDescriptor,
|
valueParameter: ValueParameterDescriptor,
|
||||||
resolvedCall: ResolvedCall<*>, // TODO resolvedCall is required for suspend conversions, see KT-38604
|
@Suppress("UNUSED_PARAMETER") resolvedCall: ResolvedCall<*>, // TODO resolvedCall is required for suspend conversions, see KT-38604
|
||||||
generateArgumentExpression: (KtExpression) -> IrExpression?
|
generateArgumentExpression: (KtExpression) -> IrExpression?
|
||||||
): IrExpression? {
|
): IrExpression? {
|
||||||
if (varargArgument.arguments.isEmpty()) {
|
if (varargArgument.arguments.isEmpty()) {
|
||||||
|
|||||||
+2
@@ -74,6 +74,7 @@ interface PersistentIrElementBase<T : Carrier> : IrElement, Carrier {
|
|||||||
|
|
||||||
fun ensureLowered()
|
fun ensureLowered()
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun getCarrier(): T {
|
fun getCarrier(): T {
|
||||||
stageController.currentStage.let { stage ->
|
stageController.currentStage.let { stage ->
|
||||||
ensureLowered()
|
ensureLowered()
|
||||||
@@ -104,6 +105,7 @@ interface PersistentIrElementBase<T : Carrier> : IrElement, Carrier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO naming? e.g. `mutableCarrier`
|
// TODO naming? e.g. `mutableCarrier`
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun setCarrier(): T {
|
fun setCarrier(): T {
|
||||||
val stage = stageController.currentStage
|
val stage = stageController.currentStage
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrClass.createMembers(isK: Boolean, isSuspend: Boolean, arity: Int, name: String, descriptorFactory: FunctionDescriptorFactory) {
|
private fun IrClass.createMembers(isK: Boolean, isSuspend: Boolean, descriptorFactory: FunctionDescriptorFactory) {
|
||||||
if (!isK) {
|
if (!isK) {
|
||||||
val invokeSymbol = descriptorFactory.memberDescriptor("invoke") {
|
val invokeSymbol = descriptorFactory.memberDescriptor("invoke") {
|
||||||
val returnType = with(IrSimpleTypeBuilder()) {
|
val returnType = with(IrSimpleTypeBuilder()) {
|
||||||
@@ -461,7 +461,7 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
|||||||
klass.parent = packageFragment
|
klass.parent = packageFragment
|
||||||
packageFragment.declarations += klass
|
packageFragment.declarations += klass
|
||||||
|
|
||||||
klass.createMembers(isK, isSuspend, n, klass.name.identifier, descriptorFactory)
|
klass.createMembers(isK, isSuspend, descriptorFactory)
|
||||||
|
|
||||||
return klass
|
return klass
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class DumpIrTreeVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun IrMemberAccessExpression<*>.getTypeParameterNames(expectedCount: Int): List<String> =
|
private fun IrMemberAccessExpression<*>.getTypeParameterNames(expectedCount: Int): List<String> =
|
||||||
if (this is IrDeclarationReference && symbol.isBound)
|
if (symbol.isBound)
|
||||||
symbol.owner.getTypeParameterNames(expectedCount)
|
symbol.owner.getTypeParameterNames(expectedCount)
|
||||||
else
|
else
|
||||||
getPlaceholderParameterNames(expectedCount)
|
getPlaceholderParameterNames(expectedCount)
|
||||||
|
|||||||
@@ -206,7 +206,9 @@ class SymbolTable(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (d.isBound()) {
|
if (d.isBound()) {
|
||||||
((d.owner as? IrSymbolDeclaration<*>)?.symbol ?: descriptorToSymbol[d]) as S?
|
val result = (d.owner as? IrSymbolDeclaration<*>)?.symbol ?: descriptorToSymbol[d]
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
result as S?
|
||||||
} else {
|
} else {
|
||||||
descriptorToSymbol[d]
|
descriptorToSymbol[d]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,12 @@ dependencies {
|
|||||||
compile(project(":compiler:serialization"))
|
compile(project(":compiler:serialization"))
|
||||||
compile(project(":kotlin-util-klib"))
|
compile(project(":kotlin-util-klib"))
|
||||||
compile(project(":kotlin-util-klib-metadata"))
|
compile(project(":kotlin-util-klib-metadata"))
|
||||||
|
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:ir.psi2ir"))
|
compile(project(":compiler:ir.psi2ir"))
|
||||||
compile(project(":compiler:ir.backend.common"))
|
compile(project(":compiler:ir.backend.common"))
|
||||||
|
compileOnly(project(":kotlin-reflect-api"))
|
||||||
|
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -29,7 +28,7 @@ tasks {
|
|||||||
val compileKotlin by existing(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
val compileKotlin by existing(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs += "-Xopt-in=org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI"
|
freeCompilerArgs += "-Xopt-in=org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI"
|
||||||
|
freeCompilerArgs += "-Xinline-classes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -100,6 +100,7 @@ class IrOverridingUtil(
|
|||||||
fun buildFakeOverridesForClass(clazz: IrClass) {
|
fun buildFakeOverridesForClass(clazz: IrClass) {
|
||||||
val superTypes = allPublicApiSuperTypesOrAny(clazz)
|
val superTypes = allPublicApiSuperTypesOrAny(clazz)
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val fromCurrent = clazz.declarations.filter { it is IrOverridableMember && it.symbol.isPublicApi } as List<IrOverridableMember>
|
val fromCurrent = clazz.declarations.filter { it is IrOverridableMember && it.symbol.isPublicApi } as List<IrOverridableMember>
|
||||||
|
|
||||||
val allFromSuper = superTypes.flatMap { superType ->
|
val allFromSuper = superTypes.flatMap { superType ->
|
||||||
@@ -190,10 +191,7 @@ class IrOverridingUtil(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun filterVisibleFakeOverrides(
|
private fun filterVisibleFakeOverrides(toFilter: Collection<IrOverridableMember>): Collection<IrOverridableMember> {
|
||||||
current: IrClass,
|
|
||||||
toFilter: Collection<IrOverridableMember>
|
|
||||||
): Collection<IrOverridableMember> {
|
|
||||||
return toFilter.filter { member: IrOverridableMember ->
|
return toFilter.filter { member: IrOverridableMember ->
|
||||||
!Visibilities.isPrivate(member.visibility)
|
!Visibilities.isPrivate(member.visibility)
|
||||||
}
|
}
|
||||||
@@ -296,7 +294,7 @@ class IrOverridingUtil(
|
|||||||
overridables: Collection<IrOverridableMember>,
|
overridables: Collection<IrOverridableMember>,
|
||||||
current: IrClass
|
current: IrClass
|
||||||
) {
|
) {
|
||||||
val effectiveOverridden = filterVisibleFakeOverrides(current, overridables)
|
val effectiveOverridden = filterVisibleFakeOverrides(overridables)
|
||||||
|
|
||||||
// The descriptor based algorithm goes further building invisible fakes here,
|
// The descriptor based algorithm goes further building invisible fakes here,
|
||||||
// but we don't use invisible fakes in IR
|
// but we don't use invisible fakes in IR
|
||||||
|
|||||||
+6
-5
@@ -1,18 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.backend.common.overrides
|
package org.jetbrains.kotlin.backend.common.overrides
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.parents
|
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithVisibility
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithVisibility
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrOverridableMember
|
import org.jetbrains.kotlin.ir.declarations.IrOverridableMember
|
||||||
import org.jetbrains.kotlin.ir.util.module
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|
||||||
|
|
||||||
// The contents of this file is from VisibilityUtil.kt adapted to IR.
|
// The contents of this file is from VisibilityUtil.kt adapted to IR.
|
||||||
// TODO: The code would better be commonized for descriptors, ir and fir.
|
// TODO: The code would better be commonized for descriptors, ir and fir.
|
||||||
|
|
||||||
fun isVisibleForOverride(
|
fun isVisibleForOverride(
|
||||||
overriding: IrOverridableMember,
|
@Suppress("UNUSED_PARAMETER") overriding: IrOverridableMember,
|
||||||
fromSuper: IrOverridableMember
|
fromSuper: IrOverridableMember
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return !Visibilities.isPrivate((fromSuper as IrDeclarationWithVisibility).visibility)
|
return !Visibilities.isPrivate((fromSuper as IrDeclarationWithVisibility).visibility)
|
||||||
|
|||||||
+1
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:OptIn(ExperimentalUnsignedTypes::class)
|
@file:OptIn(ExperimentalUnsignedTypes::class)
|
||||||
|
@file:Suppress("NAME_SHADOWING")
|
||||||
|
|
||||||
package org.jetbrains.kotlin.backend.common.serialization
|
package org.jetbrains.kotlin.backend.common.serialization
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -106,9 +106,9 @@ class ExpectActualTable(val expectDescriptorToSymbol: MutableMap<DeclarationDesc
|
|||||||
}
|
}
|
||||||
|
|
||||||
val expects: List<MemberDescriptor> = if (descriptor is ClassConstructorDescriptor && descriptor.isPrimary) {
|
val expects: List<MemberDescriptor> = if (descriptor is ClassConstructorDescriptor && descriptor.isPrimary) {
|
||||||
(descriptor.containingDeclaration.findExpects() as List<ClassDescriptor>).map {
|
descriptor.containingDeclaration.findExpects().mapNotNull {
|
||||||
it.unsubstitutedPrimaryConstructor
|
(it as ClassDescriptor).unsubstitutedPrimaryConstructor
|
||||||
}.filterNotNull()
|
}
|
||||||
} else {
|
} else {
|
||||||
descriptor.findExpects()
|
descriptor.findExpects()
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -435,7 +435,6 @@ abstract class IrFileDeserializer(
|
|||||||
proto: ProtoEnumConstructorCall,
|
proto: ProtoEnumConstructorCall,
|
||||||
start: Int,
|
start: Int,
|
||||||
end: Int,
|
end: Int,
|
||||||
type: IrType
|
|
||||||
): IrEnumConstructorCall {
|
): IrEnumConstructorCall {
|
||||||
val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol
|
val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol
|
||||||
val call = IrEnumConstructorCallImpl(
|
val call = IrEnumConstructorCallImpl(
|
||||||
@@ -587,7 +586,7 @@ abstract class IrFileDeserializer(
|
|||||||
return callable
|
return callable
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int, type: IrType): IrReturn {
|
private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int): IrReturn {
|
||||||
val symbol = deserializeIrSymbolAndRemap(proto.returnTarget) as IrReturnTargetSymbol
|
val symbol = deserializeIrSymbolAndRemap(proto.returnTarget) as IrReturnTargetSymbol
|
||||||
val value = deserializeExpression(proto.value)
|
val value = deserializeExpression(proto.value)
|
||||||
return IrReturnImpl(start, end, builtIns.nothingType, symbol, value)
|
return IrReturnImpl(start, end, builtIns.nothingType, symbol, value)
|
||||||
@@ -631,7 +630,7 @@ abstract class IrFileDeserializer(
|
|||||||
return IrStringConcatenationImpl(start, end, type, arguments)
|
return IrStringConcatenationImpl(start, end, type, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int, type: IrType): IrThrowImpl {
|
private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int): IrThrowImpl {
|
||||||
return IrThrowImpl(start, end, builtIns.nothingType, deserializeExpression(proto.value))
|
return IrThrowImpl(start, end, builtIns.nothingType, deserializeExpression(proto.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,7 +867,7 @@ abstract class IrFileDeserializer(
|
|||||||
CONTINUE -> deserializeContinue(proto.`continue`, start, end, type)
|
CONTINUE -> deserializeContinue(proto.`continue`, start, end, type)
|
||||||
DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end)
|
DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end)
|
||||||
DO_WHILE -> deserializeDoWhile(proto.doWhile, start, end, type)
|
DO_WHILE -> deserializeDoWhile(proto.doWhile, start, end, type)
|
||||||
ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end, type)
|
ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end)
|
||||||
FUNCTION_REFERENCE -> deserializeFunctionReference(proto.functionReference, start, end, type)
|
FUNCTION_REFERENCE -> deserializeFunctionReference(proto.functionReference, start, end, type)
|
||||||
GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type)
|
GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type)
|
||||||
GET_CLASS -> deserializeGetClass(proto.getClass, start, end, type)
|
GET_CLASS -> deserializeGetClass(proto.getClass, start, end, type)
|
||||||
@@ -878,11 +877,11 @@ abstract class IrFileDeserializer(
|
|||||||
LOCAL_DELEGATED_PROPERTY_REFERENCE -> deserializeIrLocalDelegatedPropertyReference(proto.localDelegatedPropertyReference, start, end, type)
|
LOCAL_DELEGATED_PROPERTY_REFERENCE -> deserializeIrLocalDelegatedPropertyReference(proto.localDelegatedPropertyReference, start, end, type)
|
||||||
INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end)
|
INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end)
|
||||||
PROPERTY_REFERENCE -> deserializePropertyReference(proto.propertyReference, start, end, type)
|
PROPERTY_REFERENCE -> deserializePropertyReference(proto.propertyReference, start, end, type)
|
||||||
RETURN -> deserializeReturn(proto.`return`, start, end, type)
|
RETURN -> deserializeReturn(proto.`return`, start, end)
|
||||||
SET_FIELD -> deserializeSetField(proto.setField, start, end)
|
SET_FIELD -> deserializeSetField(proto.setField, start, end)
|
||||||
SET_VARIABLE -> deserializeSetVariable(proto.setVariable, start, end)
|
SET_VARIABLE -> deserializeSetVariable(proto.setVariable, start, end)
|
||||||
STRING_CONCAT -> deserializeStringConcat(proto.stringConcat, start, end, type)
|
STRING_CONCAT -> deserializeStringConcat(proto.stringConcat, start, end, type)
|
||||||
THROW -> deserializeThrow(proto.`throw`, start, end, type)
|
THROW -> deserializeThrow(proto.`throw`, start, end)
|
||||||
TRY -> deserializeTry(proto.`try`, start, end, type)
|
TRY -> deserializeTry(proto.`try`, start, end, type)
|
||||||
TYPE_OP -> deserializeTypeOp(proto.typeOp, start, end, type)
|
TYPE_OP -> deserializeTypeOp(proto.typeOp, start, end, type)
|
||||||
VARARG -> deserializeVararg(proto.vararg, start, end, type)
|
VARARG -> deserializeVararg(proto.vararg, start, end, type)
|
||||||
|
|||||||
+4
-4
@@ -145,12 +145,12 @@ abstract class KlibMetadataSerializer(
|
|||||||
|
|
||||||
protected fun serializeDescriptors(
|
protected fun serializeDescriptors(
|
||||||
fqName: FqName,
|
fqName: FqName,
|
||||||
classifierDescriptors: List<DeclarationDescriptor>,
|
allClassifierDescriptors: List<DeclarationDescriptor>,
|
||||||
topLevelDescriptors: List<DeclarationDescriptor>
|
allTopLevelDescriptors: List<DeclarationDescriptor>
|
||||||
): List<ProtoBuf.PackageFragment> {
|
): List<ProtoBuf.PackageFragment> {
|
||||||
|
|
||||||
val classifierDescriptors = classifierDescriptors.filterOutExpects()
|
val classifierDescriptors = allClassifierDescriptors.filterOutExpects()
|
||||||
val topLevelDescriptors = topLevelDescriptors.filterOutExpects()
|
val topLevelDescriptors = allTopLevelDescriptors.filterOutExpects()
|
||||||
|
|
||||||
if (TOP_LEVEL_CLASS_DECLARATION_COUNT_PER_FILE == null &&
|
if (TOP_LEVEL_CLASS_DECLARATION_COUNT_PER_FILE == null &&
|
||||||
TOP_LEVEL_DECLARATION_COUNT_PER_FILE == null) {
|
TOP_LEVEL_DECLARATION_COUNT_PER_FILE == null) {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ fun generateKLib(
|
|||||||
deserializeFakeOverrides
|
deserializeFakeOverrides
|
||||||
)
|
)
|
||||||
|
|
||||||
val deserializedModuleFragments = sortDependencies(allDependencies.getFullList(), depsDescriptors.descriptors).map {
|
sortDependencies(allDependencies.getFullList(), depsDescriptors.descriptors).map {
|
||||||
irLinker.deserializeOnlyHeaderModule(depsDescriptors.getModuleDescriptor(it), it)
|
irLinker.deserializeOnlyHeaderModule(depsDescriptors.getModuleDescriptor(it), it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class IrLibraryLayoutImpl(klib: File, component: String) : KotlinLibraryLayoutIm
|
|||||||
FromZipIrLibraryImpl(this, zipFileSystem)
|
FromZipIrLibraryImpl(this, zipFileSystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
open class BaseLibraryAccess<L : KotlinLibraryLayout>(val klib: File, component: String?) {
|
open class BaseLibraryAccess<L : KotlinLibraryLayout>(val klib: File, component: String?) {
|
||||||
open val layout = KotlinLibraryLayoutImpl(klib, component)
|
open val layout = KotlinLibraryLayoutImpl(klib, component)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.android.synthetic.res
|
package org.jetbrains.kotlin.android.synthetic.res
|
||||||
|
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.module.ModuleServiceManager
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager
|
import com.intellij.openapi.vfs.VirtualFileManager
|
||||||
@@ -145,7 +144,8 @@ abstract class AndroidLayoutXmlFileManager(val project: Project) {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getInstance(module: Module): AndroidLayoutXmlFileManager? {
|
fun getInstance(module: Module): AndroidLayoutXmlFileManager? {
|
||||||
val service = ModuleServiceManager.getService(module, AndroidLayoutXmlFileManager::class.java)
|
@Suppress("DEPRECATION")
|
||||||
|
val service = com.intellij.openapi.module.ModuleServiceManager.getService(module, AndroidLayoutXmlFileManager::class.java)
|
||||||
return service ?: module.getComponent(AndroidLayoutXmlFileManager::class.java)
|
return service ?: module.getComponent(AndroidLayoutXmlFileManager::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -90,7 +90,7 @@ interface IrBuilderExtension {
|
|||||||
irInvoke(
|
irInvoke(
|
||||||
dispatchReceiver,
|
dispatchReceiver,
|
||||||
callee,
|
callee,
|
||||||
args = *valueArguments.toTypedArray(),
|
args = valueArguments.toTypedArray(),
|
||||||
typeHint = returnTypeHint
|
typeHint = returnTypeHint
|
||||||
).also { call -> typeArguments.forEachIndexed(call::putTypeArgument) }
|
).also { call -> typeArguments.forEachIndexed(call::putTypeArgument) }
|
||||||
|
|
||||||
@@ -500,11 +500,10 @@ interface IrBuilderExtension {
|
|||||||
property.type,
|
property.type,
|
||||||
genericIndex = property.genericIndex
|
genericIndex = property.genericIndex
|
||||||
)
|
)
|
||||||
?.let { expr -> wrapWithNullableSerializerIfNeeded(property.module, property.type, expr, nullableSerClass) }
|
?.let { expr -> wrapWithNullableSerializerIfNeeded(property.type, expr, nullableSerClass) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrBuilderWithScope.wrapWithNullableSerializerIfNeeded(
|
private fun IrBuilderWithScope.wrapWithNullableSerializerIfNeeded(
|
||||||
module: ModuleDescriptor,
|
|
||||||
type: KotlinType,
|
type: KotlinType,
|
||||||
expression: IrExpression,
|
expression: IrExpression,
|
||||||
nullableSerializerClass: IrClassSymbol
|
nullableSerializerClass: IrClassSymbol
|
||||||
@@ -582,7 +581,7 @@ interface IrBuilderExtension {
|
|||||||
type.genericIndex,
|
type.genericIndex,
|
||||||
genericGetter
|
genericGetter
|
||||||
) ?: return null
|
) ?: return null
|
||||||
return wrapWithNullableSerializerIfNeeded(module, type, expr, nullableSerClass)
|
return wrapWithNullableSerializerIfNeeded(type, expr, nullableSerClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
var serializerClass = serializerClassOriginal
|
var serializerClass = serializerClassOriginal
|
||||||
@@ -661,7 +660,7 @@ interface IrBuilderExtension {
|
|||||||
(genericType.constructor.declarationDescriptor as TypeParameterDescriptor).representativeUpperBound
|
(genericType.constructor.declarationDescriptor as TypeParameterDescriptor).representativeUpperBound
|
||||||
)!!
|
)!!
|
||||||
}!!
|
}!!
|
||||||
wrapWithNullableSerializerIfNeeded(module, type, expr, nullableSerClass)
|
wrapWithNullableSerializerIfNeeded(type, expr, nullableSerClass)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-2
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.js.backend.ast.JsNameRef
|
|||||||
import org.jetbrains.kotlin.js.backend.ast.JsReturn
|
import org.jetbrains.kotlin.js.backend.ast.JsReturn
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
||||||
import org.jetbrains.kotlin.js.translate.declaration.DeclarationBodyVisitor
|
import org.jetbrains.kotlin.js.translate.declaration.DeclarationBodyVisitor
|
||||||
import org.jetbrains.kotlin.psi.KtPureClassOrObject
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCompanionCodegen
|
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCompanionCodegen
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.findTypeSerializer
|
import org.jetbrains.kotlinx.serialization.compiler.backend.common.findTypeSerializer
|
||||||
@@ -62,7 +61,7 @@ class SerializableCompanionJsTranslator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun translate(declaration: KtPureClassOrObject, descriptor: ClassDescriptor, translator: DeclarationBodyVisitor, context: TranslationContext) {
|
fun translate(descriptor: ClassDescriptor, translator: DeclarationBodyVisitor, context: TranslationContext) {
|
||||||
val serializableClass = getSerializableClassDescriptorByCompanion(descriptor) ?: return
|
val serializableClass = getSerializableClassDescriptorByCompanion(descriptor) ?: return
|
||||||
if (serializableClass.shouldHaveGeneratedMethodsInCompanion)
|
if (serializableClass.shouldHaveGeneratedMethodsInCompanion)
|
||||||
SerializableCompanionJsTranslator(descriptor, translator, context).generate()
|
SerializableCompanionJsTranslator(descriptor, translator, context).generate()
|
||||||
|
|||||||
-2
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.js.backend.ast.*
|
|||||||
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
|
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
|
||||||
import org.jetbrains.kotlin.js.translate.context.Namer
|
import org.jetbrains.kotlin.js.translate.context.Namer
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
||||||
import org.jetbrains.kotlin.js.translate.declaration.DeclarationBodyVisitor
|
|
||||||
import org.jetbrains.kotlin.js.translate.general.Translation
|
import org.jetbrains.kotlin.js.translate.general.Translation
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||||
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
|
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
|
||||||
@@ -160,7 +159,6 @@ class SerializableJsTranslator(
|
|||||||
fun translate(
|
fun translate(
|
||||||
declaration: KtPureClassOrObject,
|
declaration: KtPureClassOrObject,
|
||||||
serializableClass: ClassDescriptor,
|
serializableClass: ClassDescriptor,
|
||||||
translator: DeclarationBodyVisitor,
|
|
||||||
context: TranslationContext
|
context: TranslationContext
|
||||||
) {
|
) {
|
||||||
if (serializableClass.isInternalSerializable)
|
if (serializableClass.isInternalSerializable)
|
||||||
|
|||||||
-2
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
|
|||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtPureClassOrObject
|
import org.jetbrains.kotlin.psi.KtPureClassOrObject
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
||||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen
|
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.getSerialTypeInfo
|
import org.jetbrains.kotlinx.serialization.compiler.backend.common.getSerialTypeInfo
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||||
@@ -362,7 +361,6 @@ open class SerializerJsTranslator(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun translate(
|
fun translate(
|
||||||
declaration: KtPureClassOrObject,
|
|
||||||
descriptor: ClassDescriptor,
|
descriptor: ClassDescriptor,
|
||||||
translator: DeclarationBodyVisitor,
|
translator: DeclarationBodyVisitor,
|
||||||
context: TranslationContext
|
context: TranslationContext
|
||||||
|
|||||||
+3
-3
@@ -27,8 +27,8 @@ import org.jetbrains.kotlinx.serialization.compiler.backend.js.SerializerJsTrans
|
|||||||
|
|
||||||
open class SerializationJsExtension: JsSyntheticTranslateExtension {
|
open class SerializationJsExtension: JsSyntheticTranslateExtension {
|
||||||
override fun generateClassSyntheticParts(declaration: KtPureClassOrObject, descriptor: ClassDescriptor, translator: DeclarationBodyVisitor, context: TranslationContext) {
|
override fun generateClassSyntheticParts(declaration: KtPureClassOrObject, descriptor: ClassDescriptor, translator: DeclarationBodyVisitor, context: TranslationContext) {
|
||||||
SerializerJsTranslator.translate(declaration, descriptor, translator, context)
|
SerializerJsTranslator.translate(descriptor, translator, context)
|
||||||
SerializableJsTranslator.translate(declaration, descriptor, translator, context)
|
SerializableJsTranslator.translate(declaration, descriptor, context)
|
||||||
SerializableCompanionJsTranslator.translate(declaration, descriptor, translator, context)
|
SerializableCompanionJsTranslator.translate(descriptor, translator, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user