From e43932f1479d43fc4516faae8776174f724f74da Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 4 Jun 2020 12:39:41 +0300 Subject: [PATCH] [FIR] Add attributes for `@Exact` and `@NoInfer` --- .../fir/types/CompilerConeAttributes.kt | 29 +++++++++++++++++++ .../kotlin/fir/types/ConeInferenceContext.kt | 6 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt new file mode 100644 index 00000000000..258c89c0a5d --- /dev/null +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -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() { + 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 = Exact::class + } + + object NoInfer : ConeAttribute() { + 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 = NoInfer::class + } +} + +val ConeAttributes.exact: CompilerConeAttributes.Exact? by ConeAttributes.attributeAccessor() +val ConeAttributes.noInfer: CompilerConeAttributes.NoInfer? by ConeAttributes.attributeAccessor() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index d372a1ba460..8aa73e11c94 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -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 {