Introduce Type Parameter

#KT-13155 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-26 20:14:12 +03:00
parent cd717467f0
commit 2f9a911624
23 changed files with 367 additions and 14 deletions
@@ -32,7 +32,9 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.takeSnapshot
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
operator fun <K, V: Any> BindingContext.get(slice: ReadOnlySlice<K, V>, key: K): V? = get(slice, key)
@@ -98,4 +100,16 @@ fun KtExpression.getReferenceTargets(context: BindingContext): Collection<Declar
}
fun KtTypeReference.getAbbreviatedTypeOrType(context: BindingContext) =
context[BindingContext.ABBREVIATED_TYPE, this] ?: context[BindingContext.TYPE, this]
context[BindingContext.ABBREVIATED_TYPE, this] ?: context[BindingContext.TYPE, this]
fun KtTypeElement.getAbbreviatedTypeOrType(context: BindingContext): KotlinType? {
val parent = parent
return when (parent) {
is KtTypeReference -> parent.getAbbreviatedTypeOrType(context)
is KtNullableType -> {
val outerType = parent.getAbbreviatedTypeOrType(context)
if (this is KtNullableType) outerType else outerType?.makeNotNullable()
}
else -> null
}
}