diff --git a/compiler/cli/cli-common/resources/META-INF/extensions/compiler.xml b/compiler/cli/cli-common/resources/META-INF/extensions/compiler.xml
index 7aa07b199d1..db536f39d44 100644
--- a/compiler/cli/cli-common/resources/META-INF/extensions/compiler.xml
+++ b/compiler/cli/cli-common/resources/META-INF/extensions/compiler.xml
@@ -11,8 +11,8 @@
-
): List {
+ @Suppress("UNCHECKED_CAST")
+ types as List
+ return types.map { it.attributes }.reduce { x, y -> x.union(y) }.toList()
+ }
+
+ override fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List): KotlinTypeMarker {
+ require(this is ConeKotlinType)
+ val typeAttributes = newAttributes.filterIsInstance>()
+ require(typeAttributes.size == newAttributes.size)
+ if (newAttributes.isEmpty()) return this
+ return createSimpleType(this.typeConstructor(), this.getArguments(), this.isNullable, this.isExtensionFunctionType, typeAttributes)
+ }
+
override fun TypeConstructorMarker.getApproximatedIntegerLiteralType(): KotlinTypeMarker {
require(this is ConeIntegerLiteralType)
return this.getApproximatedType()
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
index 90f1459a2e1..cd6bbd448a4 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations
import org.jetbrains.kotlin.descriptors.impl.VariableDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.Errors.*
-import org.jetbrains.kotlin.extensions.TypeAttributeTranslators
+import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslators
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
index 543ed606e1b..9be8078bfb0 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
@@ -383,6 +383,10 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
override fun findCommonIntegerLiteralTypesSuperType(explicitSupertypes: List): SimpleTypeMarker? =
irBuiltIns.intType as IrSimpleType
+ override fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List): KotlinTypeMarker = this
+
+ override fun unionTypeAttributes(types: List): List = emptyList()
+
override fun KotlinTypeMarker.isNullableType(): Boolean =
this is IrType && isNullable()
diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
index 1e0cc26db0f..f313877d7dd 100644
--- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
+++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
@@ -134,9 +134,9 @@ interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeF
*/
fun TypeConstructorMarker.toErrorType(): SimpleTypeMarker
- fun unionTypeAttributes(types: List): List = emptyList()
+ fun unionTypeAttributes(types: List): List
- fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List): KotlinTypeMarker = this
+ fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List): KotlinTypeMarker
}
// This interface is only used to declare that implementing class is supposed to be used as a TypeSystemInferenceExtensionContext component
diff --git a/core/descriptors/build.gradle.kts b/core/descriptors/build.gradle.kts
index c39470e3d59..947981536be 100644
--- a/core/descriptors/build.gradle.kts
+++ b/core/descriptors/build.gradle.kts
@@ -10,6 +10,8 @@ dependencies {
api(project(":core:util.runtime"))
api(kotlinStdlib())
api(project(":kotlin-annotations-jvm"))
+ api(project(":compiler:util"))
+ compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
}
sourceSets {
diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAttributesTranslator.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAttributesTranslator.kt
index c7ad12d99c3..7263c4b001c 100644
--- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAttributesTranslator.kt
+++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAttributesTranslator.kt
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
interface TypeAttributesTranslator {
fun toAttributes(annotations: Annotations): TypeAttributes
- fun toAnnotations(attributes: TypeAttributes): Annotations?
+ fun toAnnotations(attributes: TypeAttributes): Annotations
}
object DefaultTypeAttributesTranslator : TypeAttributesTranslator {
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/extensions/TypeAttributeTranslators.kt b/core/descriptors/src/org/jetbrains/kotlin/types/extensions/TypeAttributeTranslators.kt
similarity index 84%
rename from compiler/frontend/src/org/jetbrains/kotlin/extensions/TypeAttributeTranslators.kt
rename to core/descriptors/src/org/jetbrains/kotlin/types/extensions/TypeAttributeTranslators.kt
index 2591c67b808..7280acbcb64 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/extensions/TypeAttributeTranslators.kt
+++ b/core/descriptors/src/org/jetbrains/kotlin/types/extensions/TypeAttributeTranslators.kt
@@ -3,10 +3,11 @@
* 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.extensions
+package org.jetbrains.kotlin.types.extensions
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.annotations.Annotations
+import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
import org.jetbrains.kotlin.types.*
interface TypeAttributeTranslatorExtension : TypeAttributesTranslator
@@ -16,14 +17,14 @@ class TypeAttributeTranslators(project: Project) {
getInstances(project) + DefaultTypeAttributesTranslator
fun toAttributes(annotations: Annotations): TypeAttributes {
- val translated = translators.mapNotNull { translator ->
+ val translated = translators.map { translator ->
translator.toAttributes(annotations)
}.flatten()
return TypeAttributes.create(translated)
}
fun toAnnotations(attributes: TypeAttributes): Annotations {
- val translated = translators.mapNotNull { translator ->
+ val translated = translators.map { translator ->
translator.toAnnotations(attributes)
}.flatten()
return Annotations.create(translated)