From c0634217e170d802eec369ea1ab7ca0f2fea6cb3 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 26 Jun 2020 11:46:50 +0300 Subject: [PATCH] Revert "[FIR] Add extracting `@Exact` and `@NoInfer` attributes from annotations" This reverts commit e4c8c14e --- .../kotlin/fir/types/CompilerConeAttributes.kt | 7 ------- .../jetbrains/kotlin/fir/resolve/ResolveUtils.kt | 14 ++++---------- .../resolve/providers/impl/FirTypeResolverImpl.kt | 15 +-------------- 3 files changed, 5 insertions(+), 31 deletions(-) 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 index 8ae94c9d25a..258c89c0a5d 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -5,15 +5,10 @@ package org.jetbrains.kotlin.fir.types -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name import kotlin.reflect.KClass object CompilerConeAttributes { object Exact : ConeAttribute() { - val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.internal"), Name.identifier("Exact")) - override fun union(other: Exact?): Exact? = null override fun intersect(other: Exact?): Exact? = null override fun isSubtypeOf(other: Exact?): Boolean = true @@ -22,8 +17,6 @@ object CompilerConeAttributes { } object NoInfer : ConeAttribute() { - val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.internal"), Name.identifier("NoInfer")) - override fun union(other: NoInfer?): NoInfer? = null override fun intersect(other: NoInfer?): NoInfer? = null override fun isSubtypeOf(other: NoInfer?): Boolean = true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index ad029c11f92..058bd798be7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -165,24 +165,19 @@ fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): FirClassifierS fun ConeTypeParameterLookupTag.toSymbol(): FirTypeParameterSymbol = this.symbol as FirTypeParameterSymbol -fun FirClassifierSymbol<*>.constructType( - typeArguments: Array, - isNullable: Boolean, - attributes: ConeAttributes = ConeAttributes.Empty -): ConeLookupTagBasedType { +fun FirClassifierSymbol<*>.constructType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { return when (this) { is FirTypeParameterSymbol -> { - ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable, attributes) + ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable) } is FirClassSymbol -> { - ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable, attributes) + ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable) } is FirTypeAliasSymbol -> { ConeClassLikeTypeImpl( this.toLookupTag(), typeArguments = typeArguments, isNullable = isNullable, - attributes = attributes ) } else -> error("!") @@ -196,9 +191,8 @@ fun FirClassifierSymbol<*>.constructType( parts: List, isNullable: Boolean, symbolOriginSession: FirSession, - attributes: ConeAttributes = ConeAttributes.Empty ): ConeKotlinType = - constructType(parts.toTypeProjections(), isNullable, attributes) + constructType(parts.toTypeProjections(), isNullable) .also { val lookupTag = it.lookupTag if (lookupTag is ConeClassLikeLookupTagImpl && this is FirClassLikeSymbol<*>) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt index 72cd28a363c..730d7aabad8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt @@ -84,20 +84,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver { if (symbol == null) { return ConeKotlinErrorType("Symbol not found, for `${typeRef.render()}`") } - return symbol.constructType(typeRef.qualifier, typeRef.isMarkedNullable, symbolOriginSession = session, typeRef.computeTypeAttributes()) - } - - private fun FirTypeRef.computeTypeAttributes(): ConeAttributes { - if (annotations.isEmpty()) return ConeAttributes.Empty - val attributes = mutableListOf>() - for (annotation in annotations) { - val type = annotation.annotationTypeRef.coneTypeSafe() ?: continue - when (type.lookupTag.classId) { - CompilerConeAttributes.Exact.ANNOTATION_CLASS_ID -> attributes += CompilerConeAttributes.Exact - CompilerConeAttributes.NoInfer.ANNOTATION_CLASS_ID -> attributes += CompilerConeAttributes.NoInfer - } - } - return ConeAttributes.create(attributes) + return symbol.constructType(typeRef.qualifier, typeRef.isMarkedNullable, symbolOriginSession = session) }