Fir2IR: remove wrapped descriptors

This commit is contained in:
Georgy Bronnikov
2020-12-03 16:06:49 +03:00
parent b05400154d
commit b07dccb8d7
15 changed files with 273 additions and 356 deletions
@@ -12,9 +12,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrScriptImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazySymbolTable
import org.jetbrains.kotlin.ir.descriptors.WrappedDeclarationDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
import org.jetbrains.kotlin.ir.descriptors.*
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.symbols.*
@@ -1046,34 +1044,6 @@ class SymbolTable(
throw IllegalArgumentException("Unexpected value descriptor: $value")
}
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun wrappedTopLevelCallableDescriptors(): Set<DescriptorWithContainerSource> {
val result = mutableSetOf<DescriptorWithContainerSource>()
for (descriptor in simpleFunctionSymbolTable.descriptorToSymbol.keys) {
if (descriptor is WrappedSimpleFunctionDescriptor && descriptor.owner.parent is IrPackageFragment) {
result.add(descriptor)
}
}
for (symbol in simpleFunctionSymbolTable.idSigToSymbol.values) {
val descriptor = symbol.descriptor
if (descriptor is WrappedSimpleFunctionDescriptor && symbol.owner.parent is IrPackageFragment) {
result.add(descriptor)
}
}
for (descriptor in propertySymbolTable.descriptorToSymbol.keys) {
if (descriptor is WrappedPropertyDescriptor && descriptor.owner.parent is IrPackageFragment) {
result.add(descriptor)
}
}
for (symbol in propertySymbolTable.idSigToSymbol.values) {
val descriptor = symbol.descriptor
if (descriptor is WrappedPropertyDescriptor && symbol.owner.parent is IrPackageFragment) {
result.add(descriptor)
}
}
return result
}
private inline fun <D : DeclarationDescriptor, IR : IrSymbolOwner, S : IrBindableSymbol<D, IR>> FlatSymbolTable<D, IR, S>.forEachPublicSymbolImpl(
block: (IrSymbol) -> Unit
) {
@@ -8,11 +8,12 @@ package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.ir.descriptors.IrBasedTypeParameterDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
val TypeParameterDescriptor.originalTypeParameter: TypeParameterDescriptor
get() =
if (this is WrappedTypeParameterDescriptor) {
if (this is WrappedTypeParameterDescriptor || this is IrBasedTypeParameterDescriptor) {
original
} else {
when (val container = containingDeclaration.original) {