Iterate Intention: Fix detection of extension iterators

#KT-8616 Fixed
This commit is contained in:
Alexey Sedunov
2015-12-17 20:55:55 +03:00
parent ee9389d089
commit 1c74bab1cc
14 changed files with 99 additions and 16 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.idea.core
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.idea.util.FuzzyType
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
@@ -79,7 +80,10 @@ public class IterableTypesDetection(
private fun canBeIterable(type: FuzzyType): Boolean {
return type.type.memberScope.getContributedFunctions(iteratorName, NoLookupLocation.FROM_IDE).isNotEmpty() ||
typesWithExtensionIterator.any { type.checkIsSubtypeOf(it) != null }
typesWithExtensionIterator.any {
val freeParams = it.arguments.mapNotNull { it.type.constructor.declarationDescriptor as? TypeParameterDescriptor }
type.checkIsSubtypeOf(FuzzyType(it, freeParams)) != null
}
}
}
}