[IR] Introduce new IdSignatures

FileSignature, CompositeSignature, LocalSignature

They are needed to make possible reference any non-local declaration via
 signature, including private signature, type parameters and so on.

- Support those new signatures in proto and klibs
- Rename `isPublic` -> `isPubliclyVisible` due to changed semantic
- Fix FIR
- clean up code
This commit is contained in:
Roman Artemev
2021-05-26 19:26:08 +03:00
committed by TeamCityServer
parent 7139785036
commit 6cdac22a23
58 changed files with 3271 additions and 1330 deletions
@@ -21,17 +21,13 @@ class JsUniqIdClashTracker : IdSignatureClashTracker {
private val committedIdSignatures = mutableMapOf<IdSignature, IrDeclaration>()
override fun commit(declaration: IrDeclaration, signature: IdSignature) {
if (!signature.isPublic) return // don't track local ids
if (!signature.isPubliclyVisible) return // don't track local ids
if (signature in committedIdSignatures) {
val clashedDeclaration = committedIdSignatures[signature]!!
val parent = declaration.parent
val clashedParent = clashedDeclaration.parent
if (declaration is IrTypeParameter && parent is IrSimpleFunction && parent.parent is IrProperty && parent !== clashedParent) {
// Check whether they are type parameters of the same extension property but different accessors
require(clashedParent is IrSimpleFunction)
require(clashedParent.correspondingPropertySymbol === parent.correspondingPropertySymbol)
} else {
if (declaration !is IrTypeParameter || parent !is IrSimpleFunction || clashedParent !is IrSimpleFunction || parent.correspondingPropertySymbol !== clashedParent.correspondingPropertySymbol) {
// TODO: handle clashes properly
error("IdSignature clash: $signature; Existed declaration ${clashedDeclaration.render()} clashed with new ${declaration.render()}")
}
@@ -50,8 +50,7 @@ abstract class AbstractJsDescriptorMangler : DescriptorBasedKotlinManglerImpl()
override fun DeclarationDescriptor.isPlatformSpecificExported() = false
}
private class JsDescriptorManglerComputer(builder: StringBuilder, mode: MangleMode) :
DescriptorMangleComputer(builder, mode) {
private class JsDescriptorManglerComputer(builder: StringBuilder, mode: MangleMode) : DescriptorMangleComputer(builder, mode) {
override fun copy(newMode: MangleMode): DescriptorMangleComputer = JsDescriptorManglerComputer(builder, newMode)
}