[IR] Make descriptor parameter optional for IrFileSymbolImpl and IrExternalPackageFragmentSymbolImpl
Remove DescriptorlessIrFileSymbol and use IrFileSymbolImpl instead.
This commit is contained in:
+3
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -7,16 +7,13 @@ package org.jetbrains.kotlin.ir.backend.js.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
||||
import org.jetbrains.kotlin.backend.common.ir.addChild
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsModule
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsQualifier
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
@@ -45,28 +42,6 @@ private val BODILESS_BUILTIN_CLASSES = listOf(
|
||||
"kotlin.Function"
|
||||
).map { FqName(it) }.toSet()
|
||||
|
||||
private class DescriptorlessIrFileSymbol : IrFileSymbol {
|
||||
override fun bind(owner: IrFile) {
|
||||
_owner = owner
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: PackageFragmentDescriptor
|
||||
get() = error("Operation is unsupported")
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val hasDescriptor: Boolean
|
||||
get() = error("Operation is unsupported")
|
||||
|
||||
private var _owner: IrFile? = null
|
||||
override val owner get() = _owner!!
|
||||
|
||||
override val isBound get() = _owner != null
|
||||
|
||||
override val signature: IdSignature?
|
||||
get() = null
|
||||
}
|
||||
|
||||
private fun isBuiltInClass(declaration: IrDeclaration): Boolean =
|
||||
declaration is IrClass && declaration.fqNameWhenAvailable in BODILESS_BUILTIN_CLASSES
|
||||
|
||||
@@ -85,7 +60,7 @@ class MoveBodilessDeclarationsToSeparatePlaceLowering(private val context: JsIrB
|
||||
|
||||
val externalPackageFragment by lazy {
|
||||
context.externalPackageFragment.getOrPut(irFile.symbol) {
|
||||
IrFileImpl(fileEntry = irFile.fileEntry, fqName = irFile.fqName, symbol = DescriptorlessIrFileSymbol()).also {
|
||||
IrFileImpl(fileEntry = irFile.fileEntry, fqName = irFile.fqName, symbol = IrFileSymbolImpl()).also {
|
||||
it.annotations += irFile.annotations
|
||||
}
|
||||
}
|
||||
|
||||
+4
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.symbols.impl
|
||||
@@ -83,11 +72,11 @@ abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
get() = _owner != null
|
||||
}
|
||||
|
||||
class IrFileSymbolImpl(descriptor: PackageFragmentDescriptor) :
|
||||
class IrFileSymbolImpl(descriptor: PackageFragmentDescriptor? = null) :
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrFile>(descriptor),
|
||||
IrFileSymbol
|
||||
|
||||
class IrExternalPackageFragmentSymbolImpl(descriptor: PackageFragmentDescriptor) :
|
||||
class IrExternalPackageFragmentSymbolImpl(descriptor: PackageFragmentDescriptor? = null) :
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrExternalPackageFragment>(descriptor),
|
||||
IrExternalPackageFragmentSymbol
|
||||
|
||||
|
||||
Reference in New Issue
Block a user