[JS IR BE] Move IrSerializer from native to JS

* Fix issues
This commit is contained in:
Roman Artemev
2019-01-29 18:18:00 +03:00
committed by romanart
parent 5384f23f30
commit 3a444cd0f3
38 changed files with 62204 additions and 125 deletions
@@ -583,7 +583,7 @@ open class WrappedClassDescriptor(
private val _typeConstructor: TypeConstructor by lazy {
LazyTypeConstructor(
this,
{ emptyList() },
{ declaredTypeParameters },
{ owner.superTypes.map { it.toKotlinType() } },
LockBasedStorageManager.NO_LOCKS
)
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
@@ -386,6 +387,8 @@ fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() {
assert(descriptor.declaredTypeParameters.isEmpty())
}
fun isElseBranch(branch: IrBranch) = branch is IrElseBranch || ((branch.condition as? IrConst<Boolean>)?.value == true)
fun IrSimpleFunction.isMethodOfAny() =
((valueParameters.size == 0 && name.asString().let { it == "hashCode" || it == "toString" }) ||
(valueParameters.size == 1 && name.asString() == "equals" && valueParameters[0].type.isNullableAny()))
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.isAny
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
@@ -209,7 +210,9 @@ fun IrConstructor.callsSuper(irBuiltIns: IrBuiltIns): Boolean {
assert(++numberOfCalls == 1) { "More than one delegating constructor call: ${symbol.owner}" }
val delegatingClass = expression.symbol.owner.parent as IrClass
// TODO: figure out why Lazy IR multiplies Declarations for descriptors and fix it
if (delegatingClass.descriptor == superClass.classifierOrFail.descriptor)
if (delegatingClass.descriptor == superClass.classifierOrFail.descriptor || (
delegatingClass.defaultType.isAny() && superClass.isAny()
))
callsSuper = true
else if (delegatingClass.descriptor != constructedClass.descriptor)
throw AssertionError(