IR: add IrBasedDescriptors

This commit is contained in:
Georgy Bronnikov
2020-08-09 15:34:18 +03:00
parent dafcdc527d
commit 0b4c43083d
3 changed files with 1107 additions and 9 deletions
@@ -241,7 +241,7 @@ class IrExpressionLambdaImpl(
override val invokeMethodDescriptor: FunctionDescriptor =
// Need the descriptor without captured parameters here.
(function.descriptor as? WrappedSimpleFunctionDescriptor)?.originalDescriptor ?: function.descriptor
function.originalFunction.descriptor
override val hasDispatchReceiver: Boolean = false
@@ -383,13 +383,6 @@ open class WrappedSimpleFunctionDescriptor(
sourceElement: SourceElement = SourceElement.NO_SOURCE
) : SimpleFunctionDescriptor, WrappedCallableDescriptor<IrSimpleFunction>(annotations, sourceElement) {
// TODO: Remove as soon as all IR declarations have their originalDescriptor.
constructor(originalDescriptor: FunctionDescriptor) : this(originalDescriptor.annotations, originalDescriptor.source) {
this.originalDescriptor = originalDescriptor
}
var originalDescriptor: FunctionDescriptor? = null
override fun getOverriddenDescriptors() = owner.overriddenSymbols.map { it.descriptor }
override fun getContainingDeclaration(): DeclarationDescriptor = getContainingDeclaration(owner)
@@ -632,12 +625,23 @@ open class WrappedClassDescriptor(
private val _typeConstructor: TypeConstructor by lazy {
LazyTypeConstructor(
this,
{ declaredTypeParameters },
::collectTypeParameters,
{ owner.superTypes.map { it.toKotlinType() } },
LockBasedStorageManager.NO_LOCKS
)
}
private fun collectTypeParameters(): List<TypeParameterDescriptor> =
generateSequence(owner as IrTypeParametersContainer,
{ current ->
val parent = current.parent as? IrTypeParametersContainer
if (parent is IrClass && current is IrClass && !current.isInner) null
else parent
})
.flatMap { it.typeParameters }
.map { it.descriptor }
.toList()
override fun getTypeConstructor(): TypeConstructor = _typeConstructor
override fun isInner() = owner.isInner