diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt new file mode 100644 index 00000000000..b4b062a5668 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2019 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 org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef +import org.jetbrains.kotlin.name.ClassId + +val FirTypeRef.isAny: Boolean get() = isBuiltinType(StandardClassIds.Any, false) +val FirTypeRef.isNullableAny: Boolean get() = isBuiltinType(StandardClassIds.Any, true) +val FirTypeRef.isNothing: Boolean get() = isBuiltinType(StandardClassIds.Nothing, false) +val FirTypeRef.isNullableNothing: Boolean get() = isBuiltinType(StandardClassIds.Nothing, true) +val FirTypeRef.isUnit: Boolean get() = isBuiltinType(StandardClassIds.Unit, false) + +private fun FirTypeRef.isBuiltinType(classId: ClassId, isNullable: Boolean): Boolean = + this is FirImplicitBuiltinTypeRef && type.lookupTag.classId == classId && type.isNullable == isNullable \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt index d4074915897..b529fde5896 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirAbstractElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef @@ -24,7 +25,7 @@ sealed class FirImplicitBuiltinTypeRef( override val annotations: List get() = emptyList() - override val type: ConeKotlinType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), typeArguments, isNullable) + override val type: ConeClassLikeType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), typeArguments, isNullable) } class FirImplicitUnitTypeRef(