Make FileDescriptorForVisibilityCheck subtype of PackageFragmentDescriptor

#KT-20548 Fixed
This commit is contained in:
Mikhail Glukhikh
2020-12-16 09:22:28 +03:00
parent 3ae8521f12
commit 107a825c5f
2 changed files with 5 additions and 9 deletions
@@ -83,11 +83,9 @@ class LazyAnnotationDescriptor(
override val source = annotationEntry.toSourceElement()
private val scope = if (c.scope.ownerDescriptor is PackageFragmentDescriptor) {
LexicalScope.Base(c.scope, FileDescriptorForVisibilityChecks(source, c.scope.ownerDescriptor))
} else {
c.scope
}
private val scope = (c.scope.ownerDescriptor as? PackageFragmentDescriptor)?.let {
LexicalScope.Base(c.scope, FileDescriptorForVisibilityChecks(source, it))
} ?: c.scope
override val allValueArguments by c.storageManager.createLazyValue {
val resolutionResults = c.annotationResolver.resolveAnnotationCall(annotationEntry, scope, c.trace)
@@ -110,10 +108,9 @@ class LazyAnnotationDescriptor(
private class FileDescriptorForVisibilityChecks(
private val source: SourceElement,
private val containingDeclaration: DeclarationDescriptor
) : DeclarationDescriptorWithSource {
private val containingDeclaration: PackageFragmentDescriptor
) : DeclarationDescriptorWithSource, PackageFragmentDescriptor by containingDeclaration {
override val annotations: Annotations get() = Annotations.EMPTY
override fun getContainingDeclaration() = containingDeclaration
override fun getSource() = source
override fun getOriginal() = this
override fun getName() = Name.special("< file descriptor for annotation resolution >")
@@ -1,5 +1,4 @@
// Validation
// ALLOW_FRONTEND_EXCEPTION
// See KT-24323
// FIR_COMPARISON