[FIR] Introduce & use FirTypeRef.coneType

This commit is contained in:
Mikhail Glukhikh
2020-06-30 11:23:50 +03:00
parent 0392fe75fc
commit d846a22e33
55 changed files with 162 additions and 193 deletions
@@ -15,12 +15,12 @@ import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
private fun FirAnnotationCall.toAnnotationLookupTag(): ConeClassLikeLookupTag =
((annotationTypeRef as FirResolvedTypeRef).type as ConeClassLikeType).lookupTag
(annotationTypeRef.coneType as ConeClassLikeType).lookupTag
internal fun FirAnnotationCall.toAnnotationClassId(): ClassId =
toAnnotationLookupTag().classId
@@ -488,13 +488,11 @@ class FirElementSerializer private constructor(
}
if (parameter.isVararg) {
val varargElementType = parameter.returnTypeRef.coneTypeSafe<ConeKotlinType>()?.varargElementType(session)
if (varargElementType != null) {
if (useTypeTable()) {
builder.varargElementTypeId = typeId(varargElementType)
} else {
builder.setVarargElementType(typeProto(varargElementType))
}
val varargElementType = parameter.returnTypeRef.coneType.varargElementType(session)
if (useTypeTable()) {
builder.varargElementTypeId = typeId(varargElementType)
} else {
builder.setVarargElementType(typeProto(varargElementType))
}
}
@@ -544,7 +542,7 @@ class FirElementSerializer private constructor(
fun typeId(type: ConeKotlinType): Int = typeTable[typeProto(type)]
internal fun typeProto(typeRef: FirTypeRef): ProtoBuf.Type.Builder {
return typeProto((typeRef as FirResolvedTypeRef).type)
return typeProto(typeRef.coneType)
}
internal fun typeProto(type: ConeKotlinType): ProtoBuf.Type.Builder {