[JS IR] Nullify body of declaration on it shouldn't be loaded
This commit is contained in:
committed by
TeamCityServer
parent
4bd6e8a034
commit
2ca74174d3
+1
-1
@@ -54,7 +54,7 @@ class CarrierDeserializer(
|
|||||||
private val expressionBodyCache = mutableMapOf<Int, IrExpressionBody>()
|
private val expressionBodyCache = mutableMapOf<Int, IrExpressionBody>()
|
||||||
|
|
||||||
private fun deserializeExpressionBody(index: Int): IrExpressionBody = expressionBodyCache.getOrPut(index) {
|
private fun deserializeExpressionBody(index: Int): IrExpressionBody = expressionBodyCache.getOrPut(index) {
|
||||||
declarationDeserializer.deserializeExpressionBody(index).also {
|
declarationDeserializer.deserializeExpressionBody(index)!!.also {
|
||||||
injectCarriers(it, index)
|
injectCarriers(it, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-18
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase
|
import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterPublicSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterPublicSymbolImpl
|
||||||
@@ -305,6 +305,7 @@ class IrDeclarationDeserializer(
|
|||||||
).apply {
|
).apply {
|
||||||
if (proto.hasDefaultValue())
|
if (proto.hasDefaultValue())
|
||||||
defaultValue = deserializeExpressionBody(proto.defaultValue)
|
defaultValue = deserializeExpressionBody(proto.defaultValue)
|
||||||
|
?: irFactory.createExpressionBody(IrCompositeImpl(startOffset, endOffset, type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,27 +496,21 @@ class IrDeclarationDeserializer(
|
|||||||
return ProtoExpression.parseFrom(readBody(index), extensionRegistry)
|
return ProtoExpression.parseFrom(readBody(index), extensionRegistry)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeExpressionBody(index: Int): IrExpressionBody {
|
fun deserializeExpressionBody(index: Int): IrExpressionBody? {
|
||||||
return irFactory.createExpressionBody(
|
return if (deserializeBodies) {
|
||||||
if (deserializeBodies) {
|
val bodyData = loadExpressionBodyProto(index)
|
||||||
val bodyData = loadExpressionBodyProto(index)
|
irFactory.createExpressionBody(bodyDeserializer.deserializeExpression(bodyData))
|
||||||
bodyDeserializer.deserializeExpression(bodyData)
|
} else {
|
||||||
} else {
|
null
|
||||||
val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT)
|
}
|
||||||
IrErrorExpressionImpl(-1, -1, errorType, "Expression body is not deserialized yet")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeStatementBody(index: Int): IrElement {
|
fun deserializeStatementBody(index: Int): IrElement? {
|
||||||
return if (deserializeBodies) {
|
return if (deserializeBodies) {
|
||||||
val bodyData = loadStatementBodyProto(index)
|
val bodyData = loadStatementBodyProto(index)
|
||||||
bodyDeserializer.deserializeStatement(bodyData)
|
bodyDeserializer.deserializeStatement(bodyData)
|
||||||
} else {
|
} else {
|
||||||
val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT)
|
null
|
||||||
irFactory.createBlockBody(
|
|
||||||
-1, -1, listOf(IrErrorExpressionImpl(-1, -1, errorType, "Statement body is not deserialized yet"))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +534,7 @@ class IrDeclarationDeserializer(
|
|||||||
if (proto.hasExtensionReceiver()) deserializeIrValueParameter(proto.extensionReceiver, -1)
|
if (proto.hasExtensionReceiver()) deserializeIrValueParameter(proto.extensionReceiver, -1)
|
||||||
else null
|
else null
|
||||||
body =
|
body =
|
||||||
if (proto.hasBody()) deserializeStatementBody(proto.body) as IrBody
|
if (proto.hasBody()) deserializeStatementBody(proto.body) as IrBody?
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -615,7 +610,7 @@ class IrDeclarationDeserializer(
|
|||||||
private fun deserializeIrAnonymousInit(proto: ProtoAnonymousInit): IrAnonymousInitializer =
|
private fun deserializeIrAnonymousInit(proto: ProtoAnonymousInit): IrAnonymousInitializer =
|
||||||
withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, _ ->
|
withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, _ ->
|
||||||
irFactory.createAnonymousInitializer(startOffset, endOffset, origin, checkSymbolType(symbol)).apply {
|
irFactory.createAnonymousInitializer(startOffset, endOffset, origin, checkSymbolType(symbol)).apply {
|
||||||
body = deserializeStatementBody(proto.body) as IrBlockBody
|
body = deserializeStatementBody(proto.body) as IrBlockBody? ?: irFactory.createBlockBody(startOffset, endOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user