[NI] Fix loosing type annotations on extension functions

#KT-32138 fixed
This commit is contained in:
Ilya Chernikov
2019-11-21 18:25:57 +01:00
parent 467e6e3d97
commit 7dd9ed7e38
11 changed files with 153 additions and 4 deletions
@@ -51,9 +51,12 @@ interface Annotations : Iterable<AnnotationDescriptor> {
class FilteredAnnotations(
private val delegate: Annotations,
private val isDefinitelyNewInference: Boolean,
private val fqNameFilter: (FqName) -> Boolean
) : Annotations {
constructor(delegate: Annotations, fqNameFilter: (FqName) -> Boolean) : this(delegate, false, fqNameFilter)
override fun hasAnnotation(fqName: FqName) =
if (fqNameFilter(fqName)) delegate.hasAnnotation(fqName)
else false
@@ -64,7 +67,11 @@ class FilteredAnnotations(
override fun iterator() = delegate.filter(this::shouldBeReturned).iterator()
override fun isEmpty() = delegate.any(this::shouldBeReturned)
override fun isEmpty(): Boolean {
val condition = delegate.any(this::shouldBeReturned)
// fixing KT-32189 && KT-32138 for the new inference only
return if (isDefinitelyNewInference) !condition else condition
}
private fun shouldBeReturned(annotation: AnnotationDescriptor): Boolean =
annotation.fqName.let { fqName ->