From dbcffeb0ed853e861effe3e44538e589f24f4f8d Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Fri, 22 Jul 2022 21:51:53 +0200 Subject: [PATCH] [JS] Fix a compiler crash when generating sourcemaps It is possible that the source info has the type `KtPureElement`. For example, the serialization plugin may create a synthetic companion object for a `@Serializable`-annotated class. This results in an instance of the `SyntheticClassOrObjectDescriptor.SyntheticDeclaration` class being indirectly set as source info. This class implements the `KtPureElement` interface. --- .../kotlin/js/sourceMap/SourceMapBuilderConsumer.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt index 6c727021884..aeabdee5f0a 100644 --- a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt +++ b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt @@ -8,6 +8,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.js.backend.SourceLocationConsumer import org.jetbrains.kotlin.js.backend.ast.JsLocationWithSource import org.jetbrains.kotlin.js.backend.ast.JsNode +import org.jetbrains.kotlin.psi.KtPureElement import org.jetbrains.kotlin.resolve.calls.util.isFakePsiElement import org.jetbrains.kotlin.utils.addToStdlib.popLast import java.io.* @@ -86,8 +87,8 @@ class SourceMapBuilderConsumer( sourceInfo.startChar ) } - is JsNode -> { /* Can occur on legacy BE, not sure if it's a bug or not. */ } - else -> error("Unexpected sourceInfo: $sourceInfo") + is JsNode, is KtPureElement -> { /* Can occur on legacy BE */ } + else -> {} } } }