[JS IR BE] Make kotlinx.io compile

- Fix expect/actual default arguments
 - Fix dynamic type in inliner
 - Fix external varargs
This commit is contained in:
Roman Artemev
2019-05-27 14:06:33 +03:00
committed by romanart
parent 753a9a1c36
commit 5686de7e09
16 changed files with 111 additions and 21 deletions
@@ -87,7 +87,7 @@ private val moveBodilessDeclarationsToSeparatePlacePhase = makeCustomJsModulePha
)
private val expectDeclarationsRemovingPhase = makeJsModulePhase(
::ExpectDeclarationsRemoving,
::ExpectDeclarationsRemoveLowering,
name = "ExpectDeclarationsRemoving",
description = "Remove expect declaration from module fragment"
)
@@ -157,8 +157,10 @@ internal class DeepCopyIrTreeWithSymbolsForInliner(
if (type !is IrSimpleType) return type
val substitutedType = typeArguments?.get(type.classifier)
if (substitutedType != null) {
substitutedType as IrSimpleType
if (substitutedType is IrDynamicType) return substitutedType
if (substitutedType is IrSimpleType) {
return substitutedType.buildSimpleType {
kotlinType = null
hasQuestionMark = type.hasQuestionMark or substitutedType.isMarkedNullable()
@@ -282,6 +282,8 @@ class IrElementToJsExpressionTransformer : BaseIrElementToJsNodeTransformer<JsEx
JsInvocation(
// Create scope for temporary variable holding dispatch receiver
// It is used both during method reference and passing `this` value to `apply` function.
JsNameRef(
"call",
JsFunction(
context.currentScope,
JsBlock(
@@ -297,7 +299,8 @@ class IrElementToJsExpressionTransformer : BaseIrElementToJsNodeTransformer<JsEx
)
),
"VarargIIFE"
)
)),
JsThisRef()
)
} else {
JsInvocation(
@@ -78,7 +78,7 @@ fun translateCallArguments(expression: IrMemberAccessExpression, context: JsGene
val argument = expression.getValueArgument(index)
val result = argument?.accept(transformer, context)
if (result == null) {
assert(expression is IrFunctionAccessExpression && expression.symbol.owner.isEffectivelyExternal())
require(expression is IrFunctionAccessExpression && expression.symbol.owner.isEffectivelyExternal())
JsPrefixOperation(JsUnaryOperator.VOID, JsIntLiteral(1))
} else
result