[IR] Avoid subclassing IrFileImpl
to avoid custom IrElement implementations. #KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
1c17219a7b
commit
747b69c6c0
@@ -5,22 +5,35 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.types.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrFileEntry
|
||||
import org.jetbrains.kotlin.ir.LineAndColumn
|
||||
import org.jetbrains.kotlin.ir.SourceRangeInfo
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
|
||||
|
||||
private val ErrorFile = IrFileImpl(
|
||||
fileEntry = object : IrFileEntry {
|
||||
override val name: String = "<error-class>"
|
||||
override val maxOffset: Int
|
||||
get() = shouldNotBeCalled()
|
||||
|
||||
override fun getSourceRangeInfo(beginOffset: Int, endOffset: Int): SourceRangeInfo = shouldNotBeCalled()
|
||||
override fun getLineNumber(offset: Int): Int = shouldNotBeCalled()
|
||||
override fun getColumnNumber(offset: Int): Int = shouldNotBeCalled()
|
||||
override fun getLineAndColumnNumbers(offset: Int): LineAndColumn = shouldNotBeCalled()
|
||||
},
|
||||
symbol = IrFileSymbolImpl(),
|
||||
packageFqName = FqName("<error-package>")
|
||||
)
|
||||
|
||||
val IrErrorClassImpl: IrClass = IrFactoryImpl.createClass(
|
||||
startOffset = UNDEFINED_OFFSET,
|
||||
endOffset = UNDEFINED_OFFSET,
|
||||
@@ -34,32 +47,3 @@ val IrErrorClassImpl: IrClass = IrFactoryImpl.createClass(
|
||||
).apply {
|
||||
parent = ErrorFile
|
||||
}
|
||||
|
||||
private object ErrorFile : IrFile() {
|
||||
override val startOffset: Int
|
||||
get() = shouldNotBeCalled()
|
||||
override val endOffset: Int
|
||||
get() = shouldNotBeCalled()
|
||||
override var annotations: List<IrConstructorCall>
|
||||
get() = shouldNotBeCalled()
|
||||
set(_) {}
|
||||
|
||||
@UnsafeDuringIrConstructionAPI
|
||||
override val declarations: MutableList<IrDeclaration>
|
||||
get() = shouldNotBeCalled()
|
||||
override val symbol: IrFileSymbol
|
||||
get() = shouldNotBeCalled()
|
||||
override var module: IrModuleFragment
|
||||
get() = shouldNotBeCalled()
|
||||
set(_) = shouldNotBeCalled()
|
||||
override var fileEntry: IrFileEntry
|
||||
get() = shouldNotBeCalled()
|
||||
set(_) = shouldNotBeCalled()
|
||||
override var metadata: MetadataSource?
|
||||
get() = shouldNotBeCalled()
|
||||
set(_) {}
|
||||
|
||||
override var packageFqName: FqName
|
||||
get() = FqName.ROOT
|
||||
set(_) = shouldNotBeCalled()
|
||||
}
|
||||
Reference in New Issue
Block a user