Replace ConeFunctionType with ConeClassType
This commit is contained in:
committed by
Mikhail Glukhikh
parent
93cb23a498
commit
b38f3a1272
@@ -106,13 +106,6 @@ abstract class ConeTypeParameterType : ConeLookupTagBasedType() {
|
||||
}
|
||||
|
||||
|
||||
abstract class ConeFunctionType : ConeClassLikeType() {
|
||||
|
||||
abstract override val lookupTag: ConeClassLikeLookupTag
|
||||
abstract val receiverType: ConeKotlinType?
|
||||
abstract val parameterTypes: List<ConeKotlinType>
|
||||
abstract val returnType: ConeKotlinType
|
||||
}
|
||||
|
||||
class ConeFlexibleType(val lowerBound: ConeLookupTagBasedType, val upperBound: ConeLookupTagBasedType) : ConeKotlinType(),
|
||||
FlexibleTypeMarker {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.types.ConeFunctionType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||
|
||||
class ConeFunctionTypeImpl(
|
||||
override val receiverType: ConeKotlinType?,
|
||||
override val parameterTypes: List<ConeKotlinType>,
|
||||
override val returnType: ConeKotlinType,
|
||||
override val lookupTag: ConeClassLikeLookupTag,
|
||||
isNullable: Boolean
|
||||
) : ConeFunctionType() {
|
||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
||||
get() = EMPTY_ARRAY
|
||||
|
||||
override val nullability: ConeNullability = ConeNullability.create(isNullable)
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeAbbreviatedTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeFunctionTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
@@ -113,7 +112,6 @@ fun <T : ConeKotlinType> T.withNullability(nullability: ConeNullability): T {
|
||||
typeArguments,
|
||||
nullability.isNullable
|
||||
) as T
|
||||
is ConeFunctionTypeImpl -> ConeFunctionTypeImpl(receiverType, parameterTypes, returnType, lookupTag, nullability.isNullable) as T
|
||||
is ConeTypeParameterTypeImpl -> ConeTypeParameterTypeImpl(lookupTag, nullability.isNullable) as T
|
||||
is ConeFlexibleType -> ConeFlexibleType(lowerBound.withNullability(nullability), upperBound.withNullability(nullability)) as T
|
||||
is ConeTypeVariableType -> ConeTypeVariableType(nullability, lookupTag) as T
|
||||
@@ -135,7 +133,6 @@ fun <T : ConeKotlinType> T.withArguments(arguments: Array<ConeKotlinTypeProjecti
|
||||
arguments,
|
||||
nullability.isNullable
|
||||
) as T
|
||||
//is ConeFunctionTypeImpl -> ConeFunctionTypeImpl(receiverType, parameterTypes, returnType, lookupTag, nullability.isNullable) as T
|
||||
else -> error("Not supported: $this: ${this.render()}")
|
||||
}
|
||||
}
|
||||
|
||||
+13
-7
@@ -84,6 +84,18 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver {
|
||||
return symbol.constructType(typeRef.qualifier, typeRef.isMarkedNullable)
|
||||
}
|
||||
|
||||
|
||||
private fun createFunctionalType(typeRef: FirFunctionTypeRef): ConeClassType {
|
||||
val parameters =
|
||||
listOfNotNull((typeRef.receiverTypeRef as FirResolvedTypeRef?)?.type) +
|
||||
typeRef.valueParameters.map { it.returnTypeRef.coneTypeUnsafe<ConeKotlinType>() }
|
||||
return ConeClassTypeImpl(
|
||||
resolveBuiltInQualified(KotlinBuiltIns.getFunctionClassId(typeRef.parametersCount), session).toLookupTag(),
|
||||
parameters.toTypedArray(),
|
||||
typeRef.isMarkedNullable
|
||||
)
|
||||
}
|
||||
|
||||
override fun resolveType(
|
||||
typeRef: FirTypeRef,
|
||||
scope: FirScope,
|
||||
@@ -98,13 +110,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver {
|
||||
ConeKotlinErrorType(typeRef.reason)
|
||||
}
|
||||
is FirFunctionTypeRef -> {
|
||||
ConeFunctionTypeImpl(
|
||||
(typeRef.receiverTypeRef as FirResolvedTypeRef?)?.type,
|
||||
typeRef.valueParameters.map { it.returnTypeRef.coneTypeUnsafe() },
|
||||
typeRef.returnTypeRef.coneTypeUnsafe(),
|
||||
resolveBuiltInQualified(KotlinBuiltIns.getFunctionClassId(typeRef.parametersCount), session).toLookupTag(),
|
||||
typeRef.isMarkedNullable
|
||||
)
|
||||
createFunctionalType(typeRef)
|
||||
}
|
||||
is FirImplicitBuiltinTypeRef -> {
|
||||
resolveToSymbol(typeRef, scope, position)!!.constructType(emptyList(), isNullable = false)
|
||||
|
||||
+1
-2
@@ -58,11 +58,10 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor {
|
||||
is ConeClassErrorType -> return null
|
||||
is ConeClassType -> this.substituteArguments()
|
||||
is ConeAbbreviatedType -> this.substituteArguments()
|
||||
is ConeFunctionType -> TODO()
|
||||
is ConeTypeParameterType -> return null
|
||||
is ConeTypeVariableType -> return null
|
||||
is ConeFlexibleType -> this.substituteBounds()
|
||||
is ConeCapturedType -> TODO()
|
||||
is ConeCapturedType -> return null
|
||||
is ConeDefinitelyNotNullType -> this.substituteOriginal()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeAbbreviatedTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeFunctionTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
import org.jetbrains.kotlin.types.checker.convertVariance
|
||||
@@ -119,13 +118,6 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
|
||||
typeArguments,
|
||||
nullable
|
||||
)
|
||||
is ConeFunctionType -> ConeFunctionTypeImpl(
|
||||
receiverType,
|
||||
parameterTypes,
|
||||
returnType,
|
||||
lookupTag,
|
||||
nullable
|
||||
)
|
||||
else -> error("!")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,18 +57,6 @@ fun ConeKotlinType.render(): String {
|
||||
is ConeTypeParameterType -> {
|
||||
lookupTag.name.asString()
|
||||
}
|
||||
is ConeFunctionType -> {
|
||||
buildString {
|
||||
receiverType?.let {
|
||||
append(it.render())
|
||||
append(".")
|
||||
}
|
||||
append("(")
|
||||
parameterTypes.joinTo(this) { it.render() }
|
||||
append(") -> ")
|
||||
append(returnType.render())
|
||||
}
|
||||
}
|
||||
is ConeFlexibleType -> {
|
||||
buildString {
|
||||
append("ft<")
|
||||
|
||||
Reference in New Issue
Block a user