[K/JS] Change strategy for implicitly exported declarations if there is a cycled reference
^KT-57356 Fixed
This commit is contained in:
+6
-2
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.backend.js.export
|
package org.jetbrains.kotlin.ir.backend.js.export
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isExpect
|
import org.jetbrains.kotlin.backend.common.ir.isExpect
|
||||||
import org.jetbrains.kotlin.builtins.StandardNames
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||||
@@ -556,13 +555,17 @@ class ExportModelGenerator(val context: JsIrBackendContext, val generateNamespac
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val currentlyProcessedTypes = hashSetOf<IrType>()
|
||||||
|
|
||||||
private fun exportType(type: IrType, shouldCalculateExportedSupertypeForImplicit: Boolean = true): ExportedType {
|
private fun exportType(type: IrType, shouldCalculateExportedSupertypeForImplicit: Boolean = true): ExportedType {
|
||||||
if (type is IrDynamicType)
|
if (type is IrDynamicType || type in currentlyProcessedTypes)
|
||||||
return ExportedType.Primitive.Any
|
return ExportedType.Primitive.Any
|
||||||
|
|
||||||
if (type !is IrSimpleType)
|
if (type !is IrSimpleType)
|
||||||
return ExportedType.ErrorType("NonSimpleType ${type.render()}")
|
return ExportedType.ErrorType("NonSimpleType ${type.render()}")
|
||||||
|
|
||||||
|
currentlyProcessedTypes.add(type)
|
||||||
|
|
||||||
val classifier = type.classifier
|
val classifier = type.classifier
|
||||||
val isMarkedNullable = type.isMarkedNullable()
|
val isMarkedNullable = type.isMarkedNullable()
|
||||||
val nonNullType = type.makeNotNull() as IrSimpleType
|
val nonNullType = type.makeNotNull() as IrSimpleType
|
||||||
@@ -632,6 +635,7 @@ class ExportModelGenerator(val context: JsIrBackendContext, val generateNamespac
|
|||||||
}
|
}
|
||||||
|
|
||||||
return exportedType.withNullability(isMarkedNullable)
|
return exportedType.withNullability(isMarkedNullable)
|
||||||
|
.also { currentlyProcessedTypes.remove(type) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrDeclarationWithName.getExportedIdentifier(): String =
|
private fun IrDeclarationWithName.getExportedIdentifier(): String =
|
||||||
|
|||||||
+14
@@ -45,5 +45,19 @@ declare namespace JS_TESTS {
|
|||||||
class TheNewException extends Error {
|
class TheNewException extends Error {
|
||||||
constructor();
|
constructor();
|
||||||
}
|
}
|
||||||
|
interface Service<Self extends foo.Service<Self, TEvent>, TEvent extends foo.Event<Self>> {
|
||||||
|
readonly __doNotUseOrImplementIt: {
|
||||||
|
readonly "foo.Service": unique symbol;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface Event<TService extends foo.Service<TService, any /*UnknownType **/>> {
|
||||||
|
readonly __doNotUseOrImplementIt: {
|
||||||
|
readonly "foo.Event": unique symbol;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
class SomeServiceRequest implements foo.Service<any/* foo.SomeService */, foo.Event<any/* foo.SomeService */>/* foo.SomeEvent */> {
|
||||||
|
constructor();
|
||||||
|
readonly __doNotUseOrImplementIt: foo.Service<any/* foo.SomeService */, foo.Event<any/* foo.SomeService */>/* foo.SomeEvent */>["__doNotUseOrImplementIt"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
@@ -96,3 +96,16 @@ fun functionWithTypeAliasInside(x: NotExportedTypeAlias): NotExportedTypeAlias {
|
|||||||
|
|
||||||
@JsExport
|
@JsExport
|
||||||
class TheNewException: Throwable()
|
class TheNewException: Throwable()
|
||||||
|
|
||||||
|
// Recursive definition KT-57356
|
||||||
|
@JsExport
|
||||||
|
interface Service<Self : Service<Self, TEvent>, in TEvent : Event<Self>>
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
interface Event<out TService : Service<out TService, *>>
|
||||||
|
|
||||||
|
class SomeService : Service<SomeService, SomeEvent>
|
||||||
|
class SomeEvent : Event<SomeService>
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
class SomeServiceRequest : Service<SomeService, SomeEvent>
|
||||||
|
|||||||
Vendored
+14
@@ -79,6 +79,20 @@ declare namespace JS_TESTS {
|
|||||||
}
|
}
|
||||||
function acceptForthLike<T extends foo.Forth>(forth: T): void;
|
function acceptForthLike<T extends foo.Forth>(forth: T): void;
|
||||||
function acceptMoreGenericForthLike<T extends foo.IB & foo.IC & foo.Third>(forth: T): void;
|
function acceptMoreGenericForthLike<T extends foo.IB & foo.IC & foo.Third>(forth: T): void;
|
||||||
|
interface Service<Self extends foo.Service<Self, TEvent>, TEvent extends foo.Event<Self>> {
|
||||||
|
readonly __doNotUseOrImplementIt: {
|
||||||
|
readonly "foo.Service": unique symbol;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface Event<TService extends foo.Service<TService, any /*UnknownType **/>> {
|
||||||
|
readonly __doNotUseOrImplementIt: {
|
||||||
|
readonly "foo.Event": unique symbol;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
class SomeServiceRequest implements foo.Service<any/* foo.SomeService */, foo.Event<any/* foo.SomeService */>/* foo.SomeEvent */> {
|
||||||
|
constructor();
|
||||||
|
readonly __doNotUseOrImplementIt: foo.Service<any/* foo.SomeService */, foo.Event<any/* foo.SomeService */>/* foo.SomeEvent */>["__doNotUseOrImplementIt"];
|
||||||
|
}
|
||||||
interface NonExportedParent {
|
interface NonExportedParent {
|
||||||
readonly __doNotUseOrImplementIt: {
|
readonly __doNotUseOrImplementIt: {
|
||||||
readonly "foo.NonExportedParent": unique symbol;
|
readonly "foo.NonExportedParent": unique symbol;
|
||||||
|
|||||||
Vendored
+13
@@ -167,3 +167,16 @@ fun <T> acceptMoreGenericForthLike(forth: T) where T: IB, T: IC, T: Third {}
|
|||||||
|
|
||||||
@JsExport
|
@JsExport
|
||||||
val forth = Forth()
|
val forth = Forth()
|
||||||
|
|
||||||
|
// Recursive definition KT-57356
|
||||||
|
@JsExport
|
||||||
|
interface Service<Self : Service<Self, TEvent>, in TEvent : Event<Self>>
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
interface Event<out TService : Service<out TService, *>>
|
||||||
|
|
||||||
|
class SomeService : Service<SomeService, SomeEvent>
|
||||||
|
class SomeEvent : Event<SomeService>
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
class SomeServiceRequest : Service<SomeService, SomeEvent>
|
||||||
|
|||||||
Reference in New Issue
Block a user