Add documentation on type checker context / type system context
This commit is contained in:
committed by
TeamCityServer
parent
3909e3c54c
commit
83836037f8
@@ -12,7 +12,15 @@ import org.jetbrains.kotlin.utils.SmartList
|
|||||||
import org.jetbrains.kotlin.utils.SmartSet
|
import org.jetbrains.kotlin.utils.SmartSet
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context that defines how type-checker operates, stores type-checker state,
|
||||||
|
* created by [TypeCheckerProviderContext.newBaseTypeCheckerContext] in most cases
|
||||||
|
*
|
||||||
|
* Stateful and shouldn't be reused
|
||||||
|
*
|
||||||
|
* Once some type-checker operation is performed using a [TypeCheckerProviderContext], for example a [AbstractTypeChecker.isSubtypeOf],
|
||||||
|
* new instance of particular [AbstractTypeCheckerContext] should be created, with properly specified type system context
|
||||||
|
*/
|
||||||
abstract class AbstractTypeCheckerContext() {
|
abstract class AbstractTypeCheckerContext() {
|
||||||
|
|
||||||
abstract val typeSystemContext: TypeSystemContext
|
abstract val typeSystemContext: TypeSystemContext
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ interface TypeSystemOptimizationContext {
|
|||||||
fun identicalArguments(a: SimpleTypeMarker, b: SimpleTypeMarker) = false
|
fun identicalArguments(a: SimpleTypeMarker, b: SimpleTypeMarker) = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context that allow type-impl agnostic access to common types
|
||||||
|
*/
|
||||||
interface TypeSystemBuiltInsContext {
|
interface TypeSystemBuiltInsContext {
|
||||||
fun nullableNothingType(): SimpleTypeMarker
|
fun nullableNothingType(): SimpleTypeMarker
|
||||||
fun nullableAnyType(): SimpleTypeMarker
|
fun nullableAnyType(): SimpleTypeMarker
|
||||||
@@ -68,6 +71,9 @@ interface TypeSystemBuiltInsContext {
|
|||||||
fun anyType(): SimpleTypeMarker
|
fun anyType(): SimpleTypeMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context that allow construction of types
|
||||||
|
*/
|
||||||
interface TypeSystemTypeFactoryContext {
|
interface TypeSystemTypeFactoryContext {
|
||||||
fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker
|
fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker
|
||||||
fun createSimpleType(
|
fun createSimpleType(
|
||||||
@@ -85,7 +91,10 @@ interface TypeSystemTypeFactoryContext {
|
|||||||
fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker
|
fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory, that constructs [AbstractTypeCheckerContext], which defines type-checker behaviour
|
||||||
|
* Implementation is recommended to be [TypeSystemContext]
|
||||||
|
*/
|
||||||
interface TypeCheckerProviderContext {
|
interface TypeCheckerProviderContext {
|
||||||
fun newBaseTypeCheckerContext(
|
fun newBaseTypeCheckerContext(
|
||||||
errorTypesEqualToAnything: Boolean,
|
errorTypesEqualToAnything: Boolean,
|
||||||
@@ -93,6 +102,9 @@ interface TypeCheckerProviderContext {
|
|||||||
): AbstractTypeCheckerContext
|
): AbstractTypeCheckerContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended type system context, which defines set of operations specific to common super-type calculation
|
||||||
|
*/
|
||||||
interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeFactoryContext, TypeCheckerProviderContext {
|
interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeFactoryContext, TypeCheckerProviderContext {
|
||||||
|
|
||||||
fun KotlinTypeMarker.anySuperTypeConstructor(predicate: (TypeConstructorMarker) -> Boolean) =
|
fun KotlinTypeMarker.anySuperTypeConstructor(predicate: (TypeConstructorMarker) -> Boolean) =
|
||||||
@@ -130,6 +142,9 @@ interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeF
|
|||||||
// component implementation for TypeSystemInferenceExtensionContext
|
// component implementation for TypeSystemInferenceExtensionContext
|
||||||
interface TypeSystemInferenceExtensionContextDelegate : TypeSystemInferenceExtensionContext
|
interface TypeSystemInferenceExtensionContextDelegate : TypeSystemInferenceExtensionContext
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended type system context, which defines set of type operations specific for type inference
|
||||||
|
*/
|
||||||
interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBuiltInsContext, TypeSystemCommonSuperTypesContext {
|
interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBuiltInsContext, TypeSystemCommonSuperTypesContext {
|
||||||
fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean
|
fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean
|
||||||
|
|
||||||
@@ -228,7 +243,9 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
|||||||
|
|
||||||
class ArgumentList(initialSize: Int) : ArrayList<TypeArgumentMarker>(initialSize), TypeArgumentListMarker
|
class ArgumentList(initialSize: Int) : ArrayList<TypeArgumentMarker>(initialSize), TypeArgumentListMarker
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines common kotlin type operations with types for abstract types
|
||||||
|
*/
|
||||||
interface TypeSystemContext : TypeSystemOptimizationContext {
|
interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||||
fun KotlinTypeMarker.asSimpleType(): SimpleTypeMarker?
|
fun KotlinTypeMarker.asSimpleType(): SimpleTypeMarker?
|
||||||
fun KotlinTypeMarker.asFlexibleType(): FlexibleTypeMarker?
|
fun KotlinTypeMarker.asFlexibleType(): FlexibleTypeMarker?
|
||||||
|
|||||||
Reference in New Issue
Block a user