Fir2Ir: create file level signatures where appropriate
This is godugly code, where a flag for file level signatures is passsed around. An alternative would be not to create file level signatures for toplevel private clases, since those still need unique names, at least on JVM. But that would break binary compatibility. Signatures are due for overhaul anyway. Hopefully this code can be reverted at that point.
This commit is contained in:
committed by
Alexander Udalov
parent
9d4ab09b41
commit
39bba7973c
@@ -481,10 +481,11 @@ class Fir2IrClassifierStorage(
|
|||||||
fun createIrEnumEntry(
|
fun createIrEnumEntry(
|
||||||
enumEntry: FirEnumEntry,
|
enumEntry: FirEnumEntry,
|
||||||
irParent: IrClass?,
|
irParent: IrClass?,
|
||||||
predefinedOrigin: IrDeclarationOrigin? = null
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrEnumEntry {
|
): IrEnumEntry {
|
||||||
return enumEntry.convertWithOffsets { startOffset, endOffset ->
|
return enumEntry.convertWithOffsets { startOffset, endOffset ->
|
||||||
val signature = signatureComposer.composeSignature(enumEntry)
|
val signature = signatureComposer.composeSignature(enumEntry, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
val result = declareIrEnumEntry(signature) { symbol ->
|
val result = declareIrEnumEntry(signature) { symbol ->
|
||||||
val origin = enumEntry.computeIrOrigin(predefinedOrigin)
|
val origin = enumEntry.computeIrOrigin(predefinedOrigin)
|
||||||
irFactory.createEnumEntry(
|
irFactory.createEnumEntry(
|
||||||
@@ -522,13 +523,13 @@ class Fir2IrClassifierStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIrClassSymbol(firClassSymbol: FirClassSymbol<*>): IrClassSymbol {
|
fun getIrClassSymbol(firClassSymbol: FirClassSymbol<*>, forceTopLevelPrivate: Boolean = false): IrClassSymbol {
|
||||||
val firClass = firClassSymbol.fir
|
val firClass = firClassSymbol.fir
|
||||||
getCachedIrClass(firClass)?.let { return it.symbol }
|
getCachedIrClass(firClass)?.let { return it.symbol }
|
||||||
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.visibility == Visibilities.Local) {
|
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.visibility == Visibilities.Local) {
|
||||||
return createLocalIrClassOnTheFly(firClass).symbol
|
return createLocalIrClassOnTheFly(firClass).symbol
|
||||||
}
|
}
|
||||||
val signature = signatureComposer.composeSignature(firClass)!!
|
val signature = signatureComposer.composeSignature(firClass, forceTopLevelPrivate = forceTopLevelPrivate)!!
|
||||||
val symbol = symbolTable.referenceClass(signature)
|
val symbol = symbolTable.referenceClass(signature)
|
||||||
if (symbol.isBound) {
|
if (symbol.isBound) {
|
||||||
val irClass = symbol.owner
|
val irClass = symbol.owner
|
||||||
|
|||||||
+47
-20
@@ -477,9 +477,16 @@ class Fir2IrDeclarationStorage(
|
|||||||
function: FirSimpleFunction,
|
function: FirSimpleFunction,
|
||||||
irParent: IrDeclarationParent?,
|
irParent: IrDeclarationParent?,
|
||||||
isLocal: Boolean = false,
|
isLocal: Boolean = false,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrSimpleFunction {
|
): IrSimpleFunction {
|
||||||
getCachedIrFunction(function)?.let { return it }
|
getCachedIrFunction(function)?.let { return it }
|
||||||
return createIrFunction(function, irParent, containingClass = function.containingClass(), isLocal = isLocal)
|
return createIrFunction(
|
||||||
|
function,
|
||||||
|
irParent,
|
||||||
|
containingClass = function.containingClass(),
|
||||||
|
isLocal = isLocal,
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createIrFunction(
|
fun createIrFunction(
|
||||||
@@ -489,6 +496,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
predefinedOrigin: IrDeclarationOrigin? = null,
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
isLocal: Boolean = false,
|
isLocal: Boolean = false,
|
||||||
containingClass: ConeClassLikeLookupTag? = null,
|
containingClass: ConeClassLikeLookupTag? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrSimpleFunction = convertCatching(function) {
|
): IrSimpleFunction = convertCatching(function) {
|
||||||
val simpleFunction = function as? FirSimpleFunction
|
val simpleFunction = function as? FirSimpleFunction
|
||||||
val isLambda = function.source?.elementType.let { it == KtNodeTypes.FUNCTION_LITERAL || it == KtNodeTypes.LAMBDA_EXPRESSION }
|
val isLambda = function.source?.elementType.let { it == KtNodeTypes.FUNCTION_LITERAL || it == KtNodeTypes.LAMBDA_EXPRESSION }
|
||||||
@@ -504,7 +512,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
function.origin == FirDeclarationOrigin.Enhancement -> IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
function.origin == FirDeclarationOrigin.Enhancement -> IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
||||||
else -> function.computeIrOrigin(predefinedOrigin)
|
else -> function.computeIrOrigin(predefinedOrigin)
|
||||||
}
|
}
|
||||||
val signature = if (isLocal) null else signatureComposer.composeSignature(function, containingClass)
|
val signature = if (isLocal) null else signatureComposer.composeSignature(function, containingClass, forceTopLevelPrivate)
|
||||||
if (irParent is Fir2IrLazyClass && signature != null) {
|
if (irParent is Fir2IrLazyClass && signature != null) {
|
||||||
// For private functions signature is null, fallback to non-lazy function
|
// For private functions signature is null, fallback to non-lazy function
|
||||||
return createIrLazyFunction(function as FirSimpleFunction, signature, irParent, updatedOrigin)
|
return createIrLazyFunction(function as FirSimpleFunction, signature, irParent, updatedOrigin)
|
||||||
@@ -598,11 +606,12 @@ class Fir2IrDeclarationStorage(
|
|||||||
constructor: FirConstructor,
|
constructor: FirConstructor,
|
||||||
irParent: IrClass,
|
irParent: IrClass,
|
||||||
predefinedOrigin: IrDeclarationOrigin? = null,
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
isLocal: Boolean = false
|
isLocal: Boolean = false,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrConstructor = convertCatching(constructor) {
|
): IrConstructor = convertCatching(constructor) {
|
||||||
val origin = constructor.computeIrOrigin(predefinedOrigin)
|
val origin = constructor.computeIrOrigin(predefinedOrigin)
|
||||||
val isPrimary = constructor.isPrimary
|
val isPrimary = constructor.isPrimary
|
||||||
val signature = if (isLocal) null else signatureComposer.composeSignature(constructor)
|
val signature = if (isLocal) null else signatureComposer.composeSignature(constructor, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
val created = constructor.convertWithOffsets { startOffset, endOffset ->
|
val created = constructor.convertWithOffsets { startOffset, endOffset ->
|
||||||
declareIrConstructor(signature) { symbol ->
|
declareIrConstructor(signature) { symbol ->
|
||||||
classifierStorage.preCacheTypeParameters(constructor, symbol)
|
classifierStorage.preCacheTypeParameters(constructor, symbol)
|
||||||
@@ -627,10 +636,11 @@ class Fir2IrDeclarationStorage(
|
|||||||
constructor: FirConstructor,
|
constructor: FirConstructor,
|
||||||
irParent: IrClass,
|
irParent: IrClass,
|
||||||
predefinedOrigin: IrDeclarationOrigin? = null,
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
isLocal: Boolean = false
|
isLocal: Boolean = false,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrConstructor {
|
): IrConstructor {
|
||||||
getCachedIrConstructor(constructor)?.let { return it }
|
getCachedIrConstructor(constructor)?.let { return it }
|
||||||
return createIrConstructor(constructor, irParent, predefinedOrigin, isLocal)
|
return createIrConstructor(constructor, irParent, predefinedOrigin, isLocal, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun declareIrAccessor(
|
private fun declareIrAccessor(
|
||||||
@@ -657,9 +667,10 @@ class Fir2IrDeclarationStorage(
|
|||||||
isLocal: Boolean = false,
|
isLocal: Boolean = false,
|
||||||
containingClass: ConeClassLikeLookupTag? = null,
|
containingClass: ConeClassLikeLookupTag? = null,
|
||||||
propertyAccessorForAnnotations: FirPropertyAccessor? = propertyAccessor,
|
propertyAccessorForAnnotations: FirPropertyAccessor? = propertyAccessor,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrSimpleFunction = convertCatching(propertyAccessor ?: property) {
|
): IrSimpleFunction = convertCatching(propertyAccessor ?: property) {
|
||||||
val prefix = if (isSetter) "set" else "get"
|
val prefix = if (isSetter) "set" else "get"
|
||||||
val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter, containingClass)
|
val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter, containingClass, forceTopLevelPrivate)
|
||||||
val containerSource = (correspondingProperty as? IrProperty)?.containerSource
|
val containerSource = (correspondingProperty as? IrProperty)?.containerSource
|
||||||
return declareIrAccessor(
|
return declareIrAccessor(
|
||||||
signature,
|
signature,
|
||||||
@@ -779,9 +790,10 @@ class Fir2IrDeclarationStorage(
|
|||||||
property: FirProperty,
|
property: FirProperty,
|
||||||
irParent: IrDeclarationParent?,
|
irParent: IrDeclarationParent?,
|
||||||
isLocal: Boolean = false,
|
isLocal: Boolean = false,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrProperty {
|
): IrProperty {
|
||||||
getCachedIrProperty(property)?.let { return it }
|
getCachedIrProperty(property)?.let { return it }
|
||||||
return createIrProperty(property, irParent, isLocal = isLocal)
|
return createIrProperty(property, irParent, isLocal = isLocal, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getOrCreateIrPropertyByPureField(
|
fun getOrCreateIrPropertyByPureField(
|
||||||
@@ -822,9 +834,10 @@ class Fir2IrDeclarationStorage(
|
|||||||
predefinedOrigin: IrDeclarationOrigin? = null,
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
isLocal: Boolean = false,
|
isLocal: Boolean = false,
|
||||||
containingClass: ConeClassLikeLookupTag? = (irParent as? IrClass)?.classId?.let { ConeClassLikeLookupTagImpl(it) },
|
containingClass: ConeClassLikeLookupTag? = (irParent as? IrClass)?.classId?.let { ConeClassLikeLookupTagImpl(it) },
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrProperty = convertCatching(property) {
|
): IrProperty = convertCatching(property) {
|
||||||
val origin = property.computeIrOrigin(predefinedOrigin)
|
val origin = property.computeIrOrigin(predefinedOrigin)
|
||||||
val signature = if (isLocal) null else signatureComposer.composeSignature(property, containingClass)
|
val signature = if (isLocal) null else signatureComposer.composeSignature(property, containingClass, forceTopLevelPrivate)
|
||||||
if (irParent is Fir2IrLazyClass && signature != null) {
|
if (irParent is Fir2IrLazyClass && signature != null) {
|
||||||
// For private functions signature is null, fallback to non-lazy property
|
// For private functions signature is null, fallback to non-lazy property
|
||||||
return createIrLazyProperty(property, signature, irParent, origin)
|
return createIrLazyProperty(property, signature, irParent, origin)
|
||||||
@@ -898,6 +911,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
},
|
},
|
||||||
startOffset, endOffset, isLocal, containingClass,
|
startOffset, endOffset, isLocal, containingClass,
|
||||||
property.unwrapFakeOverrides().getter,
|
property.unwrapFakeOverrides().getter,
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate,
|
||||||
)
|
)
|
||||||
if (property.isVar) {
|
if (property.isVar) {
|
||||||
this.setter = createIrPropertyAccessor(
|
this.setter = createIrPropertyAccessor(
|
||||||
@@ -909,6 +923,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
},
|
},
|
||||||
startOffset, endOffset, isLocal, containingClass,
|
startOffset, endOffset, isLocal, containingClass,
|
||||||
property.unwrapFakeOverrides().setter,
|
property.unwrapFakeOverrides().setter,
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
leaveScope(this)
|
leaveScope(this)
|
||||||
@@ -1199,13 +1214,15 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIrConstructorSymbol(firConstructorSymbol: FirConstructorSymbol): IrConstructorSymbol {
|
fun getIrConstructorSymbol(firConstructorSymbol: FirConstructorSymbol, forceTopLevelPrivate: Boolean = false): IrConstructorSymbol {
|
||||||
val fir = firConstructorSymbol.fir
|
val fir = firConstructorSymbol.fir
|
||||||
return getIrCallableSymbol(
|
return getIrCallableSymbol(
|
||||||
firConstructorSymbol,
|
firConstructorSymbol,
|
||||||
dispatchReceiverLookupTag = null,
|
dispatchReceiverLookupTag = null,
|
||||||
getCachedIrDeclaration = { constructor: FirConstructor, _, calculator -> getCachedIrConstructor(constructor, calculator) },
|
getCachedIrDeclaration = { constructor: FirConstructor, _, calculator -> getCachedIrConstructor(constructor, calculator) },
|
||||||
createIrDeclaration = { parent, origin -> createIrConstructor(fir, parent as IrClass, predefinedOrigin = origin) },
|
createIrDeclaration = { parent, origin ->
|
||||||
|
createIrConstructor(fir, parent as IrClass, predefinedOrigin = origin, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
|
},
|
||||||
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
||||||
val symbol = Fir2IrConstructorSymbol(signature)
|
val symbol = Fir2IrConstructorSymbol(signature)
|
||||||
val irConstructor = fir.convertWithOffsets { startOffset, endOffset ->
|
val irConstructor = fir.convertWithOffsets { startOffset, endOffset ->
|
||||||
@@ -1221,13 +1238,15 @@ class Fir2IrDeclarationStorage(
|
|||||||
// NB: this is needed to prevent recursions in case of self bounds
|
// NB: this is needed to prevent recursions in case of self bounds
|
||||||
(irConstructor as Fir2IrLazyConstructor).prepareTypeParameters()
|
(irConstructor as Fir2IrLazyConstructor).prepareTypeParameters()
|
||||||
irConstructor
|
irConstructor
|
||||||
}
|
},
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate
|
||||||
) as IrConstructorSymbol
|
) as IrConstructorSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIrFunctionSymbol(
|
fun getIrFunctionSymbol(
|
||||||
firFunctionSymbol: FirFunctionSymbol<*>,
|
firFunctionSymbol: FirFunctionSymbol<*>,
|
||||||
dispatchReceiverLookupTag: ConeClassLikeLookupTag? = null
|
dispatchReceiverLookupTag: ConeClassLikeLookupTag? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrFunctionSymbol {
|
): IrFunctionSymbol {
|
||||||
return when (val fir = firFunctionSymbol.fir) {
|
return when (val fir = firFunctionSymbol.fir) {
|
||||||
is FirAnonymousFunction -> {
|
is FirAnonymousFunction -> {
|
||||||
@@ -1247,11 +1266,12 @@ class Fir2IrDeclarationStorage(
|
|||||||
dispatchReceiverLookupTag,
|
dispatchReceiverLookupTag,
|
||||||
getCachedIrDeclaration = ::getCachedIrFunction,
|
getCachedIrDeclaration = ::getCachedIrFunction,
|
||||||
createIrDeclaration = { parent, origin ->
|
createIrDeclaration = { parent, origin ->
|
||||||
createIrFunction(fir, parent, predefinedOrigin = origin)
|
createIrFunction(fir, parent, predefinedOrigin = origin, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
},
|
},
|
||||||
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
||||||
createIrLazyFunction(fir, signature, lazyParent, declarationOrigin)
|
createIrLazyFunction(fir, signature, lazyParent, declarationOrigin)
|
||||||
}
|
},
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate
|
||||||
) as IrFunctionSymbol
|
) as IrFunctionSymbol
|
||||||
if (unmatchedReceiver && dispatchReceiverLookupTag is ConeClassLookupTagWithFixedSymbol) {
|
if (unmatchedReceiver && dispatchReceiverLookupTag is ConeClassLookupTagWithFixedSymbol) {
|
||||||
val originalFunction = originalSymbol.owner as IrSimpleFunction
|
val originalFunction = originalSymbol.owner as IrSimpleFunction
|
||||||
@@ -1261,7 +1281,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is FirConstructor -> {
|
is FirConstructor -> {
|
||||||
getIrConstructorSymbol(fir.symbol)
|
getIrConstructorSymbol(fir.symbol, forceTopLevelPrivate = forceTopLevelPrivate)
|
||||||
}
|
}
|
||||||
else -> error("Unknown kind of function: ${fir::class.java}: ${fir.render()}")
|
else -> error("Unknown kind of function: ${fir::class.java}: ${fir.render()}")
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1316,8 @@ class Fir2IrDeclarationStorage(
|
|||||||
|
|
||||||
fun getIrPropertySymbol(
|
fun getIrPropertySymbol(
|
||||||
firPropertySymbol: FirPropertySymbol,
|
firPropertySymbol: FirPropertySymbol,
|
||||||
dispatchReceiverLookupTag: ConeClassLikeLookupTag? = null
|
dispatchReceiverLookupTag: ConeClassLikeLookupTag? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrSymbol {
|
): IrSymbol {
|
||||||
val fir = firPropertySymbol.fir
|
val fir = firPropertySymbol.fir
|
||||||
if (fir.isLocal) {
|
if (fir.isLocal) {
|
||||||
@@ -1312,10 +1333,15 @@ class Fir2IrDeclarationStorage(
|
|||||||
firPropertySymbol,
|
firPropertySymbol,
|
||||||
dispatchReceiverLookupTag = this,
|
dispatchReceiverLookupTag = this,
|
||||||
getCachedIrDeclaration = ::getCachedIrProperty,
|
getCachedIrDeclaration = ::getCachedIrProperty,
|
||||||
createIrDeclaration = { parent, origin -> createIrProperty(fir, parent, predefinedOrigin = origin) },
|
createIrDeclaration = { parent, origin ->
|
||||||
|
createIrProperty(
|
||||||
|
fir, parent, predefinedOrigin = origin, forceTopLevelPrivate = forceTopLevelPrivate
|
||||||
|
)
|
||||||
|
},
|
||||||
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
||||||
createIrLazyProperty(fir, signature, lazyParent, declarationOrigin)
|
createIrLazyProperty(fir, signature, lazyParent, declarationOrigin)
|
||||||
}
|
},
|
||||||
|
forceTopLevelPrivate = forceTopLevelPrivate
|
||||||
)
|
)
|
||||||
|
|
||||||
val originalSymbol = dispatchReceiverLookupTag.getIrCallableSymbol()
|
val originalSymbol = dispatchReceiverLookupTag.getIrCallableSymbol()
|
||||||
@@ -1400,10 +1426,11 @@ class Fir2IrDeclarationStorage(
|
|||||||
getCachedIrDeclaration: (firDeclaration: F, dispatchReceiverLookupTag: ConeClassLikeLookupTag?, () -> IdSignature?) -> I?,
|
getCachedIrDeclaration: (firDeclaration: F, dispatchReceiverLookupTag: ConeClassLikeLookupTag?, () -> IdSignature?) -> I?,
|
||||||
createIrDeclaration: (parent: IrDeclarationParent?, origin: IrDeclarationOrigin) -> I,
|
createIrDeclaration: (parent: IrDeclarationParent?, origin: IrDeclarationOrigin) -> I,
|
||||||
createIrLazyDeclaration: (signature: IdSignature, lazyOwner: IrDeclarationParent, origin: IrDeclarationOrigin) -> I,
|
createIrLazyDeclaration: (signature: IdSignature, lazyOwner: IrDeclarationParent, origin: IrDeclarationOrigin) -> I,
|
||||||
|
forceTopLevelPrivate: Boolean = false,
|
||||||
): IrSymbol {
|
): IrSymbol {
|
||||||
val fir = firSymbol.fir as F
|
val fir = firSymbol.fir as F
|
||||||
val irParent by lazy { findIrParent(fir) }
|
val irParent by lazy { findIrParent(fir) }
|
||||||
val signature by lazy { signatureComposer.composeSignature(fir, dispatchReceiverLookupTag) }
|
val signature by lazy { signatureComposer.composeSignature(fir, dispatchReceiverLookupTag, forceTopLevelPrivate) }
|
||||||
synchronized(symbolTable.lock) {
|
synchronized(symbolTable.lock) {
|
||||||
getCachedIrDeclaration(fir, dispatchReceiverLookupTag.takeIf { it !is ConeClassLookupTagWithFixedSymbol }) {
|
getCachedIrDeclaration(fir, dispatchReceiverLookupTag.takeIf { it !is ConeClassLookupTagWithFixedSymbol }) {
|
||||||
// Parent calculation provokes declaration calculation for some members from IrBuiltIns
|
// Parent calculation provokes declaration calculation for some members from IrBuiltIns
|
||||||
|
|||||||
+12
-2
@@ -14,8 +14,18 @@ import org.jetbrains.kotlin.ir.util.IdSignature
|
|||||||
|
|
||||||
interface Fir2IrSignatureComposer {
|
interface Fir2IrSignatureComposer {
|
||||||
val mangler: FirMangler
|
val mangler: FirMangler
|
||||||
fun composeSignature(declaration: FirDeclaration, containingClass: ConeClassLikeLookupTag? = null): IdSignature?
|
fun composeSignature(
|
||||||
fun composeAccessorSignature(property: FirProperty, isSetter: Boolean, containingClass: ConeClassLikeLookupTag? = null): IdSignature?
|
declaration: FirDeclaration,
|
||||||
|
containingClass: ConeClassLikeLookupTag? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false
|
||||||
|
): IdSignature?
|
||||||
|
|
||||||
|
fun composeAccessorSignature(
|
||||||
|
property: FirProperty,
|
||||||
|
isSetter: Boolean,
|
||||||
|
containingClass: ConeClassLikeLookupTag? = null,
|
||||||
|
forceTopLevelPrivate: Boolean = false
|
||||||
|
): IdSignature?
|
||||||
fun composeTypeParameterSignature(typeParameter: FirTypeParameter, index: Int, containerSignature: IdSignature?): IdSignature?
|
fun composeTypeParameterSignature(typeParameter: FirTypeParameter, index: Int, containerSignature: IdSignature?): IdSignature?
|
||||||
fun withFileSignature(sig: IdSignature.FileSignature, body: () -> Unit)
|
fun withFileSignature(sig: IdSignature.FileSignature, body: () -> Unit)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ package org.jetbrains.kotlin.fir.backend
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData.SymbolKind
|
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData.SymbolKind
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.kind
|
import org.jetbrains.kotlin.backend.common.serialization.kind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.fir.backend.generators.FakeOverrideGenerator
|
import org.jetbrains.kotlin.fir.backend.generators.FakeOverrideGenerator
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.classId
|
import org.jetbrains.kotlin.fir.declarations.utils.classId
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
||||||
@@ -73,19 +75,22 @@ class FirIrProvider(val fir2IrComponents: Fir2IrComponents) : IrProvider {
|
|||||||
|
|
||||||
val firCandidates: List<FirDeclaration>
|
val firCandidates: List<FirDeclaration>
|
||||||
val parent: IrDeclarationParent
|
val parent: IrDeclarationParent
|
||||||
|
var isTopLevelPrivate = false
|
||||||
if (nameSegments.size == 1 && kind != SymbolKind.CLASS_SYMBOL) {
|
if (nameSegments.size == 1 && kind != SymbolKind.CLASS_SYMBOL) {
|
||||||
firCandidates = symbolProvider.getTopLevelCallableSymbols(packageFqName, topName).map { it.fir }
|
firCandidates = symbolProvider.getTopLevelCallableSymbols(packageFqName, topName).map { it.fir }
|
||||||
parent = packageFragment // TODO: need to insert file facade class on JVM
|
parent = packageFragment // TODO: need to insert file facade class on JVM
|
||||||
} else {
|
} else {
|
||||||
var firParentClass: FirRegularClass? = null
|
val topLevelClass = symbolProvider.getClassLikeSymbolByClassId(ClassId(packageFqName, topName))?.fir as? FirRegularClass
|
||||||
var firClass = symbolProvider.getClassLikeSymbolByClassId(ClassId(packageFqName, topName))?.fir as? FirRegularClass
|
|
||||||
?: return null
|
?: return null
|
||||||
|
var firParentClass: FirRegularClass? = null
|
||||||
|
var firClass = topLevelClass
|
||||||
val midSegments = if (kind == SymbolKind.CLASS_SYMBOL) nameSegments.drop(1) else nameSegments.drop(1).dropLast(1)
|
val midSegments = if (kind == SymbolKind.CLASS_SYMBOL) nameSegments.drop(1) else nameSegments.drop(1).dropLast(1)
|
||||||
for (midName in midSegments) {
|
for (midName in midSegments) {
|
||||||
firParentClass = firClass
|
firParentClass = firClass
|
||||||
firClass = firClass.declarations.singleOrNull { (it as? FirRegularClass)?.name?.asString() == midName } as? FirRegularClass
|
firClass = firClass.declarations.singleOrNull { (it as? FirRegularClass)?.name?.asString() == midName } as? FirRegularClass
|
||||||
?: return null
|
?: return null
|
||||||
}
|
}
|
||||||
|
isTopLevelPrivate = topLevelClass.visibility == Visibilities.Private
|
||||||
val classId = firClass.classId
|
val classId = firClass.classId
|
||||||
val scope =
|
val scope =
|
||||||
firClass.unsubstitutedScope(fir2IrComponents.session, fir2IrComponents.scopeSession, withForcedTypeCalculator = true)
|
firClass.unsubstitutedScope(fir2IrComponents.session, fir2IrComponents.scopeSession, withForcedTypeCalculator = true)
|
||||||
@@ -160,19 +165,24 @@ class FirIrProvider(val fir2IrComponents: Fir2IrComponents) : IrProvider {
|
|||||||
?: return null
|
?: return null
|
||||||
|
|
||||||
return when (kind) {
|
return when (kind) {
|
||||||
SymbolKind.CLASS_SYMBOL -> classifierStorage.getIrClassSymbol((firDeclaration as FirRegularClass).symbol).owner
|
SymbolKind.CLASS_SYMBOL -> classifierStorage.getIrClassSymbol(
|
||||||
SymbolKind.ENUM_ENTRY_SYMBOL -> classifierStorage.createIrEnumEntry(firDeclaration as FirEnumEntry, parent as IrClass)
|
(firDeclaration as FirRegularClass).symbol,
|
||||||
|
forceTopLevelPrivate = isTopLevelPrivate
|
||||||
|
).owner
|
||||||
|
SymbolKind.ENUM_ENTRY_SYMBOL -> classifierStorage.createIrEnumEntry(
|
||||||
|
firDeclaration as FirEnumEntry, parent as IrClass, forceTopLevelPrivate = isTopLevelPrivate
|
||||||
|
)
|
||||||
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
||||||
val firConstructor = firDeclaration as FirConstructor
|
val firConstructor = firDeclaration as FirConstructor
|
||||||
declarationStorage.getOrCreateIrConstructor(firConstructor, parent as IrClass)
|
declarationStorage.getOrCreateIrConstructor(firConstructor, parent as IrClass, forceTopLevelPrivate = isTopLevelPrivate)
|
||||||
}
|
}
|
||||||
SymbolKind.FUNCTION_SYMBOL -> {
|
SymbolKind.FUNCTION_SYMBOL -> {
|
||||||
val firSimpleFunction = firDeclaration as FirSimpleFunction
|
val firSimpleFunction = firDeclaration as FirSimpleFunction
|
||||||
declarationStorage.getOrCreateIrFunction(firSimpleFunction, parent)
|
declarationStorage.getOrCreateIrFunction(firSimpleFunction, parent, forceTopLevelPrivate = isTopLevelPrivate)
|
||||||
}
|
}
|
||||||
SymbolKind.PROPERTY_SYMBOL -> {
|
SymbolKind.PROPERTY_SYMBOL -> {
|
||||||
val firProperty = firDeclaration as FirProperty
|
val firProperty = firDeclaration as FirProperty
|
||||||
declarationStorage.getOrCreateIrProperty(firProperty, parent)
|
declarationStorage.getOrCreateIrProperty(firProperty, parent, forceTopLevelPrivate = isTopLevelPrivate)
|
||||||
}
|
}
|
||||||
SymbolKind.FIELD_SYMBOL -> {
|
SymbolKind.FIELD_SYMBOL -> {
|
||||||
val firField = firDeclaration as FirField
|
val firField = firDeclaration as FirField
|
||||||
|
|||||||
+2
-2
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
|||||||
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
|
||||||
import org.jetbrains.kotlin.ir.util.withScope
|
|
||||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
@@ -232,7 +231,8 @@ class FakeOverrideGenerator(
|
|||||||
// have the same signature.
|
// have the same signature.
|
||||||
// Now we avoid this problem by signature caching,
|
// Now we avoid this problem by signature caching,
|
||||||
// so both FIR overrides correspond to one IR fake override
|
// so both FIR overrides correspond to one IR fake override
|
||||||
signatureComposer.composeSignature(fakeOverrideFirDeclaration)
|
val isTopLevelPrivate = irClass.symbol.signature is IdSignature.CompositeSignature
|
||||||
|
signatureComposer.composeSignature(fakeOverrideFirDeclaration, forceTopLevelPrivate = isTopLevelPrivate)
|
||||||
}?.takeIf { it.parent == irClass }
|
}?.takeIf { it.parent == irClass }
|
||||||
?: createIrDeclaration(
|
?: createIrDeclaration(
|
||||||
fakeOverrideFirDeclaration,
|
fakeOverrideFirDeclaration,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ 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
|
||||||
import org.jetbrains.kotlin.ir.util.DeserializableClass
|
import org.jetbrains.kotlin.ir.util.DeserializableClass
|
||||||
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
@@ -149,17 +150,18 @@ class Fir2IrLazyClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
||||||
|
val isTopLevelPrivate = symbol.signature is IdSignature.CompositeSignature
|
||||||
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,
|
||||||
// e.g. to avoid accessing un-enhanced Java declarations with FirJavaTypeRef etc. inside
|
// e.g. to avoid accessing un-enhanced Java declarations with FirJavaTypeRef etc. inside
|
||||||
val scope = fir.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = true)
|
val scope = fir.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = true)
|
||||||
scope.processDeclaredConstructors {
|
scope.processDeclaredConstructors {
|
||||||
result += declarationStorage.getIrConstructorSymbol(it).owner
|
result += declarationStorage.getIrConstructorSymbol(it, forceTopLevelPrivate = isTopLevelPrivate).owner
|
||||||
}
|
}
|
||||||
|
|
||||||
for (declaration in fir.declarations) {
|
for (declaration in fir.declarations) {
|
||||||
if (declaration is FirRegularClass) {
|
if (declaration is FirRegularClass) {
|
||||||
val nestedSymbol = classifierStorage.getIrClassSymbol(declaration.symbol)
|
val nestedSymbol = classifierStorage.getIrClassSymbol(declaration.symbol, forceTopLevelPrivate = isTopLevelPrivate)
|
||||||
result += nestedSymbol.owner
|
result += nestedSymbol.owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +176,7 @@ class Fir2IrLazyClass(
|
|||||||
if (declaration.source == null && declaration.origin != FirDeclarationOrigin.Java ||
|
if (declaration.source == null && declaration.origin != FirDeclarationOrigin.Java ||
|
||||||
declaration.source?.kind == KtFakeSourceElementKind.EnumGeneratedDeclaration
|
declaration.source?.kind == KtFakeSourceElementKind.EnumGeneratedDeclaration
|
||||||
) {
|
) {
|
||||||
result += declarationStorage.getIrFunctionSymbol(declaration.symbol).owner
|
result += declarationStorage.getIrFunctionSymbol(declaration.symbol, forceTopLevelPrivate = isTopLevelPrivate).owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,13 +189,15 @@ class Fir2IrLazyClass(
|
|||||||
if (it.isAbstractMethodOfAny()) {
|
if (it.isAbstractMethodOfAny()) {
|
||||||
return@processFunctionsByName
|
return@processFunctionsByName
|
||||||
}
|
}
|
||||||
result += declarationStorage.getIrFunctionSymbol(it).owner
|
result += declarationStorage.getIrFunctionSymbol(it, forceTopLevelPrivate = isTopLevelPrivate).owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.processPropertiesByName(name) {
|
scope.processPropertiesByName(name) {
|
||||||
if (it.isSubstitutionOrIntersectionOverride) return@processPropertiesByName
|
if (it.isSubstitutionOrIntersectionOverride) return@processPropertiesByName
|
||||||
if (it is FirPropertySymbol && it.dispatchReceiverClassOrNull() == ownerLookupTag) {
|
if (it is FirPropertySymbol && it.dispatchReceiverClassOrNull() == ownerLookupTag) {
|
||||||
result.addIfNotNull(declarationStorage.getIrPropertySymbol(it).owner as? IrDeclaration)
|
result.addIfNotNull(
|
||||||
|
declarationStorage.getIrPropertySymbol(it, forceTopLevelPrivate = isTopLevelPrivate).owner as? IrDeclaration
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.*
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
|
|
||||||
class Fir2IrLazyProperty(
|
class Fir2IrLazyProperty(
|
||||||
components: Fir2IrComponents,
|
components: Fir2IrComponents,
|
||||||
@@ -160,7 +161,12 @@ class Fir2IrLazyProperty(
|
|||||||
|
|
||||||
override var getter: IrSimpleFunction? by lazyVar(lock) {
|
override var getter: IrSimpleFunction? by lazyVar(lock) {
|
||||||
if (fir.isConst) return@lazyVar null
|
if (fir.isConst) return@lazyVar null
|
||||||
val signature = signatureComposer.composeAccessorSignature(fir, isSetter = false, containingClass?.symbol?.toLookupTag())!!
|
val signature = signatureComposer.composeAccessorSignature(
|
||||||
|
fir,
|
||||||
|
isSetter = false,
|
||||||
|
containingClass?.symbol?.toLookupTag(),
|
||||||
|
forceTopLevelPrivate = symbol.signature is IdSignature.CompositeSignature
|
||||||
|
)!!
|
||||||
symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol ->
|
symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol ->
|
||||||
Fir2IrLazyPropertyAccessor(
|
Fir2IrLazyPropertyAccessor(
|
||||||
components, startOffset, endOffset,
|
components, startOffset, endOffset,
|
||||||
@@ -189,7 +195,12 @@ class Fir2IrLazyProperty(
|
|||||||
override var setter: IrSimpleFunction? by lazyVar(lock) {
|
override var setter: IrSimpleFunction? by lazyVar(lock) {
|
||||||
if (!fir.isVar) null
|
if (!fir.isVar) null
|
||||||
else {
|
else {
|
||||||
val signature = signatureComposer.composeAccessorSignature(fir, isSetter = true, containingClass?.symbol?.toLookupTag())!!
|
val signature = signatureComposer.composeAccessorSignature(
|
||||||
|
fir,
|
||||||
|
isSetter = true,
|
||||||
|
containingClass?.symbol?.toLookupTag(),
|
||||||
|
forceTopLevelPrivate = symbol.signature is IdSignature.CompositeSignature
|
||||||
|
)!!
|
||||||
symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol ->
|
symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol ->
|
||||||
Fir2IrLazyPropertyAccessor(
|
Fir2IrLazyPropertyAccessor(
|
||||||
components, startOffset, endOffset,
|
components, startOffset, endOffset,
|
||||||
|
|||||||
+10
-6
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
|||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
|
||||||
|
|
||||||
// @NoMutableState -- we'll restore this annotation once we get rid of withFileSignature().
|
// @NoMutableState -- we'll restore this annotation once we get rid of withFileSignature().
|
||||||
class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignatureComposer {
|
class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignatureComposer {
|
||||||
@@ -76,7 +75,11 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun composeSignature(declaration: FirDeclaration, containingClass: ConeClassLikeLookupTag?): IdSignature? {
|
override fun composeSignature(
|
||||||
|
declaration: FirDeclaration,
|
||||||
|
containingClass: ConeClassLikeLookupTag?,
|
||||||
|
forceTopLevelPrivate: Boolean
|
||||||
|
): IdSignature? {
|
||||||
if (declaration is FirAnonymousObject || declaration is FirAnonymousFunction) return null
|
if (declaration is FirAnonymousObject || declaration is FirAnonymousFunction) return null
|
||||||
if (declaration is FirRegularClass && declaration.classId.isLocal) return null
|
if (declaration is FirRegularClass && declaration.classId.isLocal) return null
|
||||||
if (declaration is FirCallableDeclaration) {
|
if (declaration is FirCallableDeclaration) {
|
||||||
@@ -118,7 +121,7 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
|
|||||||
}
|
}
|
||||||
else -> error("Unsupported FIR declaration in signature composer: ${declaration.render()}")
|
else -> error("Unsupported FIR declaration in signature composer: ${declaration.render()}")
|
||||||
}
|
}
|
||||||
return if (isTopLevelPrivate(declaration, containingClass)) {
|
return if (isTopLevelPrivate(declaration, containingClass) || forceTopLevelPrivate) {
|
||||||
val fileSig = fileSignature ?: return null
|
val fileSig = fileSignature ?: return null
|
||||||
IdSignature.CompositeSignature(fileSig, publicSignature)
|
IdSignature.CompositeSignature(fileSig, publicSignature)
|
||||||
} else
|
} else
|
||||||
@@ -140,11 +143,12 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
|
|||||||
override fun composeAccessorSignature(
|
override fun composeAccessorSignature(
|
||||||
property: FirProperty,
|
property: FirProperty,
|
||||||
isSetter: Boolean,
|
isSetter: Boolean,
|
||||||
containingClass: ConeClassLikeLookupTag?
|
containingClass: ConeClassLikeLookupTag?,
|
||||||
|
forceTopLevelPrivate: Boolean
|
||||||
): IdSignature? {
|
): IdSignature? {
|
||||||
val propSig: IdSignature.CommonSignature
|
val propSig: IdSignature.CommonSignature
|
||||||
val fileSig: IdSignature.FileSignature?
|
val fileSig: IdSignature.FileSignature?
|
||||||
when (val propertySignature = composeSignature(property, containingClass)) {
|
when (val propertySignature = composeSignature(property, containingClass, forceTopLevelPrivate)) {
|
||||||
is IdSignature.CompositeSignature -> {
|
is IdSignature.CompositeSignature -> {
|
||||||
propSig = propertySignature.inner as? IdSignature.CommonSignature ?: return null
|
propSig = propertySignature.inner as? IdSignature.CommonSignature ?: return null
|
||||||
fileSig = propertySignature.container as? IdSignature.FileSignature ?: return null
|
fileSig = propertySignature.container as? IdSignature.FileSignature ?: return null
|
||||||
@@ -175,7 +179,7 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isTopLevelPrivate(declaration: FirDeclaration, containingClass: ConeClassLikeLookupTag?): Boolean =
|
private fun isTopLevelPrivate(declaration: FirDeclaration, containingClass: ConeClassLikeLookupTag?): Boolean =
|
||||||
containingClass == null && declaration is FirCallableDeclaration && declaration.visibility == Visibilities.Private
|
containingClass == null && declaration is FirMemberDeclaration && declaration.visibility == Visibilities.Private
|
||||||
|
|
||||||
private fun FirProperty.getterOrDefault() =
|
private fun FirProperty.getterOrDefault() =
|
||||||
getter ?: FirDefaultPropertyGetter(
|
getter ?: FirDefaultPropertyGetter(
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class FirLightTreeBlackBoxInlineCodegenTestGenerated extends AbstractFirL
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends A
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
private class S public constructor() {
|
||||||
|
class Z {
|
||||||
|
fun a(): String {
|
||||||
|
return "K"
|
||||||
|
}
|
||||||
|
|
||||||
|
val empty = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class E(val s: String) {
|
||||||
|
EMPTY("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This function exposes S.Z and S.E, nested into a private class S (package-private in the byte code)
|
||||||
|
// They can be accessed outside the `test` package now that S.Z, S.E are public in the byte code, but that may be changed later
|
||||||
|
internal inline fun call(s: () -> String): String {
|
||||||
|
return s() + S.Z().empty + S.E.EMPTY.s + S.Z().a()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return call {
|
||||||
|
"O"
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -3660,6 +3660,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends Ab
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3660,6 +3660,12 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3276,6 +3276,12 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest {
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -3276,6 +3276,12 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -3005,6 +3005,11 @@ public class IrCodegenBoxInlineWasmTestGenerated extends AbstractIrCodegenBoxInl
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/private/privateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/privateClass.kt");
|
||||||
|
|||||||
+6
@@ -42100,6 +42100,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInPrivateClass2.kt")
|
||||||
|
public void testNestedInPrivateClass2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/private/nestedInPrivateClass2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("privateClass.kt")
|
@TestMetadata("privateClass.kt")
|
||||||
public void testPrivateClass() throws Exception {
|
public void testPrivateClass() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user