[Commonizer] Extract creation of CirProperty from CirPropertyFactory
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.descriptors.commonizer.cir
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
|
||||
interface CirProperty : CirFunctionOrProperty, CirLiftedUpDeclaration {
|
||||
val isExternal: Boolean
|
||||
val isVar: Boolean
|
||||
@@ -16,4 +20,74 @@ interface CirProperty : CirFunctionOrProperty, CirLiftedUpDeclaration {
|
||||
val backingFieldAnnotations: List<CirAnnotation>
|
||||
val delegateFieldAnnotations: List<CirAnnotation>
|
||||
val compileTimeInitializer: CirConstantValue<*>
|
||||
|
||||
companion object {
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun create(
|
||||
annotations: List<CirAnnotation>,
|
||||
name: CirName,
|
||||
typeParameters: List<CirTypeParameter>,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
containingClass: CirContainingClass?,
|
||||
isExternal: Boolean,
|
||||
extensionReceiver: CirExtensionReceiver?,
|
||||
returnType: CirType,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
isVar: Boolean,
|
||||
isLateInit: Boolean,
|
||||
isConst: Boolean,
|
||||
isDelegate: Boolean,
|
||||
getter: CirPropertyGetter?,
|
||||
setter: CirPropertySetter?,
|
||||
backingFieldAnnotations: List<CirAnnotation>,
|
||||
delegateFieldAnnotations: List<CirAnnotation>,
|
||||
compileTimeInitializer: CirConstantValue<*>
|
||||
): CirProperty = CirPropertyImpl(
|
||||
annotations = annotations,
|
||||
name = name,
|
||||
typeParameters = typeParameters,
|
||||
visibility = visibility,
|
||||
modality = modality,
|
||||
containingClass = containingClass,
|
||||
isExternal = isExternal,
|
||||
extensionReceiver = extensionReceiver,
|
||||
returnType = returnType,
|
||||
kind = kind,
|
||||
isVar = isVar,
|
||||
isLateInit = isLateInit,
|
||||
isConst = isConst,
|
||||
isDelegate = isDelegate,
|
||||
getter = getter,
|
||||
setter = setter,
|
||||
backingFieldAnnotations = backingFieldAnnotations,
|
||||
delegateFieldAnnotations = delegateFieldAnnotations,
|
||||
compileTimeInitializer = compileTimeInitializer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class CirPropertyImpl(
|
||||
override val annotations: List<CirAnnotation>,
|
||||
override val name: CirName,
|
||||
override val typeParameters: List<CirTypeParameter>,
|
||||
override val visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
override val containingClass: CirContainingClass?,
|
||||
override val isExternal: Boolean,
|
||||
override val extensionReceiver: CirExtensionReceiver?,
|
||||
override val returnType: CirType,
|
||||
override val kind: CallableMemberDescriptor.Kind,
|
||||
override val isVar: Boolean,
|
||||
override val isLateInit: Boolean,
|
||||
override var isConst: Boolean,
|
||||
override val isDelegate: Boolean,
|
||||
override val getter: CirPropertyGetter?,
|
||||
override val setter: CirPropertySetter?,
|
||||
override val backingFieldAnnotations: List<CirAnnotation>,
|
||||
override val delegateFieldAnnotations: List<CirAnnotation>,
|
||||
override val compileTimeInitializer: CirConstantValue<*>
|
||||
) : CirProperty {
|
||||
// const property in "common" fragment is already lifted up
|
||||
override val isLiftedUp get() = isConst
|
||||
}
|
||||
|
||||
+5
-51
@@ -9,11 +9,10 @@ import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmProperty
|
||||
import kotlinx.metadata.klib.annotations
|
||||
import kotlinx.metadata.klib.compileTimeValue
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirPropertyImpl
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirContainingClass
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirProperty
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeCallableKind
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeModality
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeVisibility
|
||||
@@ -28,7 +27,7 @@ object CirPropertyFactory {
|
||||
)
|
||||
} else CirConstantValue.NullValue
|
||||
|
||||
return create(
|
||||
return CirProperty.create(
|
||||
annotations = CirAnnotationFactory.createAnnotations(source.flags, typeResolver, source::annotations),
|
||||
name = name,
|
||||
typeParameters = source.typeParameters.compactMap { CirTypeParameterFactory.create(it, typeResolver) },
|
||||
@@ -50,49 +49,4 @@ object CirPropertyFactory {
|
||||
compileTimeInitializer = compileTimeInitializer
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun create(
|
||||
annotations: List<CirAnnotation>,
|
||||
name: CirName,
|
||||
typeParameters: List<CirTypeParameter>,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
containingClass: CirContainingClass?,
|
||||
isExternal: Boolean,
|
||||
extensionReceiver: CirExtensionReceiver?,
|
||||
returnType: CirType,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
isVar: Boolean,
|
||||
isLateInit: Boolean,
|
||||
isConst: Boolean,
|
||||
isDelegate: Boolean,
|
||||
getter: CirPropertyGetter?,
|
||||
setter: CirPropertySetter?,
|
||||
backingFieldAnnotations: List<CirAnnotation>,
|
||||
delegateFieldAnnotations: List<CirAnnotation>,
|
||||
compileTimeInitializer: CirConstantValue<*>
|
||||
): CirProperty {
|
||||
return CirPropertyImpl(
|
||||
annotations = annotations,
|
||||
name = name,
|
||||
typeParameters = typeParameters,
|
||||
visibility = visibility,
|
||||
modality = modality,
|
||||
containingClass = containingClass,
|
||||
isExternal = isExternal,
|
||||
extensionReceiver = extensionReceiver,
|
||||
returnType = returnType,
|
||||
kind = kind,
|
||||
isVar = isVar,
|
||||
isLateInit = isLateInit,
|
||||
isConst = isConst,
|
||||
isDelegate = isDelegate,
|
||||
getter = getter,
|
||||
setter = setter,
|
||||
backingFieldAnnotations = backingFieldAnnotations,
|
||||
delegateFieldAnnotations = delegateFieldAnnotations,
|
||||
compileTimeInitializer = compileTimeInitializer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.descriptors.commonizer.cir.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
|
||||
data class CirPropertyImpl(
|
||||
override val annotations: List<CirAnnotation>,
|
||||
override val name: CirName,
|
||||
override val typeParameters: List<CirTypeParameter>,
|
||||
override val visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
override val containingClass: CirContainingClass?,
|
||||
override val isExternal: Boolean,
|
||||
override val extensionReceiver: CirExtensionReceiver?,
|
||||
override val returnType: CirType,
|
||||
override val kind: CallableMemberDescriptor.Kind,
|
||||
override val isVar: Boolean,
|
||||
override val isLateInit: Boolean,
|
||||
override var isConst: Boolean,
|
||||
override val isDelegate: Boolean,
|
||||
override val getter: CirPropertyGetter?,
|
||||
override val setter: CirPropertySetter?,
|
||||
override val backingFieldAnnotations: List<CirAnnotation>,
|
||||
override val delegateFieldAnnotations: List<CirAnnotation>,
|
||||
override val compileTimeInitializer: CirConstantValue<*>
|
||||
) : CirProperty {
|
||||
// const property in "common" fragment is already lifted up
|
||||
override val isLiftedUp get() = isConst
|
||||
}
|
||||
+1
-2
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirProperty
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPropertyGetter
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirPropertyFactory
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.core.PropertyCommonizer.ConstCommonizationState.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers
|
||||
|
||||
@@ -28,7 +27,7 @@ class PropertyCommonizer(classifiers: CirKnownClassifiers) : AbstractFunctionOrP
|
||||
constCommonizationState.properties.forEach { it.isConst = false }
|
||||
}
|
||||
|
||||
return CirPropertyFactory.create(
|
||||
return CirProperty.create(
|
||||
annotations = emptyList(),
|
||||
name = name,
|
||||
typeParameters = typeParameters.result,
|
||||
|
||||
Reference in New Issue
Block a user