[FIR] Minor. Add util functions for checks that type is builtin
This commit is contained in:
@@ -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
|
||||||
+2
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirAbstractElement
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
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.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||||
@@ -24,7 +25,7 @@ sealed class FirImplicitBuiltinTypeRef(
|
|||||||
override val annotations: List<FirAnnotationCall>
|
override val annotations: List<FirAnnotationCall>
|
||||||
get() = emptyList()
|
get() = emptyList()
|
||||||
|
|
||||||
override val type: ConeKotlinType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), typeArguments, isNullable)
|
override val type: ConeClassLikeType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), typeArguments, isNullable)
|
||||||
}
|
}
|
||||||
|
|
||||||
class FirImplicitUnitTypeRef(
|
class FirImplicitUnitTypeRef(
|
||||||
|
|||||||
Reference in New Issue
Block a user