[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.
This commit is contained in:
Sergej Jaskiewicz
2022-07-22 21:51:53 +02:00
committed by Space
parent d35656cb9f
commit dbcffeb0ed
@@ -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 -> {}
}
}
}