[FIR] Add creating simple type for type parameters symbols

This commit is contained in:
Dmitriy Novozhilov
2019-08-23 12:26:51 +03:00
parent b1731749c0
commit 2d3e9fe539
2 changed files with 24 additions and 6 deletions
@@ -12,12 +12,10 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
import org.jetbrains.kotlin.fir.resolve.withArguments
import org.jetbrains.kotlin.fir.resolve.withNullability
import org.jetbrains.kotlin.fir.service
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
import org.jetbrains.kotlin.fir.symbols.invoke
import org.jetbrains.kotlin.fir.symbols.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
import org.jetbrains.kotlin.types.model.*
@@ -59,12 +57,16 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
nullable: Boolean
): SimpleTypeMarker {
require(constructor is ConeClassifierSymbol)
when (constructor) {
is ConeClassLikeSymbol -> return ConeClassTypeImpl(
return when (constructor) {
is ConeClassLikeSymbol -> ConeClassTypeImpl(
constructor.toLookupTag(),
(arguments as List<ConeKotlinTypeProjection>).toTypedArray(),
nullable
)
is ConeTypeParameterSymbol -> ConeTypeParameterTypeImpl(
constructor.toLookupTag(),
nullable
)
else -> error("!")
}
@@ -0,0 +1,16 @@
FILE: typeParameterDerived.kt
public final inline fun <K, V, VA : R|V|> R|kotlin/collections/MutableMap<K, V>|.getOrPut(key: R|K|, defaultValue: R|kotlin/Function1<K, VA>|, postCompute: R|kotlin/Function1<VA, kotlin/Unit>|): R|V| {
lval value: R|V| = R|FakeOverride<kotlin/collections/Map.get: R|V|>|(R|<local>/key|)
^getOrPut when () {
==(R|<local>/value|, Null(null)) -> {
lval answer: R|VA| = R|<local>/defaultValue|.R|FakeOverride<kotlin/Function1.invoke: R|VA|>|(R|<local>/key|)
R|FakeOverride<kotlin/collections/MutableMap.put: R|V|>|(R|<local>/key|, R|<local>/answer|)
R|<local>/postCompute|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/answer|)
R|<local>/answer|
}
else -> {
R|<local>/value|
}
}
}