[IR] Rename IrSymbolInternals to UnsafeDuringIrConstructionAPI
The new name more precisely describes the meaning of this opt-int
This commit is contained in:
committed by
Space Team
parent
38ebe60e9f
commit
fb8bf19091
@@ -62,7 +62,7 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||||
dependsOn(":dist")
|
dependsOn(":dist")
|
||||||
|
|||||||
+5
-5
@@ -71,7 +71,7 @@ import org.jetbrains.kotlin.ir.descriptors.IrBasedVariableDescriptor
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.util.DelicateSymbolTableApi
|
import org.jetbrains.kotlin.ir.util.DelicateSymbolTableApi
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
@@ -305,7 +305,7 @@ internal class KtFirCompilerFacility(
|
|||||||
irCodeFragmentFiles.forEach { it.acceptVoid(patchingVisitor) }
|
irCodeFragmentFiles.forEach { it.acceptVoid(patchingVisitor) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun computeAdditionalCodeFragmentMapping(descriptor: IrBasedDeclarationDescriptor<*>): CodeFragmentCapturedValue? {
|
private fun computeAdditionalCodeFragmentMapping(descriptor: IrBasedDeclarationDescriptor<*>): CodeFragmentCapturedValue? {
|
||||||
val owner = descriptor.owner
|
val owner = descriptor.owner
|
||||||
|
|
||||||
@@ -635,7 +635,7 @@ private class IrDeclarationPatchingVisitor(private val mapping: Map<FirDeclarati
|
|||||||
super.visitClassReference(expression)
|
super.visitClassReference(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private inline fun <reified T : IrSymbol> patchIfNeeded(irSymbol: T?, patcher: (T) -> Unit) {
|
private inline fun <reified T : IrSymbol> patchIfNeeded(irSymbol: T?, patcher: (T) -> Unit) {
|
||||||
if (irSymbol != null) {
|
if (irSymbol != null) {
|
||||||
val irDeclaration = irSymbol.owner as? IrMetadataSourceOwner ?: return
|
val irDeclaration = irSymbol.owner as? IrMetadataSourceOwner ?: return
|
||||||
@@ -701,7 +701,7 @@ private class DeclarationRegistrarVisitor(private val consumer: SymbolTable) : I
|
|||||||
super.visitEnumEntry(declaration)
|
super.visitEnumEntry(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private inline fun <reified S : IrSymbol, D : IrDeclaration> register(
|
private inline fun <reified S : IrSymbol, D : IrDeclaration> register(
|
||||||
declaration: D,
|
declaration: D,
|
||||||
registrar: (IdSignature, () -> S, (S) -> D) -> Unit,
|
registrar: (IdSignature, () -> S, (S) -> D) -> Unit,
|
||||||
@@ -726,4 +726,4 @@ private class SyntaxErrorReportingVisitor : KtTreeVisitorVoid() {
|
|||||||
|
|
||||||
super.visitErrorElement(element)
|
super.visitErrorElement(element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ dependencies {
|
|||||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.ir.declarations.nameWithPackage
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.ConstantValueKind
|
|||||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||||
|
|
||||||
// opt-in is safe, this code runs after fir2ir is over and all symbols are bound
|
// opt-in is safe, this code runs after fir2ir is over and all symbols are bound
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
class Fir2IrAnnotationsFromPluginRegistrar(private val components: Fir2IrComponents) : IrAnnotationsFromPluginRegistrar() {
|
class Fir2IrAnnotationsFromPluginRegistrar(private val components: Fir2IrComponents) : IrAnnotationsFromPluginRegistrar() {
|
||||||
private val generatedIrDeclarationsByFileByOffset = mutableMapOf<String, MutableMap<Pair<Int, Int>, MutableList<IrConstructorCall>>>()
|
private val generatedIrDeclarationsByFileByOffset = mutableMapOf<String, MutableMap<Pair<Int, Int>, MutableList<IrConstructorCall>>>()
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.defaultType
|
import org.jetbrains.kotlin.ir.types.defaultType
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.StandardClassIds
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
@@ -81,7 +81,7 @@ class Fir2IrBuiltIns(
|
|||||||
|
|
||||||
private fun IrClassSymbol.toConstructorCall(firSymbol: FirRegularClassSymbol? = null): IrConstructorCallImpl? {
|
private fun IrClassSymbol.toConstructorCall(firSymbol: FirRegularClassSymbol? = null): IrConstructorCallImpl? {
|
||||||
val constructorSymbol = if (firSymbol == null) {
|
val constructorSymbol = if (firSymbol == null) {
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
owner.declarations.firstIsInstance<IrConstructor>().symbol
|
owner.declarations.firstIsInstance<IrConstructor>().symbol
|
||||||
} else {
|
} else {
|
||||||
val firConstructorSymbol = firSymbol.unsubstitutedScope().getDeclaredConstructors().singleOrNull() ?: return null
|
val firConstructorSymbol = firSymbol.unsubstitutedScope().getDeclaredConstructors().singleOrNull() ?: return null
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.util.isSetter
|
import org.jetbrains.kotlin.ir.util.isSetter
|
||||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
@@ -86,7 +86,7 @@ class Fir2IrConversionScope(val configuration: Fir2IrConfiguration) {
|
|||||||
// It is safe to access an owner of property symbol here, because this function may be called
|
// It is safe to access an owner of property symbol here, because this function may be called
|
||||||
// only from property accessor of corresponding property
|
// only from property accessor of corresponding property
|
||||||
// We inside accessor -> accessor is built -> property is built
|
// We inside accessor -> accessor is built -> property is built
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val property = propertySymbol.owner
|
val property = propertySymbol.owner
|
||||||
for (parent in parentStack.asReversed()) {
|
for (parent in parentStack.asReversed()) {
|
||||||
when (parent) {
|
when (parent) {
|
||||||
@@ -101,7 +101,7 @@ class Fir2IrConversionScope(val configuration: Fir2IrConfiguration) {
|
|||||||
inline fun <reified D : IrDeclaration> findDeclarationInParentsStack(symbol: IrSymbol): @kotlin.internal.NoInfer D {
|
inline fun <reified D : IrDeclaration> findDeclarationInParentsStack(symbol: IrSymbol): @kotlin.internal.NoInfer D {
|
||||||
// This is an unsafe fast path for production
|
// This is an unsafe fast path for production
|
||||||
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) {
|
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) {
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
return symbol.owner as D
|
return symbol.owner as D
|
||||||
}
|
}
|
||||||
// With slow assertions the following code guarantees that taking owner from symbol is safe
|
// With slow assertions the following code guarantees that taking owner from symbol is safe
|
||||||
@@ -115,7 +115,7 @@ class Fir2IrConversionScope(val configuration: Fir2IrConfiguration) {
|
|||||||
* for which we have Fir2IrLazyClass in symbol
|
* for which we have Fir2IrLazyClass in symbol
|
||||||
*/
|
*/
|
||||||
if (configuration.allowNonCachedDeclarations) {
|
if (configuration.allowNonCachedDeclarations) {
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
return symbol.owner as D
|
return symbol.owner as D
|
||||||
}
|
}
|
||||||
error("Declaration with symbol $symbol is not found in parents stack")
|
error("Declaration with symbol $symbol is not found in parents stack")
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.ir.interpreter.IrInterpreterEnvironment
|
|||||||
import org.jetbrains.kotlin.ir.interpreter.checker.EvaluationMode
|
import org.jetbrains.kotlin.ir.interpreter.checker.EvaluationMode
|
||||||
import org.jetbrains.kotlin.ir.interpreter.transformer.transformConst
|
import org.jetbrains.kotlin.ir.interpreter.transformer.transformConst
|
||||||
import org.jetbrains.kotlin.ir.overrides.IrFakeOverrideBuilder
|
import org.jetbrains.kotlin.ir.overrides.IrFakeOverrideBuilder
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorPublicSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorPublicSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl
|
||||||
@@ -190,7 +190,7 @@ class Fir2IrConverter(
|
|||||||
*
|
*
|
||||||
* `irFile` is definitely not a lazy class
|
* `irFile` is definitely not a lazy class
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irFile.declarations.clear()
|
irFile.declarations.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ class Fir2IrConverter(
|
|||||||
*
|
*
|
||||||
* `irClass` is a source class and definitely is not a lazy class
|
* `irClass` is a source class and definitely is not a lazy class
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irClass.declarations.clear()
|
irClass.declarations.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ class Fir2IrConverter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irClass.declarations.addAll(classifierStorage.getFieldsWithContextReceiversForClass(irClass, klass))
|
irClass.declarations.addAll(classifierStorage.getFieldsWithContextReceiversForClass(irClass, klass))
|
||||||
|
|
||||||
val irConstructor = klass.primaryConstructorIfAny(session)?.let {
|
val irConstructor = klass.primaryConstructorIfAny(session)?.let {
|
||||||
@@ -354,7 +354,7 @@ class Fir2IrConverter(
|
|||||||
private fun bindFakeOverridesInFile(file: FirFile) {
|
private fun bindFakeOverridesInFile(file: FirFile) {
|
||||||
val irFile = declarationStorage.getIrFile(file)
|
val irFile = declarationStorage.getIrFile(file)
|
||||||
// `irFile` definitely is not a lazy class
|
// `irFile` definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
for (irDeclaration in irFile.declarations) {
|
for (irDeclaration in irFile.declarations) {
|
||||||
if (irDeclaration is IrClass) {
|
if (irDeclaration is IrClass) {
|
||||||
bindFakeOverridesInClass(irDeclaration)
|
bindFakeOverridesInClass(irDeclaration)
|
||||||
@@ -363,7 +363,7 @@ class Fir2IrConverter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
fun bindFakeOverridesInClass(klass: IrClass) {
|
fun bindFakeOverridesInClass(klass: IrClass) {
|
||||||
require(klass !is Fir2IrLazyClass)
|
require(klass !is Fir2IrLazyClass)
|
||||||
fakeOverrideGenerator.bindOverriddenSymbols(klass.declarations)
|
fakeOverrideGenerator.bindOverriddenSymbols(klass.declarations)
|
||||||
@@ -376,7 +376,7 @@ class Fir2IrConverter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun delegatedMembers(irClass: IrClass): List<FirDeclaration> {
|
private fun delegatedMembers(irClass: IrClass): List<FirDeclaration> {
|
||||||
return irClass.declarations.filter {
|
return irClass.declarations.filter {
|
||||||
it.origin == IrDeclarationOrigin.DELEGATED_MEMBER
|
it.origin == IrDeclarationOrigin.DELEGATED_MEMBER
|
||||||
@@ -439,7 +439,7 @@ class Fir2IrConverter(
|
|||||||
*
|
*
|
||||||
* `irClass` is a source class and definitely is not a lazy class
|
* `irClass` is a source class and definitely is not a lazy class
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irClass.declarations.clear()
|
irClass.declarations.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ class Fir2IrConverter(
|
|||||||
*
|
*
|
||||||
* `irClass` is a source class and definitely is not a lazy class
|
* `irClass` is a source class and definitely is not a lazy class
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
fun addDeclarationToParentIfNeeded(irDeclaration: IrDeclaration) {
|
fun addDeclarationToParentIfNeeded(irDeclaration: IrDeclaration) {
|
||||||
when (parent) {
|
when (parent) {
|
||||||
is IrFile -> parent.declarations += irDeclaration
|
is IrFile -> parent.declarations += irDeclaration
|
||||||
|
|||||||
+3
-3
@@ -257,7 +257,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
functionCache,
|
functionCache,
|
||||||
signatureCalculator
|
signatureCalculator
|
||||||
) { signature ->
|
) { signature ->
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
symbolTable.referenceSimpleFunctionIfAny(signature)?.owner
|
symbolTable.referenceSimpleFunctionIfAny(signature)?.owner
|
||||||
}
|
}
|
||||||
return cachedIrCallable
|
return cachedIrCallable
|
||||||
@@ -362,7 +362,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
): IrConstructor? {
|
): IrConstructor? {
|
||||||
return constructorCache[constructor] ?: signatureCalculator()?.let { signature ->
|
return constructorCache[constructor] ?: signatureCalculator()?.let { signature ->
|
||||||
symbolTable.referenceConstructorIfAny(signature)?.let { irConstructorSymbol ->
|
symbolTable.referenceConstructorIfAny(signature)?.let { irConstructorSymbol ->
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val irConstructor = irConstructorSymbol.owner
|
val irConstructor = irConstructorSymbol.owner
|
||||||
constructorCache[constructor] = irConstructor
|
constructorCache[constructor] = irConstructor
|
||||||
irConstructor
|
irConstructor
|
||||||
@@ -576,7 +576,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
propertyCache,
|
propertyCache,
|
||||||
signatureCalculator
|
signatureCalculator
|
||||||
) { signature ->
|
) { signature ->
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
symbolTable.referencePropertyIfAny(signature)?.owner
|
symbolTable.referencePropertyIfAny(signature)?.owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.ir.IrBuiltIns
|
|||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.classId
|
import org.jetbrains.kotlin.ir.util.classId
|
||||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||||
@@ -363,7 +363,7 @@ class Fir2IrImplicitCastInserter(
|
|||||||
* bound at the time of body conversion, so it's safe to take the owner for them
|
* bound at the time of body conversion, so it's safe to take the owner for them
|
||||||
* If symbol is unbound then this annotation can not be neither @EnhancedNullability or @FlexibleNullability
|
* If symbol is unbound then this annotation can not be neither @EnhancedNullability or @FlexibleNullability
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val classId = constructorSymbol.owner.parentAsClass.classId
|
val classId = constructorSymbol.owner.parentAsClass.classId
|
||||||
classId == StandardClassIds.Annotations.EnhancedNullability ||
|
classId == StandardClassIds.Annotations.EnhancedNullability ||
|
||||||
classId == StandardClassIds.Annotations.FlexibleNullability
|
classId == StandardClassIds.Annotations.FlexibleNullability
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ import org.jetbrains.kotlin.ir.expressions.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorClassImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrErrorClassImpl
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||||
import org.jetbrains.kotlin.ir.util.coerceToUnit
|
|
||||||
import org.jetbrains.kotlin.ir.util.constructors
|
import org.jetbrains.kotlin.ir.util.constructors
|
||||||
import org.jetbrains.kotlin.ir.util.defaultConstructor
|
import org.jetbrains.kotlin.ir.util.defaultConstructor
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
@@ -150,7 +149,7 @@ class Fir2IrVisitor(
|
|||||||
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
||||||
|
|
||||||
// `correspondingClass` definitely is not a lazy class
|
// `correspondingClass` definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val constructor = correspondingClass.constructors.first()
|
val constructor = correspondingClass.constructors.first()
|
||||||
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
||||||
IrEnumConstructorCallImpl(
|
IrEnumConstructorCallImpl(
|
||||||
@@ -176,7 +175,7 @@ class Fir2IrVisitor(
|
|||||||
} else if (irParentEnumClass != null && initializer == null) {
|
} else if (irParentEnumClass != null && initializer == null) {
|
||||||
// a default-ish enum entry whose initializer would be a delegating constructor call
|
// a default-ish enum entry whose initializer would be a delegating constructor call
|
||||||
// `irParentEnumClass` definitely is not a lazy class
|
// `irParentEnumClass` definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val constructor = irParentEnumClass.defaultConstructor
|
val constructor = irParentEnumClass.defaultConstructor
|
||||||
?: error("Assuming that default constructor should exist and be converted at this point")
|
?: error("Assuming that default constructor should exist and be converted at this point")
|
||||||
enumEntry.convertWithOffsets { startOffset, endOffset ->
|
enumEntry.convertWithOffsets { startOffset, endOffset ->
|
||||||
@@ -332,7 +331,7 @@ class Fir2IrVisitor(
|
|||||||
override fun visitCodeFragment(codeFragment: FirCodeFragment, data: Any?): IrElement {
|
override fun visitCodeFragment(codeFragment: FirCodeFragment, data: Any?): IrElement {
|
||||||
val irClass = classifierStorage.getCachedIrCodeFragment(codeFragment)!!
|
val irClass = classifierStorage.getCachedIrCodeFragment(codeFragment)!!
|
||||||
// class for code fragment definitely is not a lazy class
|
// class for code fragment definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val irFunction = irClass.declarations.firstIsInstance<IrSimpleFunction>()
|
val irFunction = irClass.declarations.firstIsInstance<IrSimpleFunction>()
|
||||||
|
|
||||||
declarationStorage.enterScope(irFunction.symbol)
|
declarationStorage.enterScope(irFunction.symbol)
|
||||||
@@ -371,7 +370,7 @@ class Fir2IrVisitor(
|
|||||||
endOffset,
|
endOffset,
|
||||||
anonymousClassType,
|
anonymousClassType,
|
||||||
// a class for an anonymous object definitely is not a lazy class
|
// a class for an anonymous object definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irAnonymousObject.constructors.first().symbol,
|
irAnonymousObject.constructors.first().symbol,
|
||||||
irAnonymousObject.typeParameters.size,
|
irAnonymousObject.typeParameters.size,
|
||||||
origin = IrStatementOrigin.OBJECT_LITERAL
|
origin = IrStatementOrigin.OBJECT_LITERAL
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class IrBuiltInsOverFir(
|
|||||||
|
|
||||||
private val intrinsicConstAnnotation: IrConstructorCall by lazy {
|
private val intrinsicConstAnnotation: IrConstructorCall by lazy {
|
||||||
// class for intrinsicConst is created manually and it definitely is not a lazy class
|
// class for intrinsicConst is created manually and it definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val constructor = intrinsicConst.constructors.single()
|
val constructor = intrinsicConst.constructors.single()
|
||||||
IrConstructorCallImpl.Companion.fromSymbolOwner(intrinsicConst.defaultType, constructor)
|
IrConstructorCallImpl.Companion.fromSymbolOwner(intrinsicConst.defaultType, constructor)
|
||||||
}
|
}
|
||||||
@@ -314,7 +314,7 @@ class IrBuiltInsOverFir(
|
|||||||
isIntrinsicConst = isIntrinsicConst
|
isIntrinsicConst = isIntrinsicConst
|
||||||
).also {
|
).also {
|
||||||
// `kotlinInternalIrPackageFragment` definitely is not a lazy class
|
// `kotlinInternalIrPackageFragment` definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
declarations.add(it)
|
declarations.add(it)
|
||||||
}.symbol
|
}.symbol
|
||||||
}
|
}
|
||||||
@@ -379,7 +379,7 @@ class IrBuiltInsOverFir(
|
|||||||
origin = BUILTIN_OPERATOR
|
origin = BUILTIN_OPERATOR
|
||||||
).also {
|
).also {
|
||||||
// `kotlinInternalIrPackageFragment` definitely is not a lazy class
|
// `kotlinInternalIrPackageFragment` definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
declarations.add(it)
|
declarations.add(it)
|
||||||
}.symbol
|
}.symbol
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ class IrBuiltInsOverFir(
|
|||||||
}.toMap()
|
}.toMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override val unsignedArraysElementTypes: Map<IrClassSymbol, IrType?> by lazy {
|
override val unsignedArraysElementTypes: Map<IrClassSymbol, IrType?> by lazy {
|
||||||
unsignedTypesToUnsignedArrays.map { (k, v) -> v to loadClass(k.classId).owner.defaultType }.toMap()
|
unsignedTypesToUnsignedArrays.map { (k, v) -> v to loadClass(k.classId).owner.defaultType }.toMap()
|
||||||
}
|
}
|
||||||
@@ -426,19 +426,19 @@ class IrBuiltInsOverFir(
|
|||||||
|
|
||||||
override val enumClass: IrClassSymbol by lazy { loadClass(StandardClassIds.Enum) }
|
override val enumClass: IrClassSymbol by lazy { loadClass(StandardClassIds.Enum) }
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override val intPlusSymbol: IrSimpleFunctionSymbol
|
override val intPlusSymbol: IrSimpleFunctionSymbol
|
||||||
get() = intClass.functions.single {
|
get() = intClass.functions.single {
|
||||||
it.owner.name == OperatorNameConventions.PLUS && it.owner.valueParameters[0].type == intType
|
it.owner.name == OperatorNameConventions.PLUS && it.owner.valueParameters[0].type == intType
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override val intTimesSymbol: IrSimpleFunctionSymbol
|
override val intTimesSymbol: IrSimpleFunctionSymbol
|
||||||
get() = intClass.functions.single {
|
get() = intClass.functions.single {
|
||||||
it.owner.name == OperatorNameConventions.TIMES && it.owner.valueParameters[0].type == intType
|
it.owner.name == OperatorNameConventions.TIMES && it.owner.valueParameters[0].type == intType
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override val intXorSymbol: IrSimpleFunctionSymbol
|
override val intXorSymbol: IrSimpleFunctionSymbol
|
||||||
get() = intClass.functions.single {
|
get() = intClass.functions.single {
|
||||||
it.owner.name == OperatorNameConventions.XOR && it.owner.valueParameters[0].type == intType
|
it.owner.name == OperatorNameConventions.XOR && it.owner.valueParameters[0].type == intType
|
||||||
@@ -524,22 +524,22 @@ class IrBuiltInsOverFir(
|
|||||||
private val suspendFunctionNMap = mutableMapOf<Int, IrClass>()
|
private val suspendFunctionNMap = mutableMapOf<Int, IrClass>()
|
||||||
private val kSuspendFunctionNMap = mutableMapOf<Int, IrClass>()
|
private val kSuspendFunctionNMap = mutableMapOf<Int, IrClass>()
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun functionN(arity: Int): IrClass = functionNMap.getOrPut(arity) {
|
override fun functionN(arity: Int): IrClass = functionNMap.getOrPut(arity) {
|
||||||
loadClass(StandardClassIds.FunctionN(arity)).owner
|
loadClass(StandardClassIds.FunctionN(arity)).owner
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun kFunctionN(arity: Int): IrClass = kFunctionNMap.getOrPut(arity) {
|
override fun kFunctionN(arity: Int): IrClass = kFunctionNMap.getOrPut(arity) {
|
||||||
loadClass(StandardClassIds.KFunctionN(arity)).owner
|
loadClass(StandardClassIds.KFunctionN(arity)).owner
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun suspendFunctionN(arity: Int): IrClass = suspendFunctionNMap.getOrPut(arity) {
|
override fun suspendFunctionN(arity: Int): IrClass = suspendFunctionNMap.getOrPut(arity) {
|
||||||
loadClass(StandardClassIds.SuspendFunctionN(arity)).owner
|
loadClass(StandardClassIds.SuspendFunctionN(arity)).owner
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun kSuspendFunctionN(arity: Int): IrClass = kSuspendFunctionNMap.getOrPut(arity) {
|
override fun kSuspendFunctionN(arity: Int): IrClass = kSuspendFunctionNMap.getOrPut(arity) {
|
||||||
loadClass(StandardClassIds.KSuspendFunctionN(arity)).owner
|
loadClass(StandardClassIds.KSuspendFunctionN(arity)).owner
|
||||||
}
|
}
|
||||||
@@ -563,13 +563,13 @@ class IrBuiltInsOverFir(
|
|||||||
return loadClassSafe(ClassId(packageName, identifier))
|
return loadClassSafe(ClassId(packageName, identifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun findBuiltInClassMemberFunctions(builtInClass: IrClassSymbol, name: Name): Iterable<IrSimpleFunctionSymbol> {
|
override fun findBuiltInClassMemberFunctions(builtInClass: IrClassSymbol, name: Name): Iterable<IrSimpleFunctionSymbol> {
|
||||||
return builtInClass.functions.filter { it.owner.name == name }.asIterable()
|
return builtInClass.functions.filter { it.owner.name == name }.asIterable()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function should not be called from fir2ir code
|
// This function should not be called from fir2ir code
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override fun getBinaryOperator(name: Name, lhsType: IrType, rhsType: IrType): IrSimpleFunctionSymbol {
|
override fun getBinaryOperator(name: Name, lhsType: IrType, rhsType: IrType): IrSimpleFunctionSymbol {
|
||||||
val definingClass = lhsType.getMaybeBuiltinClass() ?: error("Defining class not found: $lhsType")
|
val definingClass = lhsType.getMaybeBuiltinClass() ?: error("Defining class not found: $lhsType")
|
||||||
return definingClass.functions.single { function ->
|
return definingClass.functions.single { function ->
|
||||||
@@ -578,7 +578,7 @@ class IrBuiltInsOverFir(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function should not be called from fir2ir code
|
// This function should not be called from fir2ir code
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override fun getUnaryOperator(name: Name, receiverType: IrType): IrSimpleFunctionSymbol {
|
override fun getUnaryOperator(name: Name, receiverType: IrType): IrSimpleFunctionSymbol {
|
||||||
val definingClass = receiverType.getMaybeBuiltinClass() ?: error("Defining class not found: $receiverType")
|
val definingClass = receiverType.getMaybeBuiltinClass() ?: error("Defining class not found: $receiverType")
|
||||||
return definingClass.functions.single { function ->
|
return definingClass.functions.single { function ->
|
||||||
@@ -601,7 +601,7 @@ class IrBuiltInsOverFir(
|
|||||||
return components.classifierStorage.getOrCreateIrClass(firClassSymbol).symbol
|
return components.classifierStorage.getOrCreateIrClass(firClassSymbol).symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun IrType.getMaybeBuiltinClass(): IrClass? {
|
private fun IrType.getMaybeBuiltinClass(): IrClass? {
|
||||||
val lhsClassFqName = classFqName!!
|
val lhsClassFqName = classFqName!!
|
||||||
return baseIrTypes.find { it.classFqName == lhsClassFqName }?.getClass()
|
return baseIrTypes.find { it.classFqName == lhsClassFqName }?.getClass()
|
||||||
|
|||||||
+2
-2
@@ -164,7 +164,7 @@ class CallAndReferenceGenerator(
|
|||||||
?: run {
|
?: run {
|
||||||
// In case of [IrField] without the corresponding property, we've created it directly from [FirField].
|
// In case of [IrField] without the corresponding property, we've created it directly from [FirField].
|
||||||
// Since it's used as a field reference, we need a bogus property as a placeholder.
|
// Since it's used as a field reference, we need a bogus property as a placeholder.
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
declarationStorage.getOrCreateIrPropertyByPureField(fieldSymbol.fir, irFieldSymbol.owner.parent).symbol
|
declarationStorage.getOrCreateIrPropertyByPureField(fieldSymbol.fir, irFieldSymbol.owner.parent).symbol
|
||||||
}
|
}
|
||||||
return IrPropertyReferenceImpl(
|
return IrPropertyReferenceImpl(
|
||||||
@@ -725,7 +725,7 @@ class CallAndReferenceGenerator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun IrPropertySymbol.overriddenBackingFieldOrNull(): IrFieldSymbol? {
|
private fun IrPropertySymbol.overriddenBackingFieldOrNull(): IrFieldSymbol? {
|
||||||
return owner.overriddenSymbols.firstNotNullOfOrNull {
|
return owner.overriddenSymbols.firstNotNullOfOrNull {
|
||||||
val owner = it.owner
|
val owner = it.owner
|
||||||
|
|||||||
+5
-5
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.ir.builders.IrGeneratorContextBase
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
@@ -103,7 +103,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
override fun getProperty(irValueParameter: IrValueParameter?): IrProperty =
|
override fun getProperty(irValueParameter: IrValueParameter?): IrProperty =
|
||||||
irValueParameter?.let {
|
irValueParameter?.let {
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irClass.properties.single { irProperty ->
|
irClass.properties.single { irProperty ->
|
||||||
irProperty.name == irValueParameter.name && irProperty.backingField?.type == irValueParameter.type
|
irProperty.name == irValueParameter.name && irProperty.backingField?.type == irValueParameter.type
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
fun generateBodies() {
|
fun generateBodies() {
|
||||||
val propertyParametersCount = irClass.primaryConstructor?.explicitParameters?.size ?: 0
|
val propertyParametersCount = irClass.primaryConstructor?.explicitParameters?.size ?: 0
|
||||||
val properties = irClass.properties.filter { it.backingField != null }.take(propertyParametersCount).toList()
|
val properties = irClass.properties.filter { it.backingField != null }.take(propertyParametersCount).toList()
|
||||||
@@ -286,7 +286,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
irFunction.origin = origin
|
irFunction.origin = origin
|
||||||
val index = DataClassResolver.getComponentIndex(irFunction.name.asString())
|
val index = DataClassResolver.getComponentIndex(irFunction.name.asString())
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
val valueParameter = irClass.primaryConstructor!!.valueParameters[index - 1]
|
val valueParameter = irClass.primaryConstructor!!.valueParameters[index - 1]
|
||||||
val irProperty = irDataClassMembersGenerator.getProperty(valueParameter)
|
val irProperty = irDataClassMembersGenerator.getProperty(valueParameter)
|
||||||
irDataClassMembersGenerator.generateComponentFunction(irFunction, irProperty)
|
irDataClassMembersGenerator.generateComponentFunction(irFunction, irProperty)
|
||||||
@@ -295,7 +295,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
fun generateCopyBody(irFunction: IrFunction) {
|
fun generateCopyBody(irFunction: IrFunction) {
|
||||||
irFunction.origin = origin
|
irFunction.origin = origin
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
irDataClassMembersGenerator.generateCopyFunction(irFunction, irClass.primaryConstructor!!.symbol)
|
irDataClassMembersGenerator.generateCopyFunction(irFunction, irClass.primaryConstructor!!.symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
|||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
||||||
@@ -182,7 +182,7 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I
|
|||||||
return result?.unwrapSubstitutionOverrides()
|
return result?.unwrapSubstitutionOverrides()
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
fun bindDelegatedMembersOverriddenSymbols(irClass: IrClass) {
|
fun bindDelegatedMembersOverriddenSymbols(irClass: IrClass) {
|
||||||
val superClasses by lazy(LazyThreadSafetyMode.NONE) {
|
val superClasses by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
irClass.superTypes.mapNotNullTo(mutableSetOf()) { it.classifierOrNull?.owner as? IrClass }
|
irClass.superTypes.mapNotNullTo(mutableSetOf()) { it.classifierOrNull?.owner as? IrClass }
|
||||||
|
|||||||
+6
-6
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||||
@@ -418,7 +418,7 @@ class FakeOverrideGenerator(
|
|||||||
) { declarationStorage.getIrPropertySymbol(it) as IrPropertySymbol }
|
) { declarationStorage.getIrPropertySymbol(it) as IrPropertySymbol }
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun <I : IrDeclaration, S : IrSymbol, F : FirCallableSymbol<*>> getOverriddenSymbolsInSupertypes(
|
private fun <I : IrDeclaration, S : IrSymbol, F : FirCallableSymbol<*>> getOverriddenSymbolsInSupertypes(
|
||||||
declaration: I,
|
declaration: I,
|
||||||
baseSymbols: List<F>,
|
baseSymbols: List<F>,
|
||||||
@@ -432,7 +432,7 @@ class FakeOverrideGenerator(
|
|||||||
}.distinct()
|
}.distinct()
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun <F : FirCallableSymbol<*>, S : IrSymbol> getOverriddenSymbolsInSupertypes(
|
private fun <F : FirCallableSymbol<*>, S : IrSymbol> getOverriddenSymbolsInSupertypes(
|
||||||
overridden: F,
|
overridden: F,
|
||||||
superClasses: Set<IrClass>,
|
superClasses: Set<IrClass>,
|
||||||
@@ -497,7 +497,7 @@ class FakeOverrideGenerator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun IrProperty.setOverriddenSymbolsForProperty(
|
private fun IrProperty.setOverriddenSymbolsForProperty(
|
||||||
declarationStorage: Fir2IrDeclarationStorage,
|
declarationStorage: Fir2IrDeclarationStorage,
|
||||||
isVar: Boolean,
|
isVar: Boolean,
|
||||||
@@ -522,7 +522,7 @@ class FakeOverrideGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
context(Fir2IrComponents)
|
context(Fir2IrComponents)
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
internal fun FirProperty.generateOverriddenAccessorSymbols(containingClass: FirClass, isGetter: Boolean): List<IrSimpleFunctionSymbol> {
|
internal fun FirProperty.generateOverriddenAccessorSymbols(containingClass: FirClass, isGetter: Boolean): List<IrSimpleFunctionSymbol> {
|
||||||
val scope = containingClass.unsubstitutedScope()
|
val scope = containingClass.unsubstitutedScope()
|
||||||
scope.processPropertiesByName(name) {}
|
scope.processPropertiesByName(name) {}
|
||||||
@@ -582,7 +582,7 @@ internal fun FirSimpleFunction.generateOverriddenFunctionSymbols(containingClass
|
|||||||
}
|
}
|
||||||
|
|
||||||
context(Fir2IrComponents)
|
context(Fir2IrComponents)
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun FirClass.getSuperTypesAsIrClasses(): Set<IrClass> {
|
private fun FirClass.getSuperTypesAsIrClasses(): Set<IrClass> {
|
||||||
val irClass = declarationStorage.classifierStorage.getOrCreateIrClass(symbol)
|
val irClass = declarationStorage.classifierStorage.getOrCreateIrClass(symbol)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1118,7 +1118,7 @@ internal fun IrDeclaration.setParent(irParent: IrDeclarationParent?) {
|
|||||||
* Note that IrClass will be a parent if some declaration is declared inside anonymous initializer, because IrAnonymousInitializer
|
* Note that IrClass will be a parent if some declaration is declared inside anonymous initializer, because IrAnonymousInitializer
|
||||||
* is not a IrDeclarationParent
|
* is not a IrDeclarationParent
|
||||||
*/
|
*/
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
internal fun addDeclarationToParent(declaration: IrDeclaration, irParent: IrDeclarationParent?) {
|
internal fun addDeclarationToParent(declaration: IrDeclaration, irParent: IrDeclarationParent?) {
|
||||||
if (irParent == null) return
|
if (irParent == null) return
|
||||||
when (irParent) {
|
when (irParent) {
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ class Fir2IrClassifiersGenerator(val components: Fir2IrComponents) : Fir2IrCompo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `irClass` is a source class and definitely is not a lazy class
|
// `irClass` is a source class and definitely is not a lazy class
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
private fun IrClass.declareTypeParameters(klass: FirClass) {
|
private fun IrClass.declareTypeParameters(klass: FirClass) {
|
||||||
classifierStorage.preCacheTypeParameters(klass, symbol)
|
classifierStorage.preCacheTypeParameters(klass, symbol)
|
||||||
setTypeParameters(this, klass)
|
setTypeParameters(this, klass)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.backend.*
|
|||||||
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||||
import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull
|
|
||||||
import org.jetbrains.kotlin.fir.hasEnumEntries
|
import org.jetbrains.kotlin.fir.hasEnumEntries
|
||||||
import org.jetbrains.kotlin.fir.isNewPlaceForBodyGeneration
|
import org.jetbrains.kotlin.fir.isNewPlaceForBodyGeneration
|
||||||
import org.jetbrains.kotlin.fir.isSubstitutionOrIntersectionOverride
|
import org.jetbrains.kotlin.fir.isSubstitutionOrIntersectionOverride
|
||||||
@@ -24,7 +23,7 @@ import org.jetbrains.kotlin.ir.declarations.lazy.IrMaybeDeserializedClass
|
|||||||
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||||
@@ -32,7 +31,6 @@ import org.jetbrains.kotlin.ir.util.DeserializableClass
|
|||||||
import org.jetbrains.kotlin.ir.util.isEnumClass
|
import org.jetbrains.kotlin.ir.util.isEnumClass
|
||||||
import org.jetbrains.kotlin.ir.util.isObject
|
import org.jetbrains.kotlin.ir.util.isObject
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
|
||||||
|
|
||||||
class Fir2IrLazyClass(
|
class Fir2IrLazyClass(
|
||||||
components: Fir2IrComponents,
|
components: Fir2IrComponents,
|
||||||
@@ -155,7 +153,7 @@ class Fir2IrLazyClass(
|
|||||||
.also(converter::bindFakeOverridesOrPostpone)
|
.also(converter::bindFakeOverridesOrPostpone)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
||||||
val result = mutableListOf<IrDeclaration>()
|
val result = mutableListOf<IrDeclaration>()
|
||||||
// NB: it's necessary to take all callables from scope,
|
// NB: it's necessary to take all callables from scope,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.fir.lazy
|
package org.jetbrains.kotlin.fir.lazy
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.backend.*
|
import org.jetbrains.kotlin.fir.backend.*
|
||||||
import org.jetbrains.kotlin.fir.backend.generators.generateOverriddenAccessorSymbols
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
||||||
@@ -21,7 +20,7 @@ import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.isFacadeClass
|
import org.jetbrains.kotlin.ir.util.isFacadeClass
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -115,7 +114,7 @@ class Fir2IrLazyPropertyAccessor(
|
|||||||
override var overriddenSymbols: List<IrSimpleFunctionSymbol> by lazyVar(lock) {
|
override var overriddenSymbols: List<IrSimpleFunctionSymbol> by lazyVar(lock) {
|
||||||
if (firParentClass == null) return@lazyVar emptyList()
|
if (firParentClass == null) return@lazyVar emptyList()
|
||||||
// If property accessor is created then corresponding property is definitely created too
|
// If property accessor is created then corresponding property is definitely created too
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
correspondingPropertySymbol!!.owner.overriddenSymbols.mapNotNull {
|
correspondingPropertySymbol!!.owner.overriddenSymbols.mapNotNull {
|
||||||
when (isSetter) {
|
when (isSetter) {
|
||||||
false -> declarationStorage.findGetterOfProperty(it)
|
false -> declarationStorage.findGetterOfProperty(it)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.*
|
import org.jetbrains.kotlin.ir.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrBindableSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrBindableSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrDeclara
|
|||||||
|
|
||||||
private var _owner: B? = null
|
private var _owner: B? = null
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val owner: B
|
override val owner: B
|
||||||
get() = _owner ?: throw IllegalStateException("Symbol is unbound")
|
get() = _owner ?: throw IllegalStateException("Symbol is unbound")
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrDeclara
|
|||||||
override val isBound: Boolean
|
override val isBound: Boolean
|
||||||
get() = _owner != null
|
get() = _owner != null
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
override val descriptor: D
|
override val descriptor: D
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -47,7 +47,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrDeclara
|
|||||||
|
|
||||||
override var privateSignature: IdSignature? = null
|
override var privateSignature: IdSignature? = null
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
if (isBound) return owner.render()
|
if (isBound) return owner.render()
|
||||||
return "Unbound public symbol for $signature"
|
return "Unbound public symbol for $signature"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dependencies {
|
|||||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ dependencies {
|
|||||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ dependencies {
|
|||||||
compileOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
|
compileOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ dependencies {
|
|||||||
api(project(":compiler:ir.tree"))
|
api(project(":compiler:ir.tree"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ sourceSets {
|
|||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
optInToObsoleteDescriptorBasedAPI()
|
optInToObsoleteDescriptorBasedAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A non-leaf IR tree element.
|
* A non-leaf IR tree element.
|
||||||
@@ -22,6 +22,6 @@ interface IrDeclarationContainer : IrDeclarationParent {
|
|||||||
* before IR for all sources is built (because fake-overrides of lazy classes may depend on
|
* before IR for all sources is built (because fake-overrides of lazy classes may depend on
|
||||||
* declaration of source classes, e.g. for java source classes)
|
* declaration of source classes, e.g. for java source classes)
|
||||||
*/
|
*/
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val declarations: MutableList<IrDeclaration>
|
val declarations: MutableList<IrDeclaration>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -48,7 +48,7 @@ open class IrClassImpl(
|
|||||||
|
|
||||||
override var thisReceiver: IrValueParameter? = null
|
override var thisReceiver: IrValueParameter? = null
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||||
|
|
||||||
override var typeParameters: List<IrTypeParameter> = emptyList()
|
override var typeParameters: List<IrTypeParameter> = emptyList()
|
||||||
|
|||||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrExternalPackageFragment
|
import org.jetbrains.kotlin.ir.declarations.IrExternalPackageFragment
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
@@ -52,7 +52,7 @@ class IrExternalPackageFragmentImpl(
|
|||||||
override val moduleDescriptor: ModuleDescriptor
|
override val moduleDescriptor: ModuleDescriptor
|
||||||
get() = packageFragmentDescriptor.containingDeclaration
|
get() = packageFragmentDescriptor.containingDeclaration
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
|||||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ class IrFileImpl(
|
|||||||
packageFragmentDescriptor.containingDeclaration
|
packageFragmentDescriptor.containingDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||||
|
|
||||||
override var annotations: List<IrConstructorCall> = emptyList()
|
override var annotations: List<IrConstructorCall> = emptyList()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
@@ -56,7 +56,7 @@ class IrLazyClass(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration> by lazyVar(stubGenerator.lock) {
|
override val declarations: MutableList<IrDeclaration> by lazyVar(stubGenerator.lock) {
|
||||||
ArrayList<IrDeclaration>().also {
|
ArrayList<IrDeclaration>().also {
|
||||||
typeTranslator.buildWithScope(this) {
|
typeTranslator.buildWithScope(this) {
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.allTypeParameters
|
import org.jetbrains.kotlin.ir.util.allTypeParameters
|
||||||
import org.jetbrains.kotlin.ir.util.initializeParameterArguments
|
import org.jetbrains.kotlin.ir.util.initializeParameterArguments
|
||||||
@@ -55,7 +55,7 @@ class IrDelegatingConstructorCallImpl(
|
|||||||
valueArgumentsCount: Int = symbol.descriptor.valueParameters.size + symbol.descriptor.contextReceiverParameters.size
|
valueArgumentsCount: Int = symbol.descriptor.valueParameters.size + symbol.descriptor.contextReceiverParameters.size
|
||||||
) = IrDelegatingConstructorCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount)
|
) = IrDelegatingConstructorCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount)
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun fromSymbolOwner(
|
fun fromSymbolOwner(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
|||||||
import org.jetbrains.kotlin.types.model.TypeParameterMarker
|
import org.jetbrains.kotlin.types.model.TypeParameterMarker
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of [IrSymbol.owner] can be unsafe in some context (like in fir2ir), where not all symbols can be bound),
|
* Usage of marked API can be unsafe at the stage when IR for the whole module is not built yet (specifically in fir2ir)
|
||||||
* so it should be used with care
|
|
||||||
*/
|
*/
|
||||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||||
annotation class IrSymbolInternals
|
annotation class UnsafeDuringIrConstructionAPI
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special object that can be used to refer to [IrDeclaration]s and some other entities from IR nodes.
|
* A special object that can be used to refer to [IrDeclaration]s and some other entities from IR nodes.
|
||||||
@@ -66,7 +65,7 @@ interface IrSymbol : DeclarationSymbolMarker {
|
|||||||
* **A:** Because we most often need to access a symbol's owner in lowerings, which happen after linkage, at which point all symbols
|
* **A:** Because we most often need to access a symbol's owner in lowerings, which happen after linkage, at which point all symbols
|
||||||
* should be already bound. Declaring this property nullable would make working with it more difficult most of the time.
|
* should be already bound. Declaring this property nullable would make working with it more difficult most of the time.
|
||||||
*/
|
*/
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val owner: IrSymbolOwner
|
val owner: IrSymbolOwner
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +125,7 @@ val IrSymbol.isPublicApi: Boolean
|
|||||||
* Only leaf interfaces in the symbol hierarchy inherit from this interface.
|
* Only leaf interfaces in the symbol hierarchy inherit from this interface.
|
||||||
*/
|
*/
|
||||||
interface IrBindableSymbol<out Descriptor : DeclarationDescriptor, Owner : IrSymbolOwner> : IrSymbol {
|
interface IrBindableSymbol<out Descriptor : DeclarationDescriptor, Owner : IrSymbolOwner> : IrSymbol {
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val owner: Owner
|
override val owner: Owner
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
@@ -230,7 +229,7 @@ sealed interface IrValueSymbol : IrSymbol {
|
|||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
override val descriptor: ValueDescriptor
|
override val descriptor: ValueDescriptor
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val owner: IrValueDeclaration
|
override val owner: IrValueDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +252,7 @@ sealed interface IrReturnTargetSymbol : IrSymbol {
|
|||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
override val descriptor: FunctionDescriptor
|
override val descriptor: FunctionDescriptor
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val owner: IrReturnTarget
|
override val owner: IrReturnTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +262,7 @@ sealed interface IrReturnTargetSymbol : IrSymbol {
|
|||||||
* @see IrFunctionReference
|
* @see IrFunctionReference
|
||||||
*/
|
*/
|
||||||
sealed interface IrFunctionSymbol : IrReturnTargetSymbol, FunctionSymbolMarker {
|
sealed interface IrFunctionSymbol : IrReturnTargetSymbol, FunctionSymbolMarker {
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val owner: IrFunction
|
override val owner: IrFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -33,7 +33,7 @@ object IrErrorClassImpl : IrClassImpl(
|
|||||||
get() = shouldNotBeCalled()
|
get() = shouldNotBeCalled()
|
||||||
set(_) {}
|
set(_) {}
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
override val declarations: MutableList<IrDeclaration>
|
override val declarations: MutableList<IrDeclaration>
|
||||||
get() = shouldNotBeCalled()
|
get() = shouldNotBeCalled()
|
||||||
override val symbol: IrFileSymbol
|
override val symbol: IrFileSymbol
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ val IrDeclaration.fileEntry: IrFileEntry
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClass.companionObject(): IrClass? =
|
fun IrClass.companionObject(): IrClass? =
|
||||||
this.declarations.singleOrNull { it is IrClass && it.isCompanion } as IrClass?
|
this.declarations.singleOrNull { it is IrClass && it.isCompanion } as IrClass?
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ class NaiveSourceBasedFileEntryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
||||||
val properties = declarations.filterIsInstanceAnd<IrProperty> { it.name.asString() == name }
|
val properties = declarations.filterIsInstanceAnd<IrProperty> { it.name.asString() == name }
|
||||||
if (properties.size > 1) {
|
if (properties.size > 1) {
|
||||||
@@ -301,24 +301,24 @@ fun IrClass.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
|
|||||||
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
getPropertyDeclaration(name)?.getter?.symbol
|
getPropertyDeclaration(name)?.getter?.symbol
|
||||||
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
getPropertyDeclaration(name)?.setter?.symbol
|
getPropertyDeclaration(name)?.setter?.symbol
|
||||||
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClassSymbol.getSimpleFunction(name: String): IrSimpleFunctionSymbol? = owner.getSimpleFunction(name)
|
fun IrClassSymbol.getSimpleFunction(name: String): IrSimpleFunctionSymbol? = owner.getSimpleFunction(name)
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClassSymbol.getPropertyGetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertyGetter(name)
|
fun IrClassSymbol.getPropertyGetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertyGetter(name)
|
||||||
|
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrClassSymbol.getPropertySetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertySetter(name)
|
fun IrClassSymbol.getPropertySetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertySetter(name)
|
||||||
|
|
||||||
fun filterOutAnnotations(fqName: FqName, annotations: List<IrConstructorCall>): List<IrConstructorCall> {
|
fun filterOutAnnotations(fqName: FqName, annotations: List<IrConstructorCall>): List<IrConstructorCall> {
|
||||||
|
|||||||
@@ -222,12 +222,12 @@ val IrProperty.isSimpleProperty: Boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.functions: Sequence<IrSimpleFunction>
|
val IrClass.functions: Sequence<IrSimpleFunction>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrSimpleFunction>()
|
get() = declarations.asSequence().filterIsInstance<IrSimpleFunction>()
|
||||||
|
|
||||||
// This declaration accesses IrBasedSymbol.owner, which is marked with this opt-in
|
// This declaration accesses IrBasedSymbol.owner, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.superClass: IrClass?
|
val IrClass.superClass: IrClass?
|
||||||
get() = superTypes
|
get() = superTypes
|
||||||
.firstOrNull { !it.isInterface() && !it.isAny() }
|
.firstOrNull { !it.isInterface() && !it.isAny() }
|
||||||
@@ -235,47 +235,47 @@ val IrClass.superClass: IrClass?
|
|||||||
?.owner
|
?.owner
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClassSymbol.functions: Sequence<IrSimpleFunctionSymbol>
|
val IrClassSymbol.functions: Sequence<IrSimpleFunctionSymbol>
|
||||||
get() = owner.functions.map { it.symbol }
|
get() = owner.functions.map { it.symbol }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.constructors: Sequence<IrConstructor>
|
val IrClass.constructors: Sequence<IrConstructor>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrConstructor>()
|
get() = declarations.asSequence().filterIsInstance<IrConstructor>()
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.defaultConstructor: IrConstructor?
|
val IrClass.defaultConstructor: IrConstructor?
|
||||||
get() = constructors.firstOrNull { ctor -> ctor.valueParameters.all { it.defaultValue != null } }
|
get() = constructors.firstOrNull { ctor -> ctor.valueParameters.all { it.defaultValue != null } }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClassSymbol.constructors: Sequence<IrConstructorSymbol>
|
val IrClassSymbol.constructors: Sequence<IrConstructorSymbol>
|
||||||
get() = owner.constructors.map { it.symbol }
|
get() = owner.constructors.map { it.symbol }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.fields: Sequence<IrField>
|
val IrClass.fields: Sequence<IrField>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrField>()
|
get() = declarations.asSequence().filterIsInstance<IrField>()
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClassSymbol.fields: Sequence<IrFieldSymbol>
|
val IrClassSymbol.fields: Sequence<IrFieldSymbol>
|
||||||
get() = owner.fields.map { it.symbol }
|
get() = owner.fields.map { it.symbol }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.primaryConstructor: IrConstructor?
|
val IrClass.primaryConstructor: IrConstructor?
|
||||||
get() = this.declarations.singleOrNull { it is IrConstructor && it.isPrimary } as IrConstructor?
|
get() = this.declarations.singleOrNull { it is IrConstructor && it.isPrimary } as IrConstructor?
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrClass.invokeFun: IrSimpleFunction?
|
val IrClass.invokeFun: IrSimpleFunction?
|
||||||
get() = declarations.filterIsInstance<IrSimpleFunction>().singleOrNull { it.name.asString() == "invoke" }
|
get() = declarations.filterIsInstance<IrSimpleFunction>().singleOrNull { it.name.asString() == "invoke" }
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
val IrDeclarationContainer.properties: Sequence<IrProperty>
|
val IrDeclarationContainer.properties: Sequence<IrProperty>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrProperty>()
|
get() = declarations.asSequence().filterIsInstance<IrProperty>()
|
||||||
|
|
||||||
@@ -466,7 +466,7 @@ fun IrFunction.isExternalOrInheritedFromExternal(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
inline fun <reified T : IrDeclaration> IrDeclarationContainer.findDeclaration(predicate: (T) -> Boolean): T? =
|
inline fun <reified T : IrDeclaration> IrDeclarationContainer.findDeclaration(predicate: (T) -> Boolean): T? =
|
||||||
declarations.find { it is T && predicate(it) } as? T
|
declarations.find { it is T && predicate(it) } as? T
|
||||||
|
|
||||||
@@ -1190,7 +1190,7 @@ fun IrFunction.isMethodOfAny(): Boolean =
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
@IrSymbolInternals
|
@UnsafeDuringIrConstructionAPI
|
||||||
fun IrDeclarationContainer.simpleFunctions() = declarations.flatMap {
|
fun IrDeclarationContainer.simpleFunctions() = declarations.flatMap {
|
||||||
when (it) {
|
when (it) {
|
||||||
is IrSimpleFunction -> listOf(it)
|
is IrSimpleFunction -> listOf(it)
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ object IrTree : AbstractTreeBuilder() {
|
|||||||
declaration of source classes, e.g. for java source classes)
|
declaration of source classes, e.g. for java source classes)
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
generationCallback = {
|
generationCallback = {
|
||||||
addAnnotation(ClassName("org.jetbrains.kotlin.ir.symbols", "IrSymbolInternals"))
|
addAnnotation(ClassName("org.jetbrains.kotlin.ir.symbols", "UnsafeDuringIrConstructionAPI"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
optInToObsoleteDescriptorBasedAPI()
|
optInToObsoleteDescriptorBasedAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dependencies {
|
|||||||
api(project(":compiler:frontend.java"))
|
api(project(":compiler:frontend.java"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { none() }
|
"main" { none() }
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { }
|
"main" { }
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ dependencies {
|
|||||||
testApi(commonDependency("org.jetbrains.intellij.deps:jdom"))
|
testApi(commonDependency("org.jetbrains.intellij.deps:jdom"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { none() }
|
"main" { none() }
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ compileCompilerKotlin {
|
|||||||
'-Xskip-prerelease-check']
|
'-Xskip-prerelease-check']
|
||||||
}
|
}
|
||||||
|
|
||||||
TasksKt.optInToIrSymbolInternals(project)
|
TasksKt.optInToUnsafeDuringIrConstructionAPI(project)
|
||||||
|
|
||||||
compileCli_bcKotlin {
|
compileCli_bcKotlin {
|
||||||
kotlinOptions.freeCompilerArgs += ['-Xskip-prerelease-check']
|
kotlinOptions.freeCompilerArgs += ['-Xskip-prerelease-check']
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
val generationRoot = projectDir.resolve("tests-gen")
|
val generationRoot = projectDir.resolve("tests-gen")
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
|
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
|
|||||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass
|
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(UnsafeDuringIrConstructionAPI::class)
|
||||||
class SourceElementChecker(val context: IrPluginContext) : IrElementVisitorVoid {
|
class SourceElementChecker(val context: IrPluginContext) : IrElementVisitorVoid {
|
||||||
override fun visitElement(element: IrElement) {
|
override fun visitElement(element: IrElement) {
|
||||||
element.acceptChildrenVoid(this)
|
element.acceptChildrenVoid(this)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ dependencies {
|
|||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ dependencies {
|
|||||||
implementation(kotlinStdlib())
|
implementation(kotlinStdlib())
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optInToExperimentalCompilerApi()
|
optInToExperimentalCompilerApi()
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { none() }
|
"main" { none() }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||||
}
|
}
|
||||||
|
|
||||||
optInToIrSymbolInternals()
|
optInToUnsafeDuringIrConstructionAPI()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
|
|||||||
@@ -411,8 +411,8 @@ fun Project.optInToExperimentalCompilerApi() {
|
|||||||
optInTo("org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi")
|
optInTo("org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.optInToIrSymbolInternals() {
|
fun Project.optInToUnsafeDuringIrConstructionAPI() {
|
||||||
optInTo("org.jetbrains.kotlin.ir.symbols.IrSymbolInternals")
|
optInTo("org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.optInToObsoleteDescriptorBasedAPI() {
|
fun Project.optInToObsoleteDescriptorBasedAPI() {
|
||||||
|
|||||||
Reference in New Issue
Block a user