FIR IDE: add API to get KtType from KtTypeParameter
This commit is contained in:
committed by
Ilya Kirillov
parent
d91170ed2c
commit
205866a516
+15
-1
@@ -8,19 +8,22 @@ package org.jetbrains.kotlin.analysis.api.components
|
||||
import org.jetbrains.kotlin.analysis.api.KtTypeArgument
|
||||
import org.jetbrains.kotlin.analysis.api.KtTypeArgumentWithVariance
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtClassType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeParameterType
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
public abstract class KtTypeCreator : KtAnalysisSessionComponent() {
|
||||
public abstract fun buildClassType(builder: KtClassTypeBuilder): KtClassType
|
||||
|
||||
public abstract fun buildTypeParameterType(builder: KtTypeParameterTypeBuilder): KtTypeParameterType
|
||||
}
|
||||
|
||||
public interface KtTypeCreatorMixIn : KtAnalysisSessionMixIn
|
||||
|
||||
|
||||
public inline fun KtTypeCreatorMixIn.buildClassType(
|
||||
classId: ClassId,
|
||||
build: KtClassTypeBuilder.() -> Unit = {}
|
||||
@@ -33,6 +36,11 @@ public inline fun KtTypeCreatorMixIn.buildClassType(
|
||||
): KtClassType =
|
||||
analysisSession.typesCreator.buildClassType(KtClassTypeBuilder.BySymbol(symbol).apply(build))
|
||||
|
||||
public inline fun KtTypeCreatorMixIn.buildTypeParameterType(
|
||||
symbol: KtTypeParameterSymbol,
|
||||
build: KtTypeParameterTypeBuilder.() -> Unit = {}
|
||||
): KtTypeParameterType =
|
||||
analysisSession.typesCreator.buildTypeParameterType(KtTypeParameterTypeBuilder.BySymbol(symbol).apply(build))
|
||||
|
||||
public sealed class KtTypeBuilder
|
||||
|
||||
@@ -55,3 +63,9 @@ public sealed class KtClassTypeBuilder : KtTypeBuilder() {
|
||||
public class BySymbol(public val symbol: KtClassOrObjectSymbol) : KtClassTypeBuilder()
|
||||
}
|
||||
|
||||
public sealed class KtTypeParameterTypeBuilder : KtTypeBuilder() {
|
||||
public var nullability: KtTypeNullability = KtTypeNullability.NULLABLE
|
||||
|
||||
public class BySymbol(public val symbol: KtTypeParameterSymbol) : KtTypeParameterTypeBuilder()
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun <<caret>T> function(t: T) where T : Int, T : Long = TODO()
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: T
|
||||
ktType: T
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun <<caret>T> function(t: T) = TODO()
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: T
|
||||
ktType: T
|
||||
+1
@@ -0,0 +1 @@
|
||||
inline fun <reified <caret>T> function(t: T) = TODO()
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: reified T
|
||||
ktType: T
|
||||
Reference in New Issue
Block a user