[Commonizer] Split different aspects of CIR
- Entity declaration - Entity implementation - Creation of new entities from descriptors
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind.ANNOTATION_CLASS
|
import org.jetbrains.kotlin.descriptors.ClassKind.ANNOTATION_CLASS
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirAnnotation
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.concat
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.concat
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
||||||
|
|||||||
+3
-3
@@ -7,13 +7,13 @@ package org.jetbrains.kotlin.descriptors.commonizer.builder
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirTypeParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase
|
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.*
|
import org.jetbrains.kotlin.resolve.DescriptorFactory.createPrimaryConstructorForObject
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.computeSealedSubclasses
|
import org.jetbrains.kotlin.resolve.descriptorUtil.computeSealedSubclasses
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.builder.CommonizedMemberScope.Companion.plusAssign
|
import org.jetbrains.kotlin.descriptors.commonizer.builder.CommonizedMemberScope.Companion.plusAssign
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.builder.CommonizedPackageFragmentProvider.Companion.plusAssign
|
import org.jetbrains.kotlin.descriptors.commonizer.builder.CommonizedPackageFragmentProvider.Companion.plusAssign
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.builder.CommonizedMemberScope
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.asListContaining
|
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.asListContaining
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.noContainingDeclarations
|
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.noContainingDeclarations
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.noReturningDeclarations
|
import org.jetbrains.kotlin.descriptors.commonizer.builder.DeclarationsBuilderVisitor1.Companion.noReturningDeclarations
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -7,8 +7,9 @@ package org.jetbrains.kotlin.descriptors.commonizer.builder
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirSimpleTypeKind.Companion.areCompatible
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind.Companion.areCompatible
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.cirSimpleTypeKind
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.resolveClassOrTypeAliasByFqName
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.resolveClassOrTypeAliasByFqName
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
@@ -160,7 +161,7 @@ internal fun findClassOrTypeAlias(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkClassifier(classifier: ClassifierDescriptor, kind: CirSimpleTypeKind, strict: Boolean) {
|
private fun checkClassifier(classifier: ClassifierDescriptor, kind: CirSimpleTypeKind, strict: Boolean) {
|
||||||
val classifierKind = CirSimpleTypeKind.determineKind(classifier)
|
val classifierKind = classifier.cirSimpleTypeKind
|
||||||
|
|
||||||
if (strict) {
|
if (strict) {
|
||||||
check(kind == classifierKind) {
|
check(kind == classifierKind) {
|
||||||
|
|||||||
+5
-1
@@ -9,7 +9,11 @@ import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClassConstructor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassConstructorNode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassNode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -9,9 +9,9 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.StatsCollector
|
import org.jetbrains.kotlin.descriptors.commonizer.StatsCollector
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirRootNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirRootNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.dimension
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.dimension
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.createKotlinNativeForwardDeclarationsModule
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.createKotlinNativeForwardDeclarationsModule
|
||||||
|
|||||||
+9
-9
@@ -9,9 +9,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunction
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFunction
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunctionNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirFunctionNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||||
|
|
||||||
@@ -52,12 +52,12 @@ private fun CirFunction.buildDescriptor(
|
|||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
)
|
)
|
||||||
|
|
||||||
functionDescriptor.isOperator = isOperator
|
functionDescriptor.isOperator = modifiers.isOperator
|
||||||
functionDescriptor.isInfix = isInfix
|
functionDescriptor.isInfix = modifiers.isInfix
|
||||||
functionDescriptor.isInline = isInline
|
functionDescriptor.isInline = modifiers.isInline
|
||||||
functionDescriptor.isTailrec = isTailrec
|
functionDescriptor.isTailrec = modifiers.isTailrec
|
||||||
functionDescriptor.isSuspend = isSuspend
|
functionDescriptor.isSuspend = modifiers.isSuspend
|
||||||
functionDescriptor.isExternal = isExternal
|
functionDescriptor.isExternal = modifiers.isExternal
|
||||||
|
|
||||||
functionDescriptor.isExpect = isExpect
|
functionDescriptor.isExpect = isExpect
|
||||||
functionDescriptor.isActual = isActual
|
functionDescriptor.isActual = isActual
|
||||||
|
|||||||
+3
-3
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.builder
|
package org.jetbrains.kotlin.descriptors.commonizer.builder
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirModule
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirModule
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirModuleNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirModuleNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.commonizer.builder
|
package org.jetbrains.kotlin.descriptors.commonizer.builder
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirPackage
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackage
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirPackageNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirPackageNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||||
|
|||||||
+3
-3
@@ -9,9 +9,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirProperty
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirProperty
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirPropertyNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirPropertyNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.impl.FieldDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.FieldDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||||
|
|||||||
+4
-4
@@ -7,10 +7,10 @@ package org.jetbrains.kotlin.descriptors.commonizer.builder
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClass
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirTypeAlias
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirTypeAliasNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirTypeAliasNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.indexOfCommon
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.indexOfCommon
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
interface CirAnnotation {
|
||||||
|
val fqName: FqName
|
||||||
|
val constantValueArguments: Map<Name, ConstantValue<*>>
|
||||||
|
val annotationValueArguments: Map<Name, CirAnnotation>
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
interface CirClass :
|
||||||
|
CirAnnotatedDeclaration,
|
||||||
|
CirNamedDeclaration,
|
||||||
|
CirDeclarationWithTypeParameters,
|
||||||
|
CirDeclarationWithVisibility,
|
||||||
|
CirDeclarationWithModality {
|
||||||
|
|
||||||
|
val kind: ClassKind
|
||||||
|
var companion: FqName? // null means no companion object
|
||||||
|
val isCompanion: Boolean
|
||||||
|
val isData: Boolean
|
||||||
|
val isInline: Boolean
|
||||||
|
val isInner: Boolean
|
||||||
|
val isExternal: Boolean
|
||||||
|
val supertypes: MutableCollection<CirType>
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
|
||||||
|
interface CirClassConstructor :
|
||||||
|
CirAnnotatedDeclaration,
|
||||||
|
CirDeclarationWithTypeParameters,
|
||||||
|
CirDeclarationWithVisibility,
|
||||||
|
CirMaybeCallableMemberOfClass,
|
||||||
|
CirCallableMemberWithParameters {
|
||||||
|
|
||||||
|
val isPrimary: Boolean
|
||||||
|
val kind: CallableMemberDescriptor.Kind
|
||||||
|
override val containingClassDetails: CirContainingClassDetails // non-nullable
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
|
||||||
|
// TODO: inline?
|
||||||
|
data class CirContainingClassDetails(
|
||||||
|
val kind: ClassKind,
|
||||||
|
val modality: Modality,
|
||||||
|
val isData: Boolean
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
val DOES_NOT_MATTER = CirContainingClassDetails(
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
isData = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-8
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* 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.
|
* 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.mergedtree.ir
|
package org.jetbrains.kotlin.descriptors.commonizer.cir
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -40,17 +40,18 @@ interface CirDeclarationWithModality : CirDeclaration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CirMaybeCallableMemberOfClass : CirDeclaration {
|
interface CirMaybeCallableMemberOfClass : CirDeclaration {
|
||||||
val containingClassKind: ClassKind? // null assumes no containing class
|
val containingClassDetails: CirContainingClassDetails? // null assumes no containing class
|
||||||
val containingClassModality: Modality? // null assumes no containing class
|
|
||||||
val containingClassIsData: Boolean? // null assumes no containing class
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CirDeclarationWithTypeParameters : CirDeclaration {
|
interface CirDeclarationWithTypeParameters : CirDeclaration {
|
||||||
val typeParameters: List<CirTypeParameter>
|
val typeParameters: List<CirTypeParameter>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CirCallableMemberWithParameters {
|
||||||
|
val valueParameters: List<CirValueParameter>
|
||||||
|
val hasStableParameterNames: Boolean
|
||||||
|
val hasSynthesizedParameterNames: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
/** Indicates presence of recursion in lazy calculations. */
|
/** Indicates presence of recursion in lazy calculations. */
|
||||||
interface CirRecursionMarker : CirDeclaration
|
interface CirRecursionMarker : CirDeclaration
|
||||||
|
|
||||||
@Suppress("unused", "NOTHING_TO_INLINE")
|
|
||||||
internal inline fun CirDeclaration.unsupported(): Nothing = error("This method should never be called")
|
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirExtensionReceiver {
|
||||||
|
val annotations: List<CirAnnotation>
|
||||||
|
val type: CirType
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirFunction : CirFunctionOrProperty, CirCallableMemberWithParameters {
|
||||||
|
val modifiers: CirFunctionModifiers
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
// TODO: inline?
|
||||||
|
data class CirFunctionModifiers(
|
||||||
|
var isOperator: Boolean,
|
||||||
|
var isInfix: Boolean,
|
||||||
|
var isInline: Boolean,
|
||||||
|
var isTailrec: Boolean,
|
||||||
|
var isSuspend: Boolean,
|
||||||
|
var isExternal: Boolean
|
||||||
|
)
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
|
|
||||||
|
interface CirFunctionOrProperty :
|
||||||
|
CirAnnotatedDeclaration,
|
||||||
|
CirNamedDeclaration,
|
||||||
|
CirDeclarationWithTypeParameters,
|
||||||
|
CirDeclarationWithVisibility,
|
||||||
|
CirDeclarationWithModality,
|
||||||
|
CirMaybeCallableMemberOfClass {
|
||||||
|
|
||||||
|
val isExternal: Boolean
|
||||||
|
val extensionReceiver: CirExtensionReceiver?
|
||||||
|
val returnType: CirType
|
||||||
|
val kind: CallableMemberDescriptor.Kind
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CirFunctionOrProperty.isNonAbstractMemberInInterface(): Boolean =
|
||||||
|
modality != Modality.ABSTRACT && containingClassDetails?.kind == ClassKind.INTERFACE
|
||||||
|
|
||||||
|
fun CirFunctionOrProperty.isVirtual(): Boolean =
|
||||||
|
visibility != Visibilities.PRIVATE
|
||||||
|
&& modality != Modality.FINAL
|
||||||
|
&& !(containingClassDetails?.modality == Modality.FINAL && containingClassDetails?.kind != ClassKind.ENUM_CLASS)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirModule : CirNamedDeclaration
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
interface CirPackage : CirDeclaration {
|
||||||
|
val fqName: FqName
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
interface CirProperty : CirFunctionOrProperty {
|
||||||
|
val isVar: Boolean
|
||||||
|
val isLateInit: Boolean
|
||||||
|
val isConst: Boolean
|
||||||
|
val isDelegate: Boolean
|
||||||
|
val getter: CirPropertyGetter?
|
||||||
|
val setter: CirPropertySetter?
|
||||||
|
val backingFieldAnnotations: List<CirAnnotation>? // null assumes no backing field
|
||||||
|
val delegateFieldAnnotations: List<CirAnnotation>? // null assumes no backing field
|
||||||
|
val compileTimeInitializer: ConstantValue<*>?
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirPropertyAccessor {
|
||||||
|
val annotations: List<CirAnnotation>
|
||||||
|
val isDefault: Boolean
|
||||||
|
val isExternal: Boolean
|
||||||
|
val isInline: Boolean
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirPropertyGetter : CirPropertyAccessor
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirPropertySetter : CirPropertyAccessor, CirDeclarationWithVisibility {
|
||||||
|
val parameterAnnotations: List<CirAnnotation>
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.BuiltInsProvider
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
||||||
|
|
||||||
|
interface CirRoot : CirDeclaration {
|
||||||
|
val target: Target
|
||||||
|
val builtInsClass: String
|
||||||
|
val builtInsProvider: BuiltInsProvider
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind.CLASS
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind.TYPE_ALIAS
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.types.AbbreviatedType
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
|
sealed class CirType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All attributes except for [expandedTypeConstructorId] are read from the abbreviation type: [AbbreviatedType.abbreviation].
|
||||||
|
* And [expandedTypeConstructorId] is read from the expanded type: [AbbreviatedType.expandedType].
|
||||||
|
*
|
||||||
|
* This is necessary to properly compare types for type aliases, where abbreviation type represents the type alias itself while
|
||||||
|
* expanded type represents right-hand side declaration that should be processed separately.
|
||||||
|
*
|
||||||
|
* There is no difference between "abbreviation" and "expanded" for types representing classes and type parameters.
|
||||||
|
* For details, see [CirTypeFactory].
|
||||||
|
*
|
||||||
|
* Note: Annotations at simple types are not preserved. After commonization all annotations assigned to types will be lost.
|
||||||
|
*/
|
||||||
|
abstract class CirSimpleType : CirType() {
|
||||||
|
abstract val kind: CirSimpleTypeKind
|
||||||
|
abstract val fqName: FqName
|
||||||
|
abstract val arguments: List<CirTypeProjection>
|
||||||
|
abstract val isMarkedNullable: Boolean
|
||||||
|
abstract val isDefinitelyNotNullType: Boolean
|
||||||
|
abstract val expandedTypeConstructorId: CirTypeConstructorId
|
||||||
|
abstract val fqNameWithTypeParameters: String
|
||||||
|
|
||||||
|
inline val isClassOrTypeAlias: Boolean get() = (kind == CLASS || kind == TYPE_ALIAS)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class CirSimpleTypeKind {
|
||||||
|
CLASS,
|
||||||
|
TYPE_ALIAS,
|
||||||
|
TYPE_PARAMETER;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun areCompatible(expect: CirSimpleTypeKind, actual: CirSimpleTypeKind): Boolean =
|
||||||
|
expect == actual || (expect == CLASS && actual == TYPE_ALIAS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class CirTypeConstructorId(val fqName: FqName, val numberOfTypeParameters: Int)
|
||||||
|
|
||||||
|
data class CirTypeProjection(val projectionKind: Variance, val isStarProjection: Boolean, val type: CirType)
|
||||||
|
|
||||||
|
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType()
|
||||||
|
|
||||||
|
val CirType.fqNameWithTypeParameters: String
|
||||||
|
get() = when (this) {
|
||||||
|
is CirSimpleType -> fqNameWithTypeParameters
|
||||||
|
is CirFlexibleType -> lowerBound.fqNameWithTypeParameters
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
interface CirTypeAlias :
|
||||||
|
CirAnnotatedDeclaration,
|
||||||
|
CirNamedDeclaration,
|
||||||
|
CirDeclarationWithTypeParameters,
|
||||||
|
CirDeclarationWithVisibility {
|
||||||
|
|
||||||
|
val underlyingType: CirSimpleType
|
||||||
|
val expandedType: CirSimpleType
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
|
interface CirTypeParameter {
|
||||||
|
val annotations: List<CirAnnotation>
|
||||||
|
val name: Name
|
||||||
|
val isReified: Boolean
|
||||||
|
val variance: Variance
|
||||||
|
val upperBounds: List<CirType>
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
interface CirValueParameter {
|
||||||
|
val annotations: List<CirAnnotation>
|
||||||
|
val name: Name
|
||||||
|
val returnType: CirType
|
||||||
|
val varargElementType: CirType?
|
||||||
|
val declaresDefaultValue: Boolean
|
||||||
|
val isCrossinline: Boolean
|
||||||
|
val isNoinline: Boolean
|
||||||
|
}
|
||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirAnnotationImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.checkConstantSupportedInCommonization
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
object CirAnnotationFactory {
|
||||||
|
private val interner = Interner<CirAnnotation>()
|
||||||
|
|
||||||
|
fun create(source: AnnotationDescriptor): CirAnnotation {
|
||||||
|
val fqName: FqName = source.fqName?.intern() ?: error("Annotation with no FQ name: ${source::class.java}, $source")
|
||||||
|
|
||||||
|
val allValueArguments: Map<Name, ConstantValue<*>> = source.allValueArguments
|
||||||
|
if (allValueArguments.isEmpty())
|
||||||
|
return create(fqName = fqName, constantValueArguments = emptyMap(), annotationValueArguments = emptyMap())
|
||||||
|
|
||||||
|
val constantValueArguments: MutableMap<Name, ConstantValue<*>> = HashMap()
|
||||||
|
val annotationValueArguments: MutableMap<Name, CirAnnotation> = HashMap()
|
||||||
|
|
||||||
|
allValueArguments.forEach { (name, constantValue) ->
|
||||||
|
checkConstantSupportedInCommonization(
|
||||||
|
constantValue = constantValue,
|
||||||
|
constantName = name,
|
||||||
|
owner = source,
|
||||||
|
allowAnnotationValues = true
|
||||||
|
)
|
||||||
|
|
||||||
|
if (constantValue is AnnotationValue)
|
||||||
|
annotationValueArguments[name.intern()] = create(source = constantValue.value)
|
||||||
|
else
|
||||||
|
constantValueArguments[name.intern()] = constantValue
|
||||||
|
}
|
||||||
|
|
||||||
|
return create(
|
||||||
|
fqName = fqName,
|
||||||
|
constantValueArguments = constantValueArguments,
|
||||||
|
annotationValueArguments = annotationValueArguments
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(
|
||||||
|
fqName: FqName,
|
||||||
|
constantValueArguments: Map<Name, ConstantValue<*>>,
|
||||||
|
annotationValueArguments: Map<Name, CirAnnotation>
|
||||||
|
): CirAnnotation {
|
||||||
|
return interner.intern(
|
||||||
|
CirAnnotationImpl(
|
||||||
|
fqName = fqName,
|
||||||
|
constantValueArguments = constantValueArguments,
|
||||||
|
annotationValueArguments = annotationValueArguments
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirClassConstructorImpl
|
||||||
|
|
||||||
|
object CirClassConstructorFactory {
|
||||||
|
fun create(source: ClassConstructorDescriptor): CirClassConstructor {
|
||||||
|
val containingClass: ClassDescriptor = source.containingDeclaration
|
||||||
|
|
||||||
|
return create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
typeParameters = source.typeParameters.mapNotNull { typeParameter ->
|
||||||
|
// save only type parameters that are contributed by the constructor itself
|
||||||
|
typeParameter.takeIf { it.containingDeclaration == source }?.let(CirTypeParameterFactory::create)
|
||||||
|
},
|
||||||
|
visibility = source.visibility,
|
||||||
|
containingClassDetails = CirContainingClassDetails(
|
||||||
|
kind = containingClass.kind,
|
||||||
|
modality = containingClass.modality,
|
||||||
|
isData = containingClass.isData
|
||||||
|
),
|
||||||
|
valueParameters = source.valueParameters.map(CirValueParameterFactory::create),
|
||||||
|
hasStableParameterNames = source.hasStableParameterNames(),
|
||||||
|
hasSynthesizedParameterNames = source.hasSynthesizedParameterNames(),
|
||||||
|
isPrimary = source.isPrimary,
|
||||||
|
kind = source.kind
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
typeParameters: List<CirTypeParameter>,
|
||||||
|
visibility: Visibility,
|
||||||
|
containingClassDetails: CirContainingClassDetails,
|
||||||
|
valueParameters: List<CirValueParameter>,
|
||||||
|
hasStableParameterNames: Boolean,
|
||||||
|
hasSynthesizedParameterNames: Boolean,
|
||||||
|
isPrimary: Boolean,
|
||||||
|
kind: CallableMemberDescriptor.Kind
|
||||||
|
): CirClassConstructor {
|
||||||
|
return CirClassConstructorImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
typeParameters = typeParameters,
|
||||||
|
visibility = visibility,
|
||||||
|
containingClassDetails = containingClassDetails,
|
||||||
|
valueParameters = valueParameters,
|
||||||
|
hasStableParameterNames = hasStableParameterNames,
|
||||||
|
hasSynthesizedParameterNames = hasSynthesizedParameterNames,
|
||||||
|
isPrimary = isPrimary,
|
||||||
|
kind = kind
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirClassImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
|
|
||||||
|
object CirClassFactory {
|
||||||
|
fun create(source: ClassDescriptor): CirClass = create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
typeParameters = source.declaredTypeParameters.map(CirTypeParameterFactory::create),
|
||||||
|
visibility = source.visibility,
|
||||||
|
modality = source.modality,
|
||||||
|
kind = source.kind,
|
||||||
|
companion = source.companionObjectDescriptor?.fqNameSafe?.intern(),
|
||||||
|
isCompanion = source.isCompanionObject,
|
||||||
|
isData = source.isData,
|
||||||
|
isInline = source.isInline,
|
||||||
|
isInner = source.isInner,
|
||||||
|
isExternal = source.isExternal,
|
||||||
|
supertypes = source.typeConstructor.supertypes.mapTo(mutableListOf()) { CirTypeFactory.create(it) }
|
||||||
|
)
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
name: Name,
|
||||||
|
typeParameters: List<CirTypeParameter>,
|
||||||
|
visibility: Visibility,
|
||||||
|
modality: Modality,
|
||||||
|
kind: ClassKind,
|
||||||
|
companion: FqName?,
|
||||||
|
isCompanion: Boolean,
|
||||||
|
isData: Boolean,
|
||||||
|
isInline: Boolean,
|
||||||
|
isInner: Boolean,
|
||||||
|
isExternal: Boolean,
|
||||||
|
supertypes: MutableCollection<CirType>
|
||||||
|
): CirClass {
|
||||||
|
return CirClassImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
name = name,
|
||||||
|
typeParameters = typeParameters,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
kind = kind,
|
||||||
|
companion = companion,
|
||||||
|
isCompanion = isCompanion,
|
||||||
|
isData = isData,
|
||||||
|
isInline = isInline,
|
||||||
|
isInner = isInner,
|
||||||
|
isExternal = isExternal,
|
||||||
|
supertypes = supertypes
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||||
|
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(source: ReceiverParameterDescriptor): CirExtensionReceiver = create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
type = CirTypeFactory.create(source.type)
|
||||||
|
)
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
type: CirType
|
||||||
|
): CirExtensionReceiver {
|
||||||
|
return CirExtensionReceiverImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
type = type
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirFunctionImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
object CirFunctionFactory {
|
||||||
|
fun create(source: SimpleFunctionDescriptor): CirFunction {
|
||||||
|
val containingClass: ClassDescriptor? = source.containingDeclaration as? ClassDescriptor
|
||||||
|
|
||||||
|
return create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
typeParameters = source.typeParameters.map(CirTypeParameterFactory::create),
|
||||||
|
visibility = source.visibility,
|
||||||
|
modality = source.modality,
|
||||||
|
containingClassDetails = containingClass?.let {
|
||||||
|
CirContainingClassDetails(
|
||||||
|
kind = it.kind,
|
||||||
|
modality = it.modality,
|
||||||
|
isData = it.isData
|
||||||
|
)
|
||||||
|
},
|
||||||
|
valueParameters = source.valueParameters.map(CirValueParameterFactory::create),
|
||||||
|
hasStableParameterNames = source.hasStableParameterNames(),
|
||||||
|
hasSynthesizedParameterNames = source.hasSynthesizedParameterNames(),
|
||||||
|
isExternal = source.isExternal,
|
||||||
|
extensionReceiver = source.extensionReceiverParameter?.let(CirExtensionReceiverFactory::create),
|
||||||
|
returnType = CirTypeFactory.create(source.returnType!!),
|
||||||
|
kind = source.kind,
|
||||||
|
// TODO: inline?
|
||||||
|
modifiers = CirFunctionModifiers(
|
||||||
|
isOperator = source.isOperator,
|
||||||
|
isInfix = source.isInfix,
|
||||||
|
isInline = source.isInline,
|
||||||
|
isTailrec = source.isTailrec,
|
||||||
|
isSuspend = source.isSuspend,
|
||||||
|
isExternal = source.isExternal
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
name: Name,
|
||||||
|
typeParameters: List<CirTypeParameter>,
|
||||||
|
visibility: Visibility,
|
||||||
|
modality: Modality,
|
||||||
|
containingClassDetails: CirContainingClassDetails?,
|
||||||
|
valueParameters: List<CirValueParameter>,
|
||||||
|
hasStableParameterNames: Boolean,
|
||||||
|
hasSynthesizedParameterNames: Boolean,
|
||||||
|
isExternal: Boolean,
|
||||||
|
extensionReceiver: CirExtensionReceiver?,
|
||||||
|
returnType: CirType,
|
||||||
|
kind: CallableMemberDescriptor.Kind,
|
||||||
|
modifiers: CirFunctionModifiers
|
||||||
|
): CirFunction {
|
||||||
|
return CirFunctionImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
name = name,
|
||||||
|
typeParameters = typeParameters,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
containingClassDetails = containingClassDetails,
|
||||||
|
valueParameters = valueParameters,
|
||||||
|
hasStableParameterNames = hasStableParameterNames,
|
||||||
|
hasSynthesizedParameterNames = hasSynthesizedParameterNames,
|
||||||
|
isExternal = isExternal,
|
||||||
|
extensionReceiver = extensionReceiver,
|
||||||
|
returnType = returnType,
|
||||||
|
kind = kind,
|
||||||
|
modifiers = modifiers
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirModule
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirModuleImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
object CirModuleFactory {
|
||||||
|
fun create(source: ModuleDescriptor): CirModule = create(source.name.intern())
|
||||||
|
|
||||||
|
fun create(name: Name) = CirModuleImpl(name)
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackage
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirPackageImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
object CirPackageFactory {
|
||||||
|
fun create(fqName: FqName): CirPackage = CirPackageImpl(fqName)
|
||||||
|
}
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirPropertyImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.checkConstantSupportedInCommonization
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
object CirPropertyFactory {
|
||||||
|
fun create(source: PropertyDescriptor): CirProperty {
|
||||||
|
val compileTimeInitializer: ConstantValue<*>? = source.compileTimeInitializer
|
||||||
|
if (compileTimeInitializer != null) {
|
||||||
|
checkConstantSupportedInCommonization(
|
||||||
|
constantValue = compileTimeInitializer,
|
||||||
|
owner = source,
|
||||||
|
allowAnnotationValues = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val containingClass: ClassDescriptor? = source.containingDeclaration as? ClassDescriptor
|
||||||
|
|
||||||
|
return create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
typeParameters = source.typeParameters.map(CirTypeParameterFactory::create),
|
||||||
|
visibility = source.visibility,
|
||||||
|
modality = source.modality,
|
||||||
|
containingClassDetails = containingClass?.let {
|
||||||
|
CirContainingClassDetails(
|
||||||
|
kind = it.kind,
|
||||||
|
modality = it.modality,
|
||||||
|
isData = it.isData
|
||||||
|
)
|
||||||
|
},
|
||||||
|
isExternal = source.isExternal,
|
||||||
|
extensionReceiver = source.extensionReceiverParameter?.let(CirExtensionReceiverFactory::create),
|
||||||
|
returnType = CirTypeFactory.create(source.returnType!!),
|
||||||
|
kind = source.kind,
|
||||||
|
isVar = source.isVar,
|
||||||
|
isLateInit = source.isLateInit,
|
||||||
|
isConst = source.isConst,
|
||||||
|
isDelegate = @Suppress("DEPRECATION") source.isDelegated,
|
||||||
|
getter = source.getter?.let(CirPropertyGetterFactory::create),
|
||||||
|
setter = source.setter?.let(CirPropertySetterFactory::create),
|
||||||
|
backingFieldAnnotations = source.backingField?.annotations?.map(CirAnnotationFactory::create),
|
||||||
|
delegateFieldAnnotations = source.delegateField?.annotations?.map(CirAnnotationFactory::create),
|
||||||
|
compileTimeInitializer = source.compileTimeInitializer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
name: Name,
|
||||||
|
typeParameters: List<CirTypeParameter>,
|
||||||
|
visibility: Visibility,
|
||||||
|
modality: Modality,
|
||||||
|
containingClassDetails: CirContainingClassDetails?,
|
||||||
|
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: ConstantValue<*>?
|
||||||
|
): CirProperty {
|
||||||
|
return CirPropertyImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
name = name,
|
||||||
|
typeParameters = typeParameters,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
containingClassDetails = containingClassDetails,
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPropertyGetter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirPropertyGetterImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
|
|
||||||
|
object CirPropertyGetterFactory {
|
||||||
|
private val interner = Interner<CirPropertyGetter>()
|
||||||
|
|
||||||
|
// speed optimization
|
||||||
|
val DEFAULT_NO_ANNOTATIONS: CirPropertyGetter = create(
|
||||||
|
annotations = emptyList(),
|
||||||
|
isDefault = true,
|
||||||
|
isExternal = false,
|
||||||
|
isInline = false
|
||||||
|
)
|
||||||
|
|
||||||
|
fun create(source: PropertyGetterDescriptor): CirPropertyGetter {
|
||||||
|
return if (source.isDefault && source.annotations.isEmpty())
|
||||||
|
DEFAULT_NO_ANNOTATIONS
|
||||||
|
else
|
||||||
|
create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
isDefault = source.isDefault,
|
||||||
|
isExternal = source.isExternal,
|
||||||
|
isInline = source.isInline
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
isDefault: Boolean,
|
||||||
|
isExternal: Boolean,
|
||||||
|
isInline: Boolean
|
||||||
|
): CirPropertyGetter {
|
||||||
|
return interner.intern(
|
||||||
|
CirPropertyGetterImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
isDefault = isDefault,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isInline = isInline
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPropertySetter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirPropertySetterImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
|
|
||||||
|
object CirPropertySetterFactory {
|
||||||
|
private val interner = Interner<CirPropertySetter>()
|
||||||
|
|
||||||
|
fun create(source: PropertySetterDescriptor): CirPropertySetter = create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
parameterAnnotations = source.valueParameters[0].annotations.map(CirAnnotationFactory::create),
|
||||||
|
visibility = source.visibility,
|
||||||
|
isDefault = source.isDefault,
|
||||||
|
isExternal = source.isExternal,
|
||||||
|
isInline = source.isInline
|
||||||
|
)
|
||||||
|
|
||||||
|
fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
parameterAnnotations: List<CirAnnotation>,
|
||||||
|
visibility: Visibility,
|
||||||
|
isDefault: Boolean,
|
||||||
|
isExternal: Boolean,
|
||||||
|
isInline: Boolean
|
||||||
|
): CirPropertySetter {
|
||||||
|
return interner.intern(
|
||||||
|
CirPropertySetterImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
parameterAnnotations = parameterAnnotations,
|
||||||
|
visibility = visibility,
|
||||||
|
isDefault = isDefault,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isInline = isInline
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun createDefaultNoAnnotations(visibility: Visibility): CirPropertySetter = create(
|
||||||
|
annotations = emptyList(),
|
||||||
|
parameterAnnotations = emptyList(),
|
||||||
|
visibility = visibility,
|
||||||
|
isDefault = visibility == Visibilities.PUBLIC,
|
||||||
|
isExternal = false,
|
||||||
|
isInline = false
|
||||||
|
)
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.BuiltInsProvider
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.InputTarget
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRoot
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirRootImpl
|
||||||
|
|
||||||
|
object CirRootFactory {
|
||||||
|
fun create(
|
||||||
|
target: Target,
|
||||||
|
builtInsClass: String,
|
||||||
|
builtInsProvider: BuiltInsProvider
|
||||||
|
): CirRoot {
|
||||||
|
if (target is InputTarget) {
|
||||||
|
check((target.konanTarget != null) == (builtInsClass == KonanBuiltIns::class.java.name))
|
||||||
|
}
|
||||||
|
|
||||||
|
return CirRootImpl(
|
||||||
|
target = target,
|
||||||
|
builtInsClass = builtInsClass,
|
||||||
|
builtInsProvider = builtInsProvider
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirTypeAliasImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
|
||||||
|
object CirTypeAliasFactory {
|
||||||
|
fun create(source: TypeAliasDescriptor): CirTypeAlias {
|
||||||
|
return CirTypeAliasImpl(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
typeParameters = source.declaredTypeParameters.map(CirTypeParameterFactory::create),
|
||||||
|
visibility = source.visibility,
|
||||||
|
underlyingType = CirTypeFactory.create(source.underlyingType),
|
||||||
|
expandedType = CirTypeFactory.create(source.expandedType)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirSimpleTypeImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.declarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.fqNameInterned
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.fqNameWithTypeParameters
|
||||||
|
import org.jetbrains.kotlin.types.*
|
||||||
|
|
||||||
|
object CirTypeFactory {
|
||||||
|
private val interner = Interner<CirSimpleType>()
|
||||||
|
|
||||||
|
fun create(source: KotlinType): CirType = source.unwrap().run {
|
||||||
|
when (this) {
|
||||||
|
is SimpleType -> create(this)
|
||||||
|
is FlexibleType -> CirFlexibleType(create(lowerBound), create(upperBound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(source: SimpleType): CirSimpleType {
|
||||||
|
val abbreviation: SimpleType = (source as? AbbreviatedType)?.abbreviation ?: source
|
||||||
|
val expanded: SimpleType = (source as? AbbreviatedType)?.expandedType ?: source
|
||||||
|
|
||||||
|
val simpleType = CirSimpleTypeImpl(
|
||||||
|
kind = abbreviation.declarationDescriptor.cirSimpleTypeKind,
|
||||||
|
fqName = abbreviation.fqNameInterned,
|
||||||
|
arguments = abbreviation.arguments.map { projection ->
|
||||||
|
CirTypeProjection(
|
||||||
|
projectionKind = projection.projectionKind,
|
||||||
|
isStarProjection = projection.isStarProjection,
|
||||||
|
type = create(projection.type)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
isMarkedNullable = abbreviation.isMarkedNullable,
|
||||||
|
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType,
|
||||||
|
expandedTypeConstructorId = CirTypeConstructorId(
|
||||||
|
fqName = expanded.fqNameInterned,
|
||||||
|
numberOfTypeParameters = expanded.constructor.parameters.size
|
||||||
|
),
|
||||||
|
fqNameWithTypeParameters = source.fqNameWithTypeParameters
|
||||||
|
)
|
||||||
|
|
||||||
|
return interner.intern(simpleType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val ClassifierDescriptor.cirSimpleTypeKind: CirSimpleTypeKind
|
||||||
|
get() = when (this) {
|
||||||
|
is ClassDescriptor -> CLASS
|
||||||
|
is TypeAliasDescriptor -> TYPE_ALIAS
|
||||||
|
is TypeParameterDescriptor -> TYPE_PARAMETER
|
||||||
|
else -> error("Unexpected classifier descriptor type: ${this::class.java}, $this")
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirTypeParameterImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
|
object CirTypeParameterFactory {
|
||||||
|
fun create(source: TypeParameterDescriptor): CirTypeParameter = create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
isReified = source.isReified,
|
||||||
|
variance = source.variance,
|
||||||
|
upperBounds = source.upperBounds.map(CirTypeFactory::create)
|
||||||
|
)
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
name: Name,
|
||||||
|
isReified: Boolean,
|
||||||
|
variance: Variance,
|
||||||
|
upperBounds: List<CirType>
|
||||||
|
): CirTypeParameter {
|
||||||
|
return CirTypeParameterImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
name = name,
|
||||||
|
isReified = isReified,
|
||||||
|
variance = variance,
|
||||||
|
upperBounds = upperBounds
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.factory
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirValueParameterImpl
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
object CirValueParameterFactory {
|
||||||
|
private val interner = Interner<CirValueParameterImpl>()
|
||||||
|
|
||||||
|
fun create(source: ValueParameterDescriptor): CirValueParameter = create(
|
||||||
|
annotations = source.annotations.map(CirAnnotationFactory::create),
|
||||||
|
name = source.name.intern(),
|
||||||
|
returnType = CirTypeFactory.create(source.returnType!!),
|
||||||
|
varargElementType = source.varargElementType?.let(CirTypeFactory::create),
|
||||||
|
declaresDefaultValue = source.declaresDefaultValue(),
|
||||||
|
isCrossinline = source.isCrossinline,
|
||||||
|
isNoinline = source.isNoinline
|
||||||
|
)
|
||||||
|
|
||||||
|
fun create(
|
||||||
|
annotations: List<CirAnnotation>,
|
||||||
|
name: Name,
|
||||||
|
returnType: CirType,
|
||||||
|
varargElementType: CirType?,
|
||||||
|
declaresDefaultValue: Boolean,
|
||||||
|
isCrossinline: Boolean,
|
||||||
|
isNoinline: Boolean
|
||||||
|
): CirValueParameter {
|
||||||
|
return interner.intern(
|
||||||
|
CirValueParameterImpl(
|
||||||
|
annotations = annotations,
|
||||||
|
name = name,
|
||||||
|
returnType = returnType,
|
||||||
|
varargElementType = varargElementType,
|
||||||
|
declaresDefaultValue = declaresDefaultValue,
|
||||||
|
isCrossinline = isCrossinline,
|
||||||
|
isNoinline = isNoinline
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.utils.appendHashCode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
data class CirAnnotationImpl(
|
||||||
|
override val fqName: FqName,
|
||||||
|
override val constantValueArguments: Map<Name, ConstantValue<*>>,
|
||||||
|
override val annotationValueArguments: Map<Name, CirAnnotation>
|
||||||
|
) : CirAnnotation {
|
||||||
|
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
||||||
|
private var cachedHashCode = 0
|
||||||
|
|
||||||
|
private fun computeHashCode() = hashCode(fqName)
|
||||||
|
.appendHashCode(constantValueArguments)
|
||||||
|
.appendHashCode(annotationValueArguments)
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var currentHashCode = cachedHashCode
|
||||||
|
if (currentHashCode != 0) return currentHashCode
|
||||||
|
|
||||||
|
currentHashCode = computeHashCode()
|
||||||
|
cachedHashCode = currentHashCode
|
||||||
|
return currentHashCode
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other === this) return true
|
||||||
|
|
||||||
|
return other is CirAnnotation
|
||||||
|
&& fqName == other.fqName
|
||||||
|
&& constantValueArguments == other.constantValueArguments
|
||||||
|
&& annotationValueArguments == other.annotationValueArguments
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
|
|
||||||
|
data class CirClassConstructorImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val typeParameters: List<CirTypeParameter>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val containingClassDetails: CirContainingClassDetails,
|
||||||
|
override val valueParameters: List<CirValueParameter>,
|
||||||
|
override val hasStableParameterNames: Boolean,
|
||||||
|
override val hasSynthesizedParameterNames: Boolean,
|
||||||
|
override val isPrimary: Boolean,
|
||||||
|
override val kind: CallableMemberDescriptor.Kind
|
||||||
|
) : CirClassConstructor
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
data class CirClassImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val typeParameters: List<CirTypeParameter>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val modality: Modality,
|
||||||
|
override val kind: ClassKind,
|
||||||
|
override var companion: FqName?,
|
||||||
|
override val isCompanion: Boolean,
|
||||||
|
override val isData: Boolean,
|
||||||
|
override val isInline: Boolean,
|
||||||
|
override val isInner: Boolean,
|
||||||
|
override val isExternal: Boolean,
|
||||||
|
override val supertypes: MutableCollection<CirType>
|
||||||
|
) : CirClass
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirDeclaration
|
||||||
|
|
||||||
|
@Suppress("unused", "NOTHING_TO_INLINE")
|
||||||
|
internal inline fun CirDeclaration.unsupported(): Nothing = error("This method should never be called")
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.*
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
data class CirFunctionImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val typeParameters: List<CirTypeParameter>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val modality: Modality,
|
||||||
|
override val containingClassDetails: CirContainingClassDetails?,
|
||||||
|
override val valueParameters: List<CirValueParameter>,
|
||||||
|
override val hasStableParameterNames: Boolean,
|
||||||
|
override val hasSynthesizedParameterNames: Boolean,
|
||||||
|
override val isExternal: Boolean,
|
||||||
|
override val extensionReceiver: CirExtensionReceiver?,
|
||||||
|
override val returnType: CirType,
|
||||||
|
override val kind: CallableMemberDescriptor.Kind,
|
||||||
|
override val modifiers: CirFunctionModifiers
|
||||||
|
) : CirFunction
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirModule
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
data class CirModuleImpl(
|
||||||
|
override val name: Name
|
||||||
|
) : CirModule
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirPackage
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
data class CirPackageImpl(
|
||||||
|
override val fqName: FqName
|
||||||
|
) : CirPackage
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirPropertyGetter
|
||||||
|
|
||||||
|
data class CirPropertyGetterImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val isDefault: Boolean,
|
||||||
|
override val isExternal: Boolean,
|
||||||
|
override val isInline: Boolean
|
||||||
|
) : CirPropertyGetter
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.*
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
|
data class CirPropertyImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val typeParameters: List<CirTypeParameter>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val modality: Modality,
|
||||||
|
override val containingClassDetails: CirContainingClassDetails?,
|
||||||
|
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 val 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: ConstantValue<*>?
|
||||||
|
) : CirProperty
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPropertySetter
|
||||||
|
|
||||||
|
data class CirPropertySetterImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val parameterAnnotations: List<CirAnnotation>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val isDefault: Boolean,
|
||||||
|
override val isExternal: Boolean,
|
||||||
|
override val isInline: Boolean
|
||||||
|
) : CirPropertySetter
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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.BuiltInsProvider
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRoot
|
||||||
|
|
||||||
|
data class CirRootImpl(
|
||||||
|
override val target: Target,
|
||||||
|
override val builtInsClass: String,
|
||||||
|
override val builtInsProvider: BuiltInsProvider
|
||||||
|
) : CirRoot
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirSimpleType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeConstructorId
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeProjection
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.appendHashCode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
data class CirSimpleTypeImpl(
|
||||||
|
override val kind: CirSimpleTypeKind,
|
||||||
|
override val fqName: FqName,
|
||||||
|
override val arguments: List<CirTypeProjection>,
|
||||||
|
override val isMarkedNullable: Boolean,
|
||||||
|
override val isDefinitelyNotNullType: Boolean,
|
||||||
|
override val expandedTypeConstructorId: CirTypeConstructorId,
|
||||||
|
override val fqNameWithTypeParameters: String
|
||||||
|
) : CirSimpleType() {
|
||||||
|
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
||||||
|
private var cachedHashCode = 0
|
||||||
|
|
||||||
|
private fun computeHashCode() = hashCode(kind)
|
||||||
|
.appendHashCode(fqName)
|
||||||
|
.appendHashCode(arguments)
|
||||||
|
.appendHashCode(isMarkedNullable)
|
||||||
|
.appendHashCode(isDefinitelyNotNullType)
|
||||||
|
.appendHashCode(fqNameWithTypeParameters)
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var currentHashCode = cachedHashCode
|
||||||
|
if (currentHashCode != 0) return currentHashCode
|
||||||
|
|
||||||
|
currentHashCode = computeHashCode()
|
||||||
|
cachedHashCode = currentHashCode
|
||||||
|
return currentHashCode
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?) = when {
|
||||||
|
other === this -> true
|
||||||
|
other is CirSimpleType -> {
|
||||||
|
isMarkedNullable == other.isMarkedNullable
|
||||||
|
&& fqName == other.fqName
|
||||||
|
&& kind == other.kind
|
||||||
|
&& arguments == other.arguments
|
||||||
|
&& fqNameWithTypeParameters == other.fqNameWithTypeParameters
|
||||||
|
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.Visibility
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
data class CirTypeAliasImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val typeParameters: List<CirTypeParameter>,
|
||||||
|
override val visibility: Visibility,
|
||||||
|
override val underlyingType: CirSimpleType,
|
||||||
|
override val expandedType: CirSimpleType
|
||||||
|
) : CirTypeAlias
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
|
data class CirTypeParameterImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val isReified: Boolean,
|
||||||
|
override val variance: Variance,
|
||||||
|
override val upperBounds: List<CirType>
|
||||||
|
) : CirTypeParameter
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.appendHashCode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
data class CirValueParameterImpl(
|
||||||
|
override val annotations: List<CirAnnotation>,
|
||||||
|
override val name: Name,
|
||||||
|
override val returnType: CirType,
|
||||||
|
override val varargElementType: CirType?,
|
||||||
|
override val declaresDefaultValue: Boolean,
|
||||||
|
override val isCrossinline: Boolean,
|
||||||
|
override val isNoinline: Boolean
|
||||||
|
) : CirValueParameter {
|
||||||
|
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
||||||
|
private var cachedHashCode = 0
|
||||||
|
|
||||||
|
private fun computeHashCode() = hashCode(name)
|
||||||
|
.appendHashCode(annotations)
|
||||||
|
.appendHashCode(returnType)
|
||||||
|
.appendHashCode(varargElementType)
|
||||||
|
.appendHashCode(declaresDefaultValue)
|
||||||
|
.appendHashCode(isCrossinline)
|
||||||
|
.appendHashCode(isNoinline)
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var currentHashCode = cachedHashCode
|
||||||
|
if (currentHashCode != 0) return currentHashCode
|
||||||
|
|
||||||
|
currentHashCode = computeHashCode()
|
||||||
|
cachedHashCode = currentHashCode
|
||||||
|
return currentHashCode
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean = when {
|
||||||
|
other === this -> true
|
||||||
|
other is CirValueParameterImpl -> {
|
||||||
|
name == other.name
|
||||||
|
&& returnType == other.returnType
|
||||||
|
&& annotations == other.annotations
|
||||||
|
&& varargElementType == other.varargElementType
|
||||||
|
&& declaresDefaultValue == other.declaresDefaultValue
|
||||||
|
&& isCrossinline == other.isCrossinline
|
||||||
|
&& isNoinline == other.isNoinline
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.CirClass
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRecursionMarker
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
object CirClassRecursionMarker : CirClass, CirRecursionMarker {
|
||||||
|
override val annotations get() = unsupported()
|
||||||
|
override val name get() = unsupported()
|
||||||
|
override val typeParameters get() = unsupported()
|
||||||
|
override val visibility get() = unsupported()
|
||||||
|
override val modality get() = unsupported()
|
||||||
|
override val kind get() = unsupported()
|
||||||
|
override var companion: FqName?
|
||||||
|
get() = unsupported()
|
||||||
|
set(_) = unsupported()
|
||||||
|
override val isCompanion get() = unsupported()
|
||||||
|
override val isData get() = unsupported()
|
||||||
|
override val isInline get() = unsupported()
|
||||||
|
override val isInner get() = unsupported()
|
||||||
|
override val isExternal get() = unsupported()
|
||||||
|
override val supertypes get() = unsupported()
|
||||||
|
}
|
||||||
+4
-4
@@ -8,9 +8,9 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
|||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFunctionOrProperty
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunctionOrProperty
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.isNonAbstractMemberInInterface
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.isNonAbstractMemberInInterface
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
abstract class AbstractFunctionOrPropertyCommonizer<T : CirFunctionOrProperty>(
|
abstract class AbstractFunctionOrPropertyCommonizer<T : CirFunctionOrProperty>(
|
||||||
@@ -32,7 +32,7 @@ abstract class AbstractFunctionOrPropertyCommonizer<T : CirFunctionOrProperty>(
|
|||||||
override fun doCommonizeWith(next: T): Boolean =
|
override fun doCommonizeWith(next: T): Boolean =
|
||||||
!next.isNonAbstractMemberInInterface() // non-abstract callable members declared in interface can't be commonized
|
!next.isNonAbstractMemberInInterface() // non-abstract callable members declared in interface can't be commonized
|
||||||
&& next.kind != DELEGATION // delegated members should not be commonized
|
&& next.kind != DELEGATION // delegated members should not be commonized
|
||||||
&& (next.kind != SYNTHESIZED || next.containingClassIsData != true) // synthesized members of data classes should not be commonized
|
&& (next.kind != SYNTHESIZED || next.containingClassDetails?.isData != true) // synthesized members of data classes should not be commonized
|
||||||
&& kind == next.kind
|
&& kind == next.kind
|
||||||
&& modality.commonizeWith(next.modality)
|
&& modality.commonizeWith(next.modality)
|
||||||
&& visibility.commonizeWith(next)
|
&& visibility.commonizeWith(next)
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlike [Commonizer] which commonizes only single elements, this [AbstractListCommonizer] commonizes lists of elements using
|
* Unlike [Commonizer] which commonizes only single elements, this [AbstractListCommonizer] commonizes lists of elements using
|
||||||
|
|||||||
+4
-3
@@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirAnnotationFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.core.AnnotationsCommonizer.Companion.FALLBACK_MESSAGE
|
import org.jetbrains.kotlin.descriptors.commonizer.core.AnnotationsCommonizer.Companion.FALLBACK_MESSAGE
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirAnnotation
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.DEPRECATED_ANNOTATION_FQN
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.DEPRECATED_ANNOTATION_FQN
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -68,7 +69,7 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
|
|||||||
} else
|
} else
|
||||||
mapOf(PROPERTY_NAME_REPLACE_WITH to replaceWithExpression.toReplaceWithValue(replaceWithImports))
|
mapOf(PROPERTY_NAME_REPLACE_WITH to replaceWithExpression.toReplaceWithValue(replaceWithImports))
|
||||||
|
|
||||||
return CirAnnotation.create(
|
return CirAnnotationFactory.create(
|
||||||
fqName = DEPRECATED_ANNOTATION_FQN,
|
fqName = DEPRECATED_ANNOTATION_FQN,
|
||||||
constantValueArguments = constantValueArguments,
|
constantValueArguments = constantValueArguments,
|
||||||
annotationValueArguments = annotationValueArguments
|
annotationValueArguments = annotationValueArguments
|
||||||
@@ -202,7 +203,7 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inline fun createReplaceWithAnnotation(expression: String, imports: List<String>): CirAnnotation =
|
private inline fun createReplaceWithAnnotation(expression: String, imports: List<String>): CirAnnotation =
|
||||||
CirAnnotation.create(
|
CirAnnotationFactory.create(
|
||||||
fqName = REPLACE_WITH_FQN,
|
fqName = REPLACE_WITH_FQN,
|
||||||
constantValueArguments = mapOf(
|
constantValueArguments = mapOf(
|
||||||
PROPERTY_NAME_EXPRESSION to StringValue(expression),
|
PROPERTY_NAME_EXPRESSION to StringValue(expression),
|
||||||
|
|||||||
+12
-7
@@ -6,9 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClass
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonClass
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class ClassCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirClass, CirClass>() {
|
class ClassCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirClass, CirClass>() {
|
||||||
@@ -21,15 +21,20 @@ class ClassCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<C
|
|||||||
private var isInline = false
|
private var isInline = false
|
||||||
private var isCompanion = false
|
private var isCompanion = false
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonClass(
|
override fun commonizationResult() = CirClassFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
name = name,
|
name = name,
|
||||||
typeParameters = typeParameters.result,
|
typeParameters = typeParameters.result,
|
||||||
kind = kind,
|
|
||||||
modality = modality.result,
|
|
||||||
visibility = visibility.result,
|
visibility = visibility.result,
|
||||||
|
modality = modality.result,
|
||||||
|
kind = kind,
|
||||||
|
companion = null,
|
||||||
isCompanion = isCompanion,
|
isCompanion = isCompanion,
|
||||||
|
isData = false,
|
||||||
isInline = isInline,
|
isInline = isInline,
|
||||||
isInner = isInner
|
isInner = isInner,
|
||||||
|
isExternal = false,
|
||||||
|
supertypes = mutableListOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun initialize(first: CirClass) {
|
override fun initialize(first: CirClass) {
|
||||||
|
|||||||
+13
-10
@@ -7,9 +7,10 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassConstructor
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClassConstructor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirContainingClassDetails
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonClassConstructor
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassConstructorFactory
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class ClassConstructorCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirClassConstructor, CirClassConstructor>() {
|
class ClassConstructorCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirClassConstructor, CirClassConstructor>() {
|
||||||
private var isPrimary = false
|
private var isPrimary = false
|
||||||
@@ -20,14 +21,16 @@ class ClassConstructorCommonizer(cache: CirClassifiersCache) : AbstractStandardC
|
|||||||
private var hasStableParameterNames = true
|
private var hasStableParameterNames = true
|
||||||
private var hasSynthesizedParameterNames = false
|
private var hasSynthesizedParameterNames = false
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonClassConstructor(
|
override fun commonizationResult() = CirClassConstructorFactory.create(
|
||||||
isPrimary = isPrimary,
|
annotations = emptyList(),
|
||||||
kind = kind,
|
|
||||||
visibility = visibility.result,
|
|
||||||
typeParameters = typeParameters.result,
|
typeParameters = typeParameters.result,
|
||||||
|
visibility = visibility.result,
|
||||||
|
containingClassDetails = CirContainingClassDetails.DOES_NOT_MATTER,
|
||||||
valueParameters = valueParameters.result,
|
valueParameters = valueParameters.result,
|
||||||
hasStableParameterNames = hasStableParameterNames,
|
hasStableParameterNames = hasStableParameterNames,
|
||||||
hasSynthesizedParameterNames = hasSynthesizedParameterNames
|
hasSynthesizedParameterNames = hasSynthesizedParameterNames,
|
||||||
|
isPrimary = isPrimary,
|
||||||
|
kind = kind
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun initialize(first: CirClassConstructor) {
|
override fun initialize(first: CirClassConstructor) {
|
||||||
@@ -36,8 +39,8 @@ class ClassConstructorCommonizer(cache: CirClassifiersCache) : AbstractStandardC
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun doCommonizeWith(next: CirClassConstructor): Boolean {
|
override fun doCommonizeWith(next: CirClassConstructor): Boolean {
|
||||||
val result = !next.containingClassKind.isSingleton // don't commonize constructors for objects and enum entries
|
val result = !next.containingClassDetails.kind.isSingleton // don't commonize constructors for objects and enum entries
|
||||||
&& next.containingClassModality != Modality.SEALED // don't commonize constructors for sealed classes (not not their subclasses)
|
&& next.containingClassDetails.modality != Modality.SEALED // don't commonize constructors for sealed classes (not not their subclasses)
|
||||||
&& isPrimary == next.isPrimary
|
&& isPrimary == next.isPrimary
|
||||||
&& kind == next.kind
|
&& kind == next.kind
|
||||||
&& visibility.commonizeWith(next)
|
&& visibility.commonizeWith(next)
|
||||||
|
|||||||
+5
-3
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.fqNameWithTypeParameters
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
||||||
|
|
||||||
internal class CommonizationVisitor(
|
internal class CommonizationVisitor(
|
||||||
@@ -57,7 +59,7 @@ internal class CommonizationVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitClassNode(node: CirClassNode, data: Unit) {
|
override fun visitClassNode(node: CirClassNode, data: Unit) {
|
||||||
val commonClass = node.common() as CirCommonClass? // commonize class
|
val commonClass = node.common() // commonized class
|
||||||
|
|
||||||
node.constructors.forEach { constructor ->
|
node.constructors.forEach { constructor ->
|
||||||
constructor.accept(this, Unit)
|
constructor.accept(this, Unit)
|
||||||
@@ -99,7 +101,7 @@ internal class CommonizationVisitor(
|
|||||||
for ((_, supertypesGroup) in supertypesMap) {
|
for ((_, supertypesGroup) in supertypesMap) {
|
||||||
val commonSupertype = commonize(supertypesGroup.toList(), TypeCommonizer(root.cache))
|
val commonSupertype = commonize(supertypesGroup.toList(), TypeCommonizer(root.cache))
|
||||||
if (commonSupertype != null)
|
if (commonSupertype != null)
|
||||||
commonClass.supertypes += commonSupertype
|
commonClass.supertypes.add(commonSupertype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -5,14 +5,19 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirExtensionReceiver
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirExtensionReceiverFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirExtensionReceiver.Companion.toReceiverNoAnnotations
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class ExtensionReceiverCommonizer(cache: CirClassifiersCache) :
|
class ExtensionReceiverCommonizer(cache: CirClassifiersCache) :
|
||||||
AbstractNullableCommonizer<CirExtensionReceiver, CirExtensionReceiver, CirType, CirType>(
|
AbstractNullableCommonizer<CirExtensionReceiver, CirExtensionReceiver, CirType, CirType>(
|
||||||
wrappedCommonizerFactory = { TypeCommonizer(cache) },
|
wrappedCommonizerFactory = { TypeCommonizer(cache) },
|
||||||
extractor = { it.type },
|
extractor = { it.type },
|
||||||
builder = { it.toReceiverNoAnnotations() }
|
builder = { receiverType ->
|
||||||
|
CirExtensionReceiverFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
|
type = receiverType
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+13
-11
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFunction
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonFunction
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirFunctionFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunction
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class FunctionCommonizer(cache: CirClassifiersCache) : AbstractFunctionOrPropertyCommonizer<CirFunction>(cache) {
|
class FunctionCommonizer(cache: CirClassifiersCache) : AbstractFunctionOrPropertyCommonizer<CirFunction>(cache) {
|
||||||
private val annotations = AnnotationsCommonizer()
|
private val annotations = AnnotationsCommonizer()
|
||||||
@@ -16,25 +16,27 @@ class FunctionCommonizer(cache: CirClassifiersCache) : AbstractFunctionOrPropert
|
|||||||
private var hasStableParameterNames = true
|
private var hasStableParameterNames = true
|
||||||
private var hasSynthesizedParameterNames = false
|
private var hasSynthesizedParameterNames = false
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonFunction(
|
override fun commonizationResult() = CirFunctionFactory.create(
|
||||||
annotations = annotations.result,
|
annotations = annotations.result,
|
||||||
name = name,
|
name = name,
|
||||||
modality = modality.result,
|
typeParameters = typeParameters.result,
|
||||||
visibility = visibility.result,
|
visibility = visibility.result,
|
||||||
|
modality = modality.result,
|
||||||
|
containingClassDetails = null,
|
||||||
|
valueParameters = valueParameters.result,
|
||||||
|
hasStableParameterNames = hasStableParameterNames,
|
||||||
|
hasSynthesizedParameterNames = hasSynthesizedParameterNames,
|
||||||
|
isExternal = false,
|
||||||
extensionReceiver = extensionReceiver.result,
|
extensionReceiver = extensionReceiver.result,
|
||||||
returnType = returnType.result,
|
returnType = returnType.result,
|
||||||
kind = kind,
|
kind = kind,
|
||||||
modifiers = modifiers.result,
|
modifiers = modifiers.result
|
||||||
valueParameters = valueParameters.result,
|
|
||||||
typeParameters = typeParameters.result,
|
|
||||||
hasStableParameterNames = hasStableParameterNames,
|
|
||||||
hasSynthesizedParameterNames = hasSynthesizedParameterNames
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun doCommonizeWith(next: CirFunction): Boolean {
|
override fun doCommonizeWith(next: CirFunction): Boolean {
|
||||||
val result = super.doCommonizeWith(next)
|
val result = super.doCommonizeWith(next)
|
||||||
&& annotations.commonizeWith(next.annotations)
|
&& annotations.commonizeWith(next.annotations)
|
||||||
&& modifiers.commonizeWith(next)
|
&& modifiers.commonizeWith(next.modifiers)
|
||||||
&& valueParameters.commonizeWith(next.valueParameters)
|
&& valueParameters.commonizeWith(next.valueParameters)
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|||||||
+3
-21
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunctionModifiers
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFunctionModifiers
|
||||||
|
|
||||||
class FunctionModifiersCommonizer : Commonizer<CirFunctionModifiers, CirFunctionModifiers> {
|
class FunctionModifiersCommonizer : Commonizer<CirFunctionModifiers, CirFunctionModifiers> {
|
||||||
private var modifiers: CirFunctionModifiersImpl? = null
|
private var modifiers: CirFunctionModifiers? = null
|
||||||
private var error = false
|
private var error = false
|
||||||
|
|
||||||
override val result: CirFunctionModifiers
|
override val result: CirFunctionModifiers
|
||||||
@@ -20,7 +20,7 @@ class FunctionModifiersCommonizer : Commonizer<CirFunctionModifiers, CirFunction
|
|||||||
|
|
||||||
val modifiers = modifiers
|
val modifiers = modifiers
|
||||||
if (modifiers == null)
|
if (modifiers == null)
|
||||||
this.modifiers = CirFunctionModifiersImpl(next)
|
this.modifiers = next.copy() // TODO: inline?
|
||||||
else {
|
else {
|
||||||
if (modifiers.isSuspend != next.isSuspend)
|
if (modifiers.isSuspend != next.isSuspend)
|
||||||
error = true
|
error = true
|
||||||
@@ -35,22 +35,4 @@ class FunctionModifiersCommonizer : Commonizer<CirFunctionModifiers, CirFunction
|
|||||||
|
|
||||||
return !error
|
return !error
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class CirFunctionModifiersImpl(
|
|
||||||
override var isOperator: Boolean,
|
|
||||||
override var isInfix: Boolean,
|
|
||||||
override var isInline: Boolean,
|
|
||||||
override var isTailrec: Boolean,
|
|
||||||
override var isSuspend: Boolean,
|
|
||||||
override var isExternal: Boolean
|
|
||||||
) : CirFunctionModifiers {
|
|
||||||
constructor(function: CirFunctionModifiers) : this(
|
|
||||||
function.isOperator,
|
|
||||||
function.isInfix,
|
|
||||||
function.isInline,
|
|
||||||
function.isTailrec,
|
|
||||||
function.isSuspend,
|
|
||||||
function.isExternal
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -5,13 +5,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirModule
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirModule
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirModuleFactory
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class ModuleCommonizer : AbstractStandardCommonizer<CirModule, CirModule>() {
|
class ModuleCommonizer : AbstractStandardCommonizer<CirModule, CirModule>() {
|
||||||
private lateinit var name: Name
|
private lateinit var name: Name
|
||||||
|
|
||||||
override fun commonizationResult() = CirModule(name = name)
|
override fun commonizationResult() = CirModuleFactory.create(name = name)
|
||||||
|
|
||||||
override fun initialize(first: CirModule) {
|
override fun initialize(first: CirModule) {
|
||||||
name = first.name
|
name = first.name
|
||||||
|
|||||||
+29
-14
@@ -5,25 +5,40 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirProperty
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonProperty
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirPropertyFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirProperty
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirPropertyGetterFactory
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class PropertyCommonizer(cache: CirClassifiersCache) : AbstractFunctionOrPropertyCommonizer<CirProperty>(cache) {
|
class PropertyCommonizer(cache: CirClassifiersCache) : AbstractFunctionOrPropertyCommonizer<CirProperty>(cache) {
|
||||||
private val setter = PropertySetterCommonizer()
|
private val setter = PropertySetterCommonizer()
|
||||||
private var isExternal = true
|
private var isExternal = true
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonProperty(
|
override fun commonizationResult(): CirProperty {
|
||||||
name = name,
|
val setter = setter.result
|
||||||
modality = modality.result,
|
|
||||||
visibility = visibility.result,
|
return CirPropertyFactory.create(
|
||||||
isExternal = isExternal,
|
annotations = emptyList(),
|
||||||
extensionReceiver = extensionReceiver.result,
|
name = name,
|
||||||
returnType = returnType.result,
|
typeParameters = typeParameters.result,
|
||||||
kind = kind,
|
visibility = visibility.result,
|
||||||
setter = setter.result,
|
modality = modality.result,
|
||||||
typeParameters = typeParameters.result
|
containingClassDetails = null,
|
||||||
)
|
isExternal = isExternal,
|
||||||
|
extensionReceiver = extensionReceiver.result,
|
||||||
|
returnType = returnType.result,
|
||||||
|
kind = kind,
|
||||||
|
isVar = setter != null,
|
||||||
|
isLateInit = false,
|
||||||
|
isConst = false,
|
||||||
|
isDelegate = false,
|
||||||
|
getter = CirPropertyGetterFactory.DEFAULT_NO_ANNOTATIONS,
|
||||||
|
setter = setter,
|
||||||
|
backingFieldAnnotations = null,
|
||||||
|
delegateFieldAnnotations = null,
|
||||||
|
compileTimeInitializer = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun doCommonizeWith(next: CirProperty): Boolean {
|
override fun doCommonizeWith(next: CirProperty): Boolean {
|
||||||
when {
|
when {
|
||||||
|
|||||||
+5
-4
@@ -6,11 +6,12 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirDeclarationWithVisibility
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirDeclarationWithVisibility
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirSetter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPropertySetter
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirPropertySetterFactory
|
||||||
|
|
||||||
class PropertySetterCommonizer : AbstractNullableCommonizer<CirSetter, CirSetter, CirDeclarationWithVisibility, Visibility>(
|
class PropertySetterCommonizer : AbstractNullableCommonizer<CirPropertySetter, CirPropertySetter, CirDeclarationWithVisibility, Visibility>(
|
||||||
wrappedCommonizerFactory = { VisibilityCommonizer.equalizing() },
|
wrappedCommonizerFactory = { VisibilityCommonizer.equalizing() },
|
||||||
extractor = { it },
|
extractor = { it },
|
||||||
builder = { CirSetter.createDefaultNoAnnotations(it) }
|
builder = CirPropertySetterFactory::createDefaultNoAnnotations
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-2
@@ -10,13 +10,14 @@ import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.BuiltInsProvider
|
import org.jetbrains.kotlin.descriptors.commonizer.BuiltInsProvider
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.InputTarget
|
import org.jetbrains.kotlin.descriptors.commonizer.InputTarget
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.OutputTarget
|
import org.jetbrains.kotlin.descriptors.commonizer.OutputTarget
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirRoot
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRoot
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirRootFactory
|
||||||
|
|
||||||
class RootCommonizer : AbstractStandardCommonizer<CirRoot, CirRoot>() {
|
class RootCommonizer : AbstractStandardCommonizer<CirRoot, CirRoot>() {
|
||||||
private val inputTargets = mutableSetOf<InputTarget>()
|
private val inputTargets = mutableSetOf<InputTarget>()
|
||||||
private var konanBuiltInsProvider: BuiltInsProvider? = null
|
private var konanBuiltInsProvider: BuiltInsProvider? = null
|
||||||
|
|
||||||
override fun commonizationResult() = CirRoot(
|
override fun commonizationResult() = CirRootFactory.create(
|
||||||
target = OutputTarget(inputTargets),
|
target = OutputTarget(inputTargets),
|
||||||
builtInsClass = if (konanBuiltInsProvider != null) KonanBuiltIns::class.java.name else DefaultBuiltIns::class.java.name,
|
builtInsClass = if (konanBuiltInsProvider != null) KonanBuiltIns::class.java.name else DefaultBuiltIns::class.java.name,
|
||||||
builtInsProvider = konanBuiltInsProvider ?: BuiltInsProvider.wrap(DefaultBuiltIns.Instance)
|
builtInsProvider = konanBuiltInsProvider ?: BuiltInsProvider.wrap(DefaultBuiltIns.Instance)
|
||||||
|
|||||||
+14
-5
@@ -7,7 +7,11 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class TypeAliasCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirTypeAlias, CirClass>() {
|
class TypeAliasCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirTypeAlias, CirClass>() {
|
||||||
@@ -15,15 +19,20 @@ class TypeAliasCommonizer(cache: CirClassifiersCache) : AbstractStandardCommoniz
|
|||||||
private val underlyingType = TypeCommonizer(cache)
|
private val underlyingType = TypeCommonizer(cache)
|
||||||
private val visibility = VisibilityCommonizer.lowering(allowPrivate = true)
|
private val visibility = VisibilityCommonizer.lowering(allowPrivate = true)
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonClass(
|
override fun commonizationResult() = CirClassFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
name = name,
|
name = name,
|
||||||
typeParameters = emptyList(),
|
typeParameters = emptyList(),
|
||||||
kind = ClassKind.CLASS,
|
|
||||||
modality = Modality.FINAL,
|
|
||||||
visibility = visibility.result,
|
visibility = visibility.result,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
companion = null,
|
||||||
isCompanion = false,
|
isCompanion = false,
|
||||||
|
isData = false,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isInner = false
|
isInner = false,
|
||||||
|
isExternal = false,
|
||||||
|
supertypes = mutableListOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun initialize(first: CirTypeAlias) {
|
override fun initialize(first: CirTypeAlias) {
|
||||||
|
|||||||
+7
-1
@@ -5,7 +5,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFlexibleType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirSimpleTypeKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirNode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
||||||
import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker
|
import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker
|
||||||
|
|
||||||
@@ -24,6 +29,7 @@ class TypeCommonizer(private val cache: CirClassifiersCache) : AbstractStandardC
|
|||||||
/**
|
/**
|
||||||
* See also [AbstractStrictEqualityTypeChecker].
|
* See also [AbstractStrictEqualityTypeChecker].
|
||||||
*/
|
*/
|
||||||
|
@Suppress("IntroduceWhenSubject")
|
||||||
internal fun areTypesEqual(cache: CirClassifiersCache, a: CirType, b: CirType): Boolean = when {
|
internal fun areTypesEqual(cache: CirClassifiersCache, a: CirType, b: CirType): Boolean = when {
|
||||||
a is CirSimpleType -> (b is CirSimpleType) && areSimpleTypesEqual(cache, a, b)
|
a is CirSimpleType -> (b is CirSimpleType) && areSimpleTypesEqual(cache, a, b)
|
||||||
a is CirFlexibleType -> (b is CirFlexibleType)
|
a is CirFlexibleType -> (b is CirFlexibleType)
|
||||||
|
|||||||
+6
-5
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonTypeParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeParameterFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirTypeParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
@@ -18,7 +18,8 @@ class TypeParameterCommonizer(cache: CirClassifiersCache) : AbstractStandardComm
|
|||||||
private lateinit var variance: Variance
|
private lateinit var variance: Variance
|
||||||
private val upperBounds = TypeParameterUpperBoundsCommonizer(cache)
|
private val upperBounds = TypeParameterUpperBoundsCommonizer(cache)
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonTypeParameter(
|
override fun commonizationResult() = CirTypeParameterFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
name = name,
|
name = name,
|
||||||
isReified = isReified,
|
isReified = isReified,
|
||||||
variance = variance,
|
variance = variance,
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirTypeParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class TypeParameterListCommonizer(cache: CirClassifiersCache) : AbstractListCommonizer<CirTypeParameter, CirTypeParameter>(
|
class TypeParameterListCommonizer(cache: CirClassifiersCache) : AbstractListCommonizer<CirTypeParameter, CirTypeParameter>(
|
||||||
singleElementCommonizerFactory = { TypeParameterCommonizer(cache) }
|
singleElementCommonizerFactory = { TypeParameterCommonizer(cache) }
|
||||||
|
|||||||
+7
-5
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirCommonValueParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirValueParameterFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirValueParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isNull
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isNull
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
@@ -19,10 +19,12 @@ class ValueParameterCommonizer(cache: CirClassifiersCache) : AbstractStandardCom
|
|||||||
private var isCrossinline = true
|
private var isCrossinline = true
|
||||||
private var isNoinline = true
|
private var isNoinline = true
|
||||||
|
|
||||||
override fun commonizationResult() = CirCommonValueParameter(
|
override fun commonizationResult() = CirValueParameterFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
name = name,
|
name = name,
|
||||||
returnType = returnType.result,
|
returnType = returnType.result,
|
||||||
varargElementType = varargElementType,
|
varargElementType = varargElementType,
|
||||||
|
declaresDefaultValue = false,
|
||||||
isCrossinline = isCrossinline,
|
isCrossinline = isCrossinline,
|
||||||
isNoinline = isNoinline
|
isNoinline = isNoinline
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirValueParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirClassifiersCache
|
||||||
|
|
||||||
class ValueParameterListCommonizer(cache: CirClassifiersCache) : AbstractListCommonizer<CirValueParameter, CirValueParameter>(
|
class ValueParameterListCommonizer(cache: CirClassifiersCache) : AbstractListCommonizer<CirValueParameter, CirValueParameter>(
|
||||||
singleElementCommonizerFactory = { ValueParameterCommonizer(cache) }
|
singleElementCommonizerFactory = { ValueParameterCommonizer(cache) }
|
||||||
|
|||||||
+5
-4
@@ -5,10 +5,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirDeclarationWithVisibility
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirFunctionOrProperty
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirDeclarationWithVisibility
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.isVirtual
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirFunctionOrProperty
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.isVirtual
|
||||||
|
|
||||||
abstract class VisibilityCommonizer(private val allowPrivate: Boolean) : Commonizer<CirDeclarationWithVisibility, Visibility> {
|
abstract class VisibilityCommonizer(private val allowPrivate: Boolean) : Commonizer<CirDeclarationWithVisibility, Visibility> {
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* 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.
|
* 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.mergedtree.ir
|
package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
||||||
|
|
||||||
interface CirNodeVisitor<R, T> {
|
interface CirNodeVisitor<R, T> {
|
||||||
fun visitRootNode(node: CirRootNode, data: T): R
|
fun visitRootNode(node: CirRootNode, data: T): R
|
||||||
-4
@@ -8,10 +8,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassifiersCache
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.buildClassConstructorNode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.buildFunctionNode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.buildPropertyNode
|
|
||||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -6,10 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirClassNode
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirRootNode.ClassifiersCacheImpl
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirRootNode.ClassifiersCacheImpl
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.buildClassNode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.buildTypeAliasNode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroupMap
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|||||||
-94
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.checkConstantSupportedInCommonization
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.constants.*
|
|
||||||
|
|
||||||
class CirAnnotation private constructor(
|
|
||||||
val fqName: FqName,
|
|
||||||
val constantValueArguments: Map<Name, ConstantValue<*>>,
|
|
||||||
val annotationValueArguments: Map<Name, CirAnnotation>
|
|
||||||
) {
|
|
||||||
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
|
||||||
private var cachedHashCode = 0
|
|
||||||
|
|
||||||
private fun computeHashCode() = hashCode(fqName)
|
|
||||||
.appendHashCode(constantValueArguments)
|
|
||||||
.appendHashCode(annotationValueArguments)
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
var currentHashCode = cachedHashCode
|
|
||||||
if (currentHashCode != 0) return currentHashCode
|
|
||||||
|
|
||||||
currentHashCode = computeHashCode()
|
|
||||||
cachedHashCode = currentHashCode
|
|
||||||
return currentHashCode
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (other === this) return true
|
|
||||||
|
|
||||||
return other is CirAnnotation
|
|
||||||
&& fqName == other.fqName
|
|
||||||
&& constantValueArguments == other.constantValueArguments
|
|
||||||
&& annotationValueArguments == other.annotationValueArguments
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val interner = Interner<CirAnnotation>()
|
|
||||||
|
|
||||||
fun create(original: AnnotationDescriptor): CirAnnotation {
|
|
||||||
val fqName: FqName = original.fqName?.intern() ?: error("Annotation with no FQ name: ${original::class.java}, $original")
|
|
||||||
|
|
||||||
val allValueArguments: Map<Name, ConstantValue<*>> = original.allValueArguments
|
|
||||||
if (allValueArguments.isEmpty())
|
|
||||||
return create(fqName = fqName, constantValueArguments = emptyMap(), annotationValueArguments = emptyMap())
|
|
||||||
|
|
||||||
val constantValueArguments: MutableMap<Name, ConstantValue<*>> = HashMap()
|
|
||||||
val annotationValueArguments: MutableMap<Name, CirAnnotation> = HashMap()
|
|
||||||
|
|
||||||
allValueArguments.forEach { (name, constantValue) ->
|
|
||||||
checkConstantSupportedInCommonization(
|
|
||||||
constantValue = constantValue,
|
|
||||||
constantName = name,
|
|
||||||
owner = original,
|
|
||||||
allowAnnotationValues = true
|
|
||||||
)
|
|
||||||
|
|
||||||
if (constantValue is AnnotationValue)
|
|
||||||
annotationValueArguments[name.intern()] = create(original = constantValue.value)
|
|
||||||
else
|
|
||||||
constantValueArguments[name.intern()] = constantValue
|
|
||||||
}
|
|
||||||
|
|
||||||
return create(
|
|
||||||
fqName = fqName,
|
|
||||||
constantValueArguments = constantValueArguments,
|
|
||||||
annotationValueArguments = annotationValueArguments
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(
|
|
||||||
fqName: FqName,
|
|
||||||
constantValueArguments: Map<Name, ConstantValue<*>>,
|
|
||||||
annotationValueArguments: Map<Name, CirAnnotation>
|
|
||||||
): CirAnnotation {
|
|
||||||
return interner.intern(
|
|
||||||
CirAnnotation(
|
|
||||||
fqName = fqName,
|
|
||||||
constantValueArguments = constantValueArguments,
|
|
||||||
annotationValueArguments = annotationValueArguments
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-112
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
|
||||||
|
|
||||||
interface CirClass : CirAnnotatedDeclaration, CirNamedDeclaration, CirDeclarationWithTypeParameters, CirDeclarationWithVisibility, CirDeclarationWithModality {
|
|
||||||
val companion: FqName? // null means no companion object
|
|
||||||
val kind: ClassKind
|
|
||||||
val isCompanion: Boolean
|
|
||||||
val isData: Boolean
|
|
||||||
val isInline: Boolean
|
|
||||||
val isInner: Boolean
|
|
||||||
val isExternal: Boolean
|
|
||||||
val supertypes: Collection<CirType>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CirClassConstructor : CirAnnotatedDeclaration, CirDeclarationWithTypeParameters, CirDeclarationWithVisibility, CirMaybeCallableMemberOfClass, CirCallableMemberWithParameters {
|
|
||||||
val isPrimary: Boolean
|
|
||||||
val kind: CallableMemberDescriptor.Kind
|
|
||||||
override val containingClassKind: ClassKind
|
|
||||||
override val containingClassModality: Modality
|
|
||||||
override val containingClassIsData: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirCommonClass(
|
|
||||||
override val name: Name,
|
|
||||||
override val typeParameters: List<CirTypeParameter>,
|
|
||||||
override val kind: ClassKind,
|
|
||||||
override val modality: Modality,
|
|
||||||
override val visibility: Visibility,
|
|
||||||
override val isCompanion: Boolean,
|
|
||||||
override val isInline: Boolean,
|
|
||||||
override val isInner: Boolean
|
|
||||||
) : CirClass {
|
|
||||||
override val annotations: List<CirAnnotation> get() = emptyList()
|
|
||||||
override val isData get() = false
|
|
||||||
override val isExternal get() = false
|
|
||||||
override var companion: FqName? = null
|
|
||||||
override val supertypes: MutableCollection<CirType> = ArrayList()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirCommonClassConstructor(
|
|
||||||
override val isPrimary: Boolean,
|
|
||||||
override val kind: CallableMemberDescriptor.Kind,
|
|
||||||
override val visibility: Visibility,
|
|
||||||
override val typeParameters: List<CirTypeParameter>,
|
|
||||||
override val valueParameters: List<CirValueParameter>,
|
|
||||||
override val hasStableParameterNames: Boolean,
|
|
||||||
override val hasSynthesizedParameterNames: Boolean
|
|
||||||
) : CirClassConstructor {
|
|
||||||
override val annotations: List<CirAnnotation> get() = emptyList()
|
|
||||||
override val containingClassKind get() = unsupported()
|
|
||||||
override val containingClassModality get() = unsupported()
|
|
||||||
override val containingClassIsData get() = unsupported()
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirClassImpl(original: ClassDescriptor) : CirClass {
|
|
||||||
override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
override val name = original.name.intern()
|
|
||||||
override val typeParameters = original.declaredTypeParameters.map(::CirTypeParameterImpl)
|
|
||||||
override val companion = original.companionObjectDescriptor?.fqNameSafe?.intern()
|
|
||||||
override val kind = original.kind
|
|
||||||
override val modality = original.modality
|
|
||||||
override val visibility = original.visibility
|
|
||||||
override val isCompanion = original.isCompanionObject
|
|
||||||
override val isData = original.isData
|
|
||||||
override val isInline = original.isInline
|
|
||||||
override val isInner = original.isInner
|
|
||||||
override val isExternal = original.isExternal
|
|
||||||
override val supertypes = original.typeConstructor.supertypes.map(CirType.Companion::create)
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirClassConstructorImpl(original: ClassConstructorDescriptor) : CirClassConstructor {
|
|
||||||
override val isPrimary = original.isPrimary
|
|
||||||
override val kind = original.kind
|
|
||||||
override val containingClassKind = original.containingDeclaration.kind
|
|
||||||
override val containingClassModality = original.containingDeclaration.modality
|
|
||||||
override val containingClassIsData = original.containingDeclaration.isData
|
|
||||||
override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
override val visibility = original.visibility
|
|
||||||
override val typeParameters = original.typeParameters.mapNotNull { typeParameter ->
|
|
||||||
// save only type parameters that are contributed by the constructor itself
|
|
||||||
typeParameter.takeIf { it.containingDeclaration == original }?.let(::CirTypeParameterImpl)
|
|
||||||
}
|
|
||||||
override val valueParameters = original.valueParameters.map(CirValueParameterImpl.Companion::create)
|
|
||||||
override val hasStableParameterNames = original.hasStableParameterNames()
|
|
||||||
override val hasSynthesizedParameterNames = original.hasSynthesizedParameterNames()
|
|
||||||
}
|
|
||||||
|
|
||||||
object CirClassRecursionMarker : CirClass, CirRecursionMarker {
|
|
||||||
override val companion get() = unsupported()
|
|
||||||
override val kind get() = unsupported()
|
|
||||||
override val modality get() = unsupported()
|
|
||||||
override val isCompanion get() = unsupported()
|
|
||||||
override val isData get() = unsupported()
|
|
||||||
override val isInline get() = unsupported()
|
|
||||||
override val isInner get() = unsupported()
|
|
||||||
override val isExternal get() = unsupported()
|
|
||||||
override val supertypes get() = unsupported()
|
|
||||||
override val annotations get() = unsupported()
|
|
||||||
override val name get() = unsupported()
|
|
||||||
override val visibility get() = unsupported()
|
|
||||||
override val typeParameters get() = unsupported()
|
|
||||||
}
|
|
||||||
-127
@@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.appendHashCode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
|
|
||||||
interface CirFunctionModifiers {
|
|
||||||
val isOperator: Boolean
|
|
||||||
val isInfix: Boolean
|
|
||||||
val isInline: Boolean
|
|
||||||
val isTailrec: Boolean
|
|
||||||
val isSuspend: Boolean
|
|
||||||
val isExternal: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CirCallableMemberWithParameters {
|
|
||||||
val valueParameters: List<CirValueParameter>
|
|
||||||
val hasStableParameterNames: Boolean
|
|
||||||
val hasSynthesizedParameterNames: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CirFunction : CirFunctionOrProperty, CirFunctionModifiers, CirCallableMemberWithParameters
|
|
||||||
|
|
||||||
data class CirCommonFunction(
|
|
||||||
override val annotations: List<CirAnnotation>,
|
|
||||||
override val name: Name,
|
|
||||||
override val modality: Modality,
|
|
||||||
override val visibility: Visibility,
|
|
||||||
override val extensionReceiver: CirExtensionReceiver?,
|
|
||||||
override val returnType: CirType,
|
|
||||||
override val kind: CallableMemberDescriptor.Kind,
|
|
||||||
private val modifiers: CirFunctionModifiers,
|
|
||||||
override val valueParameters: List<CirValueParameter>,
|
|
||||||
override val typeParameters: List<CirTypeParameter>,
|
|
||||||
override val hasStableParameterNames: Boolean,
|
|
||||||
override val hasSynthesizedParameterNames: Boolean
|
|
||||||
) : CirCommonFunctionOrProperty(), CirFunction, CirFunctionModifiers by modifiers
|
|
||||||
|
|
||||||
class CirFunctionImpl(original: SimpleFunctionDescriptor) : CirFunctionOrPropertyImpl<SimpleFunctionDescriptor>(original), CirFunction {
|
|
||||||
override val isOperator = original.isOperator
|
|
||||||
override val isInfix = original.isInfix
|
|
||||||
override val isInline = original.isInline
|
|
||||||
override val isTailrec = original.isTailrec
|
|
||||||
override val isSuspend = original.isSuspend
|
|
||||||
override val valueParameters = original.valueParameters.map(CirValueParameterImpl.Companion::create)
|
|
||||||
override val hasStableParameterNames = original.hasStableParameterNames()
|
|
||||||
override val hasSynthesizedParameterNames = original.hasSynthesizedParameterNames()
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CirValueParameter {
|
|
||||||
val name: Name
|
|
||||||
val annotations: List<CirAnnotation>
|
|
||||||
val returnType: CirType
|
|
||||||
val varargElementType: CirType?
|
|
||||||
val declaresDefaultValue: Boolean
|
|
||||||
val isCrossinline: Boolean
|
|
||||||
val isNoinline: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirCommonValueParameter(
|
|
||||||
override val name: Name,
|
|
||||||
override val returnType: CirType,
|
|
||||||
override val varargElementType: CirType?,
|
|
||||||
override val isCrossinline: Boolean,
|
|
||||||
override val isNoinline: Boolean
|
|
||||||
) : CirValueParameter {
|
|
||||||
override val annotations: List<CirAnnotation> get() = emptyList()
|
|
||||||
override val declaresDefaultValue get() = false
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirValueParameterImpl private constructor(original: ValueParameterDescriptor) : CirValueParameter {
|
|
||||||
override val name = original.name.intern()
|
|
||||||
override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
override val returnType = CirType.create(original.returnType!!)
|
|
||||||
override val varargElementType = original.varargElementType?.let(CirType.Companion::create)
|
|
||||||
override val declaresDefaultValue = original.declaresDefaultValue()
|
|
||||||
override val isCrossinline = original.isCrossinline
|
|
||||||
override val isNoinline = original.isNoinline
|
|
||||||
|
|
||||||
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
|
||||||
private var cachedHashCode = 0
|
|
||||||
|
|
||||||
private fun computeHashCode() = hashCode(name)
|
|
||||||
.appendHashCode(annotations)
|
|
||||||
.appendHashCode(returnType)
|
|
||||||
.appendHashCode(varargElementType)
|
|
||||||
.appendHashCode(declaresDefaultValue)
|
|
||||||
.appendHashCode(isCrossinline)
|
|
||||||
.appendHashCode(isNoinline)
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
var currentHashCode = cachedHashCode
|
|
||||||
if (currentHashCode != 0) return currentHashCode
|
|
||||||
|
|
||||||
currentHashCode = computeHashCode()
|
|
||||||
cachedHashCode = currentHashCode
|
|
||||||
return currentHashCode
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = when {
|
|
||||||
other === this -> true
|
|
||||||
other is CirValueParameterImpl -> {
|
|
||||||
name == other.name
|
|
||||||
&& returnType == other.returnType
|
|
||||||
&& annotations == other.annotations
|
|
||||||
&& varargElementType == other.varargElementType
|
|
||||||
&& declaresDefaultValue == other.declaresDefaultValue
|
|
||||||
&& isCrossinline == other.isCrossinline
|
|
||||||
&& isNoinline == other.isNoinline
|
|
||||||
}
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val interner = Interner<CirValueParameterImpl>()
|
|
||||||
|
|
||||||
fun create(original: ValueParameterDescriptor): CirValueParameterImpl = interner.intern(CirValueParameterImpl(original))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirExtensionReceiver.Companion.toReceiver
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
|
|
||||||
interface CirFunctionOrProperty : CirAnnotatedDeclaration, CirNamedDeclaration, CirDeclarationWithTypeParameters,
|
|
||||||
CirDeclarationWithVisibility, CirDeclarationWithModality, CirMaybeCallableMemberOfClass {
|
|
||||||
val isExternal: Boolean
|
|
||||||
val extensionReceiver: CirExtensionReceiver?
|
|
||||||
val returnType: CirType
|
|
||||||
val kind: CallableMemberDescriptor.Kind
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class CirCommonFunctionOrProperty : CirFunctionOrProperty {
|
|
||||||
final override val containingClassKind: ClassKind? get() = unsupported()
|
|
||||||
final override val containingClassModality: Modality? get() = unsupported()
|
|
||||||
final override val containingClassIsData: Boolean? get() = unsupported()
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class CirFunctionOrPropertyImpl<T : CallableMemberDescriptor>(original: T) : CirFunctionOrProperty {
|
|
||||||
final override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
final override val name = original.name.intern()
|
|
||||||
final override val modality = original.modality
|
|
||||||
final override val visibility = original.visibility
|
|
||||||
final override val isExternal = original.isExternal
|
|
||||||
final override val extensionReceiver = original.extensionReceiverParameter?.toReceiver()
|
|
||||||
final override val returnType = CirType.create(original.returnType!!)
|
|
||||||
final override val kind = original.kind
|
|
||||||
final override val containingClassKind: ClassKind?
|
|
||||||
final override val containingClassModality: Modality?
|
|
||||||
final override val containingClassIsData: Boolean?
|
|
||||||
final override val typeParameters = original.typeParameters.map(::CirTypeParameterImpl)
|
|
||||||
|
|
||||||
init {
|
|
||||||
val containingClass = original.containingDeclaration as? ClassDescriptor
|
|
||||||
containingClassKind = containingClass?.kind
|
|
||||||
containingClassModality = containingClass?.modality
|
|
||||||
containingClassIsData = containingClass?.isData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirExtensionReceiver(
|
|
||||||
val annotations: List<CirAnnotation>,
|
|
||||||
val type: CirType
|
|
||||||
) {
|
|
||||||
companion object {
|
|
||||||
fun CirType.toReceiverNoAnnotations() = CirExtensionReceiver(annotations = emptyList(), type = this)
|
|
||||||
|
|
||||||
fun ReceiverParameterDescriptor.toReceiver() = CirExtensionReceiver(
|
|
||||||
annotations = annotations.map(CirAnnotation.Companion::create),
|
|
||||||
type = CirType.create(type)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun CirFunctionOrProperty.isNonAbstractMemberInInterface() =
|
|
||||||
modality != Modality.ABSTRACT && containingClassKind == ClassKind.INTERFACE
|
|
||||||
|
|
||||||
fun CirFunctionOrProperty.isVirtual() =
|
|
||||||
visibility != Visibilities.PRIVATE
|
|
||||||
&& modality != Modality.FINAL
|
|
||||||
&& !(containingClassModality == Modality.FINAL && containingClassKind != ClassKind.ENUM_CLASS)
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
|
|
||||||
data class CirModule(val name: Name) : CirDeclaration {
|
|
||||||
constructor(descriptor: ModuleDescriptor) : this(descriptor.name.intern())
|
|
||||||
}
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
|
|
||||||
data class CirPackage(val fqName: FqName) : CirDeclaration
|
|
||||||
-147
@@ -1,147 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirGetter.Companion.toGetter
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirSetter.Companion.toSetter
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.checkConstantSupportedInCommonization
|
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
|
||||||
|
|
||||||
interface CirProperty : CirFunctionOrProperty {
|
|
||||||
val isVar: Boolean
|
|
||||||
val isLateInit: Boolean
|
|
||||||
val isConst: Boolean
|
|
||||||
val isDelegate: Boolean
|
|
||||||
val getter: CirGetter?
|
|
||||||
val setter: CirSetter?
|
|
||||||
val backingFieldAnnotations: List<CirAnnotation>? // null assumes no backing field
|
|
||||||
val delegateFieldAnnotations: List<CirAnnotation>? // null assumes no backing field
|
|
||||||
val compileTimeInitializer: ConstantValue<*>?
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirCommonProperty(
|
|
||||||
override val name: Name,
|
|
||||||
override val modality: Modality,
|
|
||||||
override val visibility: Visibility,
|
|
||||||
override val isExternal: Boolean,
|
|
||||||
override val extensionReceiver: CirExtensionReceiver?,
|
|
||||||
override val returnType: CirType,
|
|
||||||
override val kind: CallableMemberDescriptor.Kind,
|
|
||||||
override val setter: CirSetter?,
|
|
||||||
override val typeParameters: List<CirTypeParameter>
|
|
||||||
) : CirCommonFunctionOrProperty(), CirProperty {
|
|
||||||
override val annotations: List<CirAnnotation> get() = emptyList()
|
|
||||||
override val isVar get() = setter != null
|
|
||||||
override val isLateInit get() = false
|
|
||||||
override val isConst get() = false
|
|
||||||
override val isDelegate get() = false
|
|
||||||
override val getter get() = CirGetter.DEFAULT_NO_ANNOTATIONS
|
|
||||||
override val backingFieldAnnotations: List<CirAnnotation>? get() = null
|
|
||||||
override val delegateFieldAnnotations: List<CirAnnotation>? get() = null
|
|
||||||
override val compileTimeInitializer: ConstantValue<*>? get() = null
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirPropertyImpl(original: PropertyDescriptor) : CirFunctionOrPropertyImpl<PropertyDescriptor>(original), CirProperty {
|
|
||||||
override val isVar = original.isVar
|
|
||||||
override val isLateInit = original.isLateInit
|
|
||||||
override val isConst = original.isConst
|
|
||||||
override val isDelegate = @Suppress("DEPRECATION") original.isDelegated
|
|
||||||
override val getter = original.getter?.toGetter()
|
|
||||||
override val setter = original.setter?.toSetter()
|
|
||||||
override val backingFieldAnnotations = original.backingField?.annotations?.map(CirAnnotation.Companion::create)
|
|
||||||
override val delegateFieldAnnotations = original.delegateField?.annotations?.map(CirAnnotation.Companion::create)
|
|
||||||
override val compileTimeInitializer = original.compileTimeInitializer
|
|
||||||
|
|
||||||
init {
|
|
||||||
compileTimeInitializer?.let { compileTimeInitializer ->
|
|
||||||
checkConstantSupportedInCommonization(
|
|
||||||
constantValue = compileTimeInitializer,
|
|
||||||
owner = original,
|
|
||||||
allowAnnotationValues = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CirPropertyAccessor {
|
|
||||||
val annotations: List<CirAnnotation>
|
|
||||||
val isDefault: Boolean
|
|
||||||
val isExternal: Boolean
|
|
||||||
val isInline: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("DataClassPrivateConstructor")
|
|
||||||
data class CirGetter private constructor(
|
|
||||||
override val annotations: List<CirAnnotation>,
|
|
||||||
override val isDefault: Boolean,
|
|
||||||
override val isExternal: Boolean,
|
|
||||||
override val isInline: Boolean
|
|
||||||
) : CirPropertyAccessor {
|
|
||||||
companion object {
|
|
||||||
private val interner = Interner<CirGetter>()
|
|
||||||
|
|
||||||
val DEFAULT_NO_ANNOTATIONS = interner.intern(
|
|
||||||
CirGetter(
|
|
||||||
annotations = emptyList(),
|
|
||||||
isDefault = true,
|
|
||||||
isExternal = false,
|
|
||||||
isInline = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun PropertyGetterDescriptor.toGetter() =
|
|
||||||
if (isDefault && annotations.isEmpty())
|
|
||||||
DEFAULT_NO_ANNOTATIONS
|
|
||||||
else
|
|
||||||
interner.intern(
|
|
||||||
CirGetter(
|
|
||||||
annotations = annotations.map(CirAnnotation.Companion::create),
|
|
||||||
isDefault = isDefault,
|
|
||||||
isExternal = isExternal,
|
|
||||||
isInline = isInline
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("DataClassPrivateConstructor")
|
|
||||||
data class CirSetter private constructor(
|
|
||||||
override val annotations: List<CirAnnotation>,
|
|
||||||
val parameterAnnotations: List<CirAnnotation>,
|
|
||||||
override val visibility: Visibility,
|
|
||||||
override val isDefault: Boolean,
|
|
||||||
override val isExternal: Boolean,
|
|
||||||
override val isInline: Boolean
|
|
||||||
) : CirPropertyAccessor, CirDeclarationWithVisibility {
|
|
||||||
companion object {
|
|
||||||
private val interner = Interner<CirSetter>()
|
|
||||||
|
|
||||||
fun createDefaultNoAnnotations(visibility: Visibility) = interner.intern(
|
|
||||||
CirSetter(
|
|
||||||
annotations = emptyList(),
|
|
||||||
parameterAnnotations = emptyList(),
|
|
||||||
visibility = visibility,
|
|
||||||
isDefault = visibility == Visibilities.PUBLIC,
|
|
||||||
isExternal = false,
|
|
||||||
isInline = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun PropertySetterDescriptor.toSetter() = interner.intern(
|
|
||||||
CirSetter(
|
|
||||||
annotations = annotations.map(CirAnnotation.Companion::create),
|
|
||||||
parameterAnnotations = valueParameters.single().annotations.map(CirAnnotation.Companion::create),
|
|
||||||
visibility = visibility,
|
|
||||||
isDefault = isDefault,
|
|
||||||
isExternal = isExternal,
|
|
||||||
isInline = isInline
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.BuiltInsProvider
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.InputTarget
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.Target
|
|
||||||
|
|
||||||
data class CirRoot(
|
|
||||||
val target: Target,
|
|
||||||
val builtInsClass: String,
|
|
||||||
val builtInsProvider: BuiltInsProvider
|
|
||||||
) : CirDeclaration {
|
|
||||||
init {
|
|
||||||
if (target is InputTarget) {
|
|
||||||
check((target.konanTarget != null) == (builtInsClass == KonanBuiltIns::class.java.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-134
@@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirSimpleTypeKind.CLASS
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir.CirSimpleTypeKind.TYPE_ALIAS
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.types.*
|
|
||||||
|
|
||||||
sealed class CirType {
|
|
||||||
companion object {
|
|
||||||
fun create(type: KotlinType): CirType = type.unwrap().run {
|
|
||||||
when (this) {
|
|
||||||
is SimpleType -> CirSimpleType.create(this)
|
|
||||||
is FlexibleType -> CirFlexibleType(CirSimpleType.create(lowerBound), CirSimpleType.create(upperBound))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All attributes except for [expandedTypeConstructorId] are read from the abbreviation type: [AbbreviatedType.abbreviation].
|
|
||||||
* And [expandedTypeConstructorId] is read from the expanded type: [AbbreviatedType.expandedType].
|
|
||||||
*
|
|
||||||
* This is necessary to properly compare types for type aliases, where abbreviation type represents the type alias itself while
|
|
||||||
* expanded type represents right-hand side declaration that should be processed separately.
|
|
||||||
*
|
|
||||||
* There is no difference between "abbreviation" and "expanded" for types representing classes and type parameters.
|
|
||||||
*
|
|
||||||
* Note: Annotations at simple types are not preserved. After commonization all annotations assigned to types will be lost.
|
|
||||||
*/
|
|
||||||
class CirSimpleType private constructor(original: SimpleType) : CirType() {
|
|
||||||
val kind: CirSimpleTypeKind
|
|
||||||
val fqName: FqName
|
|
||||||
val arguments: List<CirTypeProjection>
|
|
||||||
val isMarkedNullable: Boolean
|
|
||||||
val isDefinitelyNotNullType: Boolean
|
|
||||||
val expandedTypeConstructorId: CirTypeConstructorId
|
|
||||||
|
|
||||||
init {
|
|
||||||
val abbreviation = (original as? AbbreviatedType)?.abbreviation ?: original
|
|
||||||
val expanded = (original as? AbbreviatedType)?.expandedType ?: original
|
|
||||||
|
|
||||||
kind = CirSimpleTypeKind.determineKind(abbreviation.declarationDescriptor)
|
|
||||||
fqName = abbreviation.fqNameInterned
|
|
||||||
arguments = abbreviation.arguments.map(::CirTypeProjection)
|
|
||||||
isMarkedNullable = abbreviation.isMarkedNullable
|
|
||||||
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType
|
|
||||||
expandedTypeConstructorId = CirTypeConstructorId(expanded)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline val isClassOrTypeAlias get() = (kind == CLASS || kind == TYPE_ALIAS)
|
|
||||||
val fqNameWithTypeParameters = original.fqNameWithTypeParameters
|
|
||||||
|
|
||||||
override fun equals(other: Any?) = when {
|
|
||||||
other === this -> true
|
|
||||||
other is CirSimpleType -> {
|
|
||||||
isMarkedNullable == other.isMarkedNullable
|
|
||||||
&& fqName == other.fqName
|
|
||||||
&& kind == other.kind
|
|
||||||
&& arguments == other.arguments
|
|
||||||
&& fqNameWithTypeParameters == other.fqNameWithTypeParameters
|
|
||||||
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
|
|
||||||
}
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
|
|
||||||
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
|
||||||
private var cachedHashCode = 0
|
|
||||||
|
|
||||||
private fun computeHashCode() = hashCode(kind)
|
|
||||||
.appendHashCode(fqName)
|
|
||||||
.appendHashCode(arguments)
|
|
||||||
.appendHashCode(isMarkedNullable)
|
|
||||||
.appendHashCode(isDefinitelyNotNullType)
|
|
||||||
.appendHashCode(fqNameWithTypeParameters)
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
var currentHashCode = cachedHashCode
|
|
||||||
if (currentHashCode != 0) return currentHashCode
|
|
||||||
|
|
||||||
currentHashCode = computeHashCode()
|
|
||||||
cachedHashCode = currentHashCode
|
|
||||||
return currentHashCode
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val interner = Interner<CirSimpleType>()
|
|
||||||
|
|
||||||
fun create(original: SimpleType): CirSimpleType = interner.intern(CirSimpleType(original))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class CirSimpleTypeKind {
|
|
||||||
CLASS,
|
|
||||||
TYPE_ALIAS,
|
|
||||||
TYPE_PARAMETER;
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun determineKind(classifier: ClassifierDescriptor) = when (classifier) {
|
|
||||||
is ClassDescriptor -> CLASS
|
|
||||||
is TypeAliasDescriptor -> TYPE_ALIAS
|
|
||||||
is TypeParameterDescriptor -> TYPE_PARAMETER
|
|
||||||
else -> error("Unexpected classifier descriptor type: ${classifier::class.java}, $classifier")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun areCompatible(expect: CirSimpleTypeKind, actual: CirSimpleTypeKind) =
|
|
||||||
expect == actual || (expect == CLASS && actual == TYPE_ALIAS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirTypeConstructorId(val fqName: FqName, val numberOfTypeParameters: Int) {
|
|
||||||
constructor(type: SimpleType) : this(type.fqNameInterned, type.constructor.parameters.size)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirTypeProjection(val projectionKind: Variance, val isStarProjection: Boolean, val type: CirType) {
|
|
||||||
constructor(original: TypeProjection) : this(original.projectionKind, original.isStarProjection, CirType.create(original.type))
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType()
|
|
||||||
|
|
||||||
val CirType.fqNameWithTypeParameters: String
|
|
||||||
get() = when (this) {
|
|
||||||
is CirSimpleType -> fqNameWithTypeParameters
|
|
||||||
is CirFlexibleType -> lowerBound.fqNameWithTypeParameters
|
|
||||||
}
|
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
|
|
||||||
interface CirTypeAlias : CirAnnotatedDeclaration, CirNamedDeclaration, CirDeclarationWithTypeParameters, CirDeclarationWithVisibility {
|
|
||||||
val underlyingType: CirSimpleType
|
|
||||||
val expandedType: CirSimpleType
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirTypeAliasImpl(original: TypeAliasDescriptor) : CirTypeAlias {
|
|
||||||
override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
override val name = original.name.intern()
|
|
||||||
override val typeParameters = original.declaredTypeParameters.map(::CirTypeParameterImpl)
|
|
||||||
override val visibility = original.visibility
|
|
||||||
override val underlyingType = CirSimpleType.create(original.underlyingType)
|
|
||||||
override val expandedType = CirSimpleType.create(original.expandedType)
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.mergedtree.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
|
|
||||||
interface CirTypeParameter {
|
|
||||||
val annotations: List<CirAnnotation>
|
|
||||||
val name: Name
|
|
||||||
val isReified: Boolean
|
|
||||||
val variance: Variance
|
|
||||||
val upperBounds: List<CirType>
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CirCommonTypeParameter(
|
|
||||||
override val name: Name,
|
|
||||||
override val isReified: Boolean,
|
|
||||||
override val variance: Variance,
|
|
||||||
override val upperBounds: List<CirType>
|
|
||||||
) : CirTypeParameter {
|
|
||||||
override val annotations: List<CirAnnotation> get() = emptyList()
|
|
||||||
}
|
|
||||||
|
|
||||||
class CirTypeParameterImpl(original: TypeParameterDescriptor) : CirTypeParameter {
|
|
||||||
override val annotations = original.annotations.map(CirAnnotation.Companion::create)
|
|
||||||
override val name = original.name.intern()
|
|
||||||
override val isReified = original.isReified
|
|
||||||
override val variance = original.variance
|
|
||||||
override val upperBounds = original.upperBounds.map(CirType.Companion::create)
|
|
||||||
}
|
|
||||||
-4
@@ -8,10 +8,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.core.Commonizer
|
import org.jetbrains.kotlin.descriptors.commonizer.core.Commonizer
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.fqNameWithTypeParameters
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isBlacklistedDarwinFunction
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isDeprecatedTopLevelFunction
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isKniBridgeFunction
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user