[FIR2IR] Remove redundant ConversionTypeContext.inSetter()
This commit is contained in:
committed by
Space Team
parent
f08da86cfd
commit
cda7dc4a3a
@@ -109,11 +109,7 @@ internal enum class ConversionTypeOrigin {
|
|||||||
SETTER
|
SETTER
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConversionTypeContext internal constructor(internal val origin: ConversionTypeOrigin) {
|
class ConversionTypeContext private constructor(internal val origin: ConversionTypeOrigin) {
|
||||||
fun inSetter() = ConversionTypeContext(
|
|
||||||
origin = ConversionTypeOrigin.SETTER
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal val DEFAULT = ConversionTypeContext(
|
internal val DEFAULT = ConversionTypeContext(
|
||||||
origin = ConversionTypeOrigin.DEFAULT
|
origin = ConversionTypeOrigin.DEFAULT
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Fir2IrClassifierStorage(
|
|||||||
getCachedIrTypeParameter(original)
|
getCachedIrTypeParameter(original)
|
||||||
?: createIrTypeParameterWithoutBounds(original, index, irOwnerSymbol)
|
?: createIrTypeParameterWithoutBounds(original, index, irOwnerSymbol)
|
||||||
if (owner is FirProperty && owner.isVar) {
|
if (owner is FirProperty && owner.isVar) {
|
||||||
val context = ConversionTypeContext.DEFAULT.inSetter()
|
val context = ConversionTypeContext.IN_SETTER
|
||||||
getCachedIrTypeParameter(original, context)
|
getCachedIrTypeParameter(original, context)
|
||||||
?: createIrTypeParameterWithoutBounds(original, index, irOwnerSymbol, context)
|
?: createIrTypeParameterWithoutBounds(original, index, irOwnerSymbol, context)
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -20,7 +20,10 @@ import org.jetbrains.kotlin.fir.declarations.utils.*
|
|||||||
import org.jetbrains.kotlin.fir.descriptors.FirBuiltInsPackageFragment
|
import org.jetbrains.kotlin.fir.descriptors.FirBuiltInsPackageFragment
|
||||||
import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
|
import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
|
||||||
import org.jetbrains.kotlin.fir.descriptors.FirPackageFragmentDescriptor
|
import org.jetbrains.kotlin.fir.descriptors.FirPackageFragmentDescriptor
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
|
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
|
||||||
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
|
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
|
||||||
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyConstructor
|
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyConstructor
|
||||||
@@ -54,7 +57,10 @@ import org.jetbrains.kotlin.ir.types.IrErrorType
|
|||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.name.*
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.name.NameUtils
|
||||||
|
import org.jetbrains.kotlin.name.SpecialNames
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.runUnless
|
import org.jetbrains.kotlin.utils.addToStdlib.runUnless
|
||||||
@@ -333,11 +339,9 @@ class Fir2IrDeclarationStorage(
|
|||||||
setTypeParameters(function)
|
setTypeParameters(function)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val typeContext = ConversionTypeContext(
|
val typeContext = if (forSetter) ConversionTypeContext.IN_SETTER else ConversionTypeContext.DEFAULT
|
||||||
origin = if (forSetter) ConversionTypeOrigin.SETTER else ConversionTypeOrigin.DEFAULT
|
|
||||||
)
|
|
||||||
if (function is FirDefaultPropertySetter) {
|
if (function is FirDefaultPropertySetter) {
|
||||||
val type = function.valueParameters.first().returnTypeRef.toIrType(ConversionTypeContext.DEFAULT.inSetter())
|
val type = function.valueParameters.first().returnTypeRef.toIrType(ConversionTypeContext.IN_SETTER)
|
||||||
declareDefaultSetterParameter(type)
|
declareDefaultSetterParameter(type)
|
||||||
} else if (function != null) {
|
} else if (function != null) {
|
||||||
val contextReceivers = function.contextReceiversForFunctionOrContainingProperty()
|
val contextReceivers = function.contextReceiversForFunctionOrContainingProperty()
|
||||||
@@ -731,9 +735,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
with(classifierStorage) {
|
with(classifierStorage) {
|
||||||
setTypeParameters(
|
setTypeParameters(
|
||||||
property, ConversionTypeContext(
|
property, if (isSetter) ConversionTypeContext.IN_SETTER else ConversionTypeContext.DEFAULT
|
||||||
origin = if (isSetter) ConversionTypeOrigin.SETTER else ConversionTypeOrigin.DEFAULT
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// NB: we should enter accessor' scope before declaring its parameters
|
// NB: we should enter accessor' scope before declaring its parameters
|
||||||
@@ -741,7 +743,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
enterScope(this)
|
enterScope(this)
|
||||||
if (propertyAccessor == null && isSetter) {
|
if (propertyAccessor == null && isSetter) {
|
||||||
declareDefaultSetterParameter(
|
declareDefaultSetterParameter(
|
||||||
property.returnTypeRef.toIrType(ConversionTypeContext.DEFAULT.inSetter())
|
property.returnTypeRef.toIrType(ConversionTypeContext.IN_SETTER)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
bindAndDeclareParameters(
|
bindAndDeclareParameters(
|
||||||
|
|||||||
@@ -182,9 +182,7 @@ class Fir2IrLazyProperty(
|
|||||||
correspondingPropertySymbol = this@Fir2IrLazyProperty.symbol
|
correspondingPropertySymbol = this@Fir2IrLazyProperty.symbol
|
||||||
with(classifierStorage) {
|
with(classifierStorage) {
|
||||||
setTypeParameters(
|
setTypeParameters(
|
||||||
this@Fir2IrLazyProperty.fir, ConversionTypeContext(
|
this@Fir2IrLazyProperty.fir, ConversionTypeContext.DEFAULT
|
||||||
origin = ConversionTypeOrigin.DEFAULT
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,9 +214,7 @@ class Fir2IrLazyProperty(
|
|||||||
correspondingPropertySymbol = this@Fir2IrLazyProperty.symbol
|
correspondingPropertySymbol = this@Fir2IrLazyProperty.symbol
|
||||||
with(classifierStorage) {
|
with(classifierStorage) {
|
||||||
setTypeParameters(
|
setTypeParameters(
|
||||||
this@Fir2IrLazyProperty.fir, ConversionTypeContext(
|
this@Fir2IrLazyProperty.fir, ConversionTypeContext.IN_SETTER
|
||||||
origin = ConversionTypeOrigin.SETTER
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,5 +118,5 @@ class Fir2IrLazyPropertyAccessor(
|
|||||||
override val containerSource: DeserializedContainerSource?
|
override val containerSource: DeserializedContainerSource?
|
||||||
get() = firParentProperty.containerSource
|
get() = firParentProperty.containerSource
|
||||||
|
|
||||||
private val conversionTypeContext = if (isSetter) ConversionTypeContext.DEFAULT.inSetter() else ConversionTypeContext.DEFAULT
|
private val conversionTypeContext = if (isSetter) ConversionTypeContext.IN_SETTER else ConversionTypeContext.DEFAULT
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user