FIR IDE: introduce KtType
This commit is contained in:
+3
-3
@@ -18,13 +18,13 @@ abstract class FrontendAnalysisSession(project: Project) : Invalidatable {
|
||||
|
||||
abstract val symbolProvider: KtSymbolProvider
|
||||
|
||||
abstract fun getSmartCastedToTypes(expression: KtExpression): Collection<TypeInfo>?
|
||||
abstract fun getSmartCastedToTypes(expression: KtExpression): Collection<KtType>?
|
||||
|
||||
abstract fun getImplicitReceiverSmartCasts(expression: KtExpression): Collection<ImplicitReceiverSmartCast>
|
||||
|
||||
abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): TypeInfo
|
||||
abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): KtType
|
||||
|
||||
abstract fun getKtExpressionType(expression: KtExpression): TypeInfo
|
||||
abstract fun getKtExpressionType(expression: KtExpression): KtType
|
||||
|
||||
abstract fun isSubclassOf(klass: KtClassOrObject, superClassId: ClassId): Boolean
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
data class ImplicitReceiverSmartCast(val types: Collection<TypeInfo>, val kind: ImplicitReceiverSmartcastKind)
|
||||
data class ImplicitReceiverSmartCast(val types: Collection<KtType>, val kind: ImplicitReceiverSmartcastKind)
|
||||
|
||||
enum class ImplicitReceiverSmartcastKind {
|
||||
DISPATCH, EXTENSION
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassLikeSymbol
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface KtType : Invalidatable {
|
||||
fun isEqualTo(other: KtType): Boolean
|
||||
fun isSubTypeOf(superType: KtType): Boolean
|
||||
|
||||
fun asStringForDebugging(): String
|
||||
}
|
||||
|
||||
sealed class KtDenotableType : KtType {
|
||||
abstract fun asString(): String
|
||||
}
|
||||
|
||||
abstract class KtClassType : KtDenotableType() {
|
||||
abstract val classId: ClassId
|
||||
abstract val classSymbol: KtClassLikeSymbol
|
||||
abstract val typeArguments: List<KtTypeArgument>
|
||||
}
|
||||
|
||||
abstract class KtErrorType : KtType {
|
||||
abstract val error: String
|
||||
}
|
||||
|
||||
abstract class KtTypeParameterType : KtDenotableType() {
|
||||
abstract val name: Name
|
||||
abstract val symbol: KtTypeParameterSymbol
|
||||
}
|
||||
|
||||
sealed class KtNonDenotableType : KtType
|
||||
|
||||
abstract class KtFlexibleType : KtNonDenotableType() {
|
||||
abstract val lowerBound: KtType
|
||||
abstract val upperBound: KtType
|
||||
}
|
||||
|
||||
abstract class KtIntersectionType : KtNonDenotableType() {
|
||||
abstract val conjuncts: List<KtType>
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
sealed class KtTypeArgument
|
||||
|
||||
object KtStarProjectionTypeArgument : KtTypeArgument()
|
||||
|
||||
abstract class KtTypeArgumentWithVariance : KtTypeArgument() {
|
||||
abstract val type: KtType
|
||||
abstract val variance: KtTypeArgumentVariance
|
||||
}
|
||||
|
||||
enum class KtTypeArgumentVariance {
|
||||
COVARIANT, CONTRAVARIANT, INVARIANT
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
abstract class TypeInfo : Invalidatable {
|
||||
abstract fun isClassType(): Boolean
|
||||
abstract fun classIdIfClassTypeOrError(): ClassId
|
||||
|
||||
abstract fun isErrorType(): Boolean
|
||||
|
||||
abstract fun asDenotableTypeStringRepresentation(): String
|
||||
|
||||
abstract fun isEqualTo(other: TypeInfo): Boolean
|
||||
abstract fun isSubTypeOf(superType: TypeInfo): Boolean
|
||||
|
||||
abstract fun isDefinitelyNullable(): Boolean
|
||||
abstract fun isDefinitelyNotNull(): Boolean
|
||||
|
||||
override fun toString(): String = asDenotableTypeStringRepresentation()
|
||||
}
|
||||
|
||||
class ErrorTypeClassIdAccessException(override val message: String? = null) : IllegalStateException()
|
||||
class ClassTypeExpectedException(override val message: String? = null) : IllegalStateException()
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api.symbols
|
||||
|
||||
import org.jetbrains.kotlin.idea.frontend.api.TypeInfo
|
||||
import org.jetbrains.kotlin.idea.frontend.api.KtType
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -36,7 +36,7 @@ object DebugSymbolRenderer {
|
||||
value.joinTo(this) { renderValue(it) }
|
||||
append("]")
|
||||
}
|
||||
is TypeInfo -> value.asDenotableTypeStringRepresentation()
|
||||
is KtType -> value.asStringForDebugging()
|
||||
is KtSymbol -> {
|
||||
val symbolTag = when (value) {
|
||||
is KtClassLikeSymbol -> renderValue(value.classId)
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api.symbols
|
||||
|
||||
import org.jetbrains.kotlin.idea.frontend.api.TypeInfo
|
||||
import org.jetbrains.kotlin.idea.frontend.api.KtType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface KtNamedSymbol : KtSymbol {
|
||||
@@ -21,12 +21,12 @@ enum class KtSymbolKind {
|
||||
}
|
||||
|
||||
interface KtTypedSymbol : KtSymbol {
|
||||
val type: TypeInfo
|
||||
val type: KtType
|
||||
}
|
||||
|
||||
interface KtPossibleExtensionSymbol {
|
||||
val isExtension: Boolean
|
||||
val receiverType: TypeInfo?
|
||||
val receiverType: KtType?
|
||||
}
|
||||
|
||||
interface KtSymbolWithTypeParameters {
|
||||
|
||||
Reference in New Issue
Block a user