FIR IDE: introduce TypeInfo as a wrapper for types in high level API
Needed for correct handling types lifecycle
This commit is contained in:
+4
-5
@@ -5,20 +5,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
abstract class FrontendAnalysisSession : Invalidatable {
|
||||
abstract fun getSmartCastedToTypes(expression: KtExpression): Collection<TypeInfo>?
|
||||
|
||||
abstract fun getImplicitReceiverSmartCasts(expression: KtExpression): Collection<ImplicitReceiverSmartCast>
|
||||
|
||||
abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): KotlinTypeMarker?
|
||||
abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): TypeInfo?
|
||||
|
||||
abstract fun renderType(type: KotlinTypeMarker): String
|
||||
|
||||
abstract fun getKtExpressionType(expression: KtExpression): KotlinTypeMarker?
|
||||
abstract fun getKtExpressionType(expression: KtExpression): TypeInfo?
|
||||
|
||||
abstract fun isSubclassOf(klass: KtClassOrObject, superClassId: ClassId): Boolean
|
||||
|
||||
|
||||
+1
-3
@@ -5,9 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
data class ImplicitReceiverSmartCast(val types: Collection<KotlinTypeMarker>, val kind: ImplicitReceiverSmartcastKind)
|
||||
data class ImplicitReceiverSmartCast(val types: Collection<TypeInfo>, val kind: ImplicitReceiverSmartcastKind)
|
||||
|
||||
enum class ImplicitReceiverSmartcastKind {
|
||||
DISPATCH, EXTENSION
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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()
|
||||
Reference in New Issue
Block a user