[Commonizer] Extract creation of CirExtensionReceiver from CirExtensionReceiverFactory
This commit is contained in:
+16
@@ -7,4 +7,20 @@ package org.jetbrains.kotlin.descriptors.commonizer.cir
|
||||
|
||||
interface CirExtensionReceiver : CirHasAnnotations {
|
||||
val type: CirType
|
||||
|
||||
companion object {
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun create(
|
||||
annotations: List<CirAnnotation>,
|
||||
type: CirType
|
||||
): CirExtensionReceiver = CirExtensionReceiverImpl(
|
||||
annotations = annotations,
|
||||
type = type
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class CirExtensionReceiverImpl(
|
||||
override val annotations: List<CirAnnotation>,
|
||||
override val type: CirType
|
||||
) : CirExtensionReceiver
|
||||
|
||||
+1
-15
@@ -6,25 +6,11 @@
|
||||
package org.jetbrains.kotlin.descriptors.commonizer.cir.factory
|
||||
|
||||
import kotlinx.metadata.KmType
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirExtensionReceiverImpl
|
||||
|
||||
object CirExtensionReceiverFactory {
|
||||
fun create(receiverParameterType: KmType, typeResolver: CirTypeResolver): CirExtensionReceiver = create(
|
||||
fun create(receiverParameterType: KmType, typeResolver: CirTypeResolver): CirExtensionReceiver = CirExtensionReceiver.create(
|
||||
annotations = emptyList(), // TODO nowhere to read receiver annotations from, see KT-42490
|
||||
type = CirTypeFactory.create(receiverParameterType, typeResolver)
|
||||
)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun create(
|
||||
annotations: List<CirAnnotation>,
|
||||
type: CirType
|
||||
): CirExtensionReceiver {
|
||||
return CirExtensionReceiverImpl(
|
||||
annotations = annotations,
|
||||
type = type
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
-15
@@ -1,15 +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.commonizer.cir.CirAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||
|
||||
data class CirExtensionReceiverImpl(
|
||||
override val annotations: List<CirAnnotation>,
|
||||
override val type: CirType
|
||||
) : CirExtensionReceiver
|
||||
+1
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirExtensionReceiverFactory
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers
|
||||
|
||||
class ExtensionReceiverCommonizer(classifiers: CirKnownClassifiers) :
|
||||
@@ -15,7 +14,7 @@ class ExtensionReceiverCommonizer(classifiers: CirKnownClassifiers) :
|
||||
wrappedCommonizerFactory = { TypeCommonizer(classifiers) },
|
||||
extractor = { it.type },
|
||||
builder = { receiverType ->
|
||||
CirExtensionReceiverFactory.create(
|
||||
CirExtensionReceiver.create(
|
||||
annotations = emptyList(),
|
||||
type = receiverType
|
||||
)
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirExtensionReceiverFactory
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.MOCK_CLASSIFIERS
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
||||
import org.junit.Test
|
||||
@@ -51,7 +50,7 @@ class ExtensionReceiverCommonizerTest : AbstractCommonizerTest<CirExtensionRecei
|
||||
override fun createCommonizer() = ExtensionReceiverCommonizer(MOCK_CLASSIFIERS)
|
||||
}
|
||||
|
||||
private fun mockExtensionReceiver(receiverClassId: String) = CirExtensionReceiverFactory.create(
|
||||
private fun mockExtensionReceiver(receiverClassId: String) = CirExtensionReceiver.create(
|
||||
annotations = emptyList(),
|
||||
type = mockClassType(receiverClassId)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user