[FIR] Add attributes for @Exact and @NoInfer

This commit is contained in:
Dmitriy Novozhilov
2020-06-04 12:39:41 +03:00
parent f76befa84e
commit e43932f147
2 changed files with 33 additions and 2 deletions
@@ -0,0 +1,29 @@
/*
* 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.fir.types
import kotlin.reflect.KClass
object CompilerConeAttributes {
object Exact : ConeAttribute<Exact>() {
override fun union(other: Exact?): Exact? = null
override fun intersect(other: Exact?): Exact? = null
override fun isSubtypeOf(other: Exact?): Boolean = true
override val key: KClass<out Exact> = Exact::class
}
object NoInfer : ConeAttribute<NoInfer>() {
override fun union(other: NoInfer?): NoInfer? = null
override fun intersect(other: NoInfer?): NoInfer? = null
override fun isSubtypeOf(other: NoInfer?): Boolean = true
override val key: KClass<out NoInfer> = NoInfer::class
}
}
val ConeAttributes.exact: CompilerConeAttributes.Exact? by ConeAttributes.attributeAccessor<CompilerConeAttributes.Exact>()
val ConeAttributes.noInfer: CompilerConeAttributes.NoInfer? by ConeAttributes.attributeAccessor<CompilerConeAttributes.NoInfer>()
@@ -251,11 +251,13 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
}
override fun KotlinTypeMarker.hasExactAnnotation(): Boolean {
return false // TODO
require(this is ConeKotlinType)
return attributes.exact != null
}
override fun KotlinTypeMarker.hasNoInferAnnotation(): Boolean {
return false // TODO
require(this is ConeKotlinType)
return attributes.noInfer != null
}
override fun TypeVariableMarker.freshTypeConstructor(): TypeConstructorMarker {