From fa9e1f5b57b7ec7aec03091637e3dc1956d865d7 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Wed, 31 Jul 2024 13:34:01 -0400 Subject: [PATCH] Seal the protocol factory interface (#2215) The only subtype should be the generated interface which is itself open to new subtypes. --- CHANGELOG.md | 2 +- .../api/redwood-protocol-host.klib.api | 10 +++++----- .../app/cash/redwood/protocol/host/ProtocolFactory.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c380a38d..89c5b5aacf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ New: - Introduce a `LoadingStrategy` interface to manage `LazyList` preloading. Changed: -- Nothing yet! +- `ProtocolFactory` interface is now sealed as arbitrary subtypes were never supported. Only schema-generated subtypes should be used. Fixed: - Nothing yet! diff --git a/redwood-protocol-host/api/redwood-protocol-host.klib.api b/redwood-protocol-host/api/redwood-protocol-host.klib.api index 327e90bef7..23ad9f283b 100644 --- a/redwood-protocol-host/api/redwood-protocol-host.klib.api +++ b/redwood-protocol-host/api/redwood-protocol-host.klib.api @@ -12,11 +12,6 @@ abstract interface <#A: kotlin/Any> app.cash.redwood.protocol.host/GeneratedProt abstract fun widgetChildren(app.cash.redwood.protocol/WidgetTag): kotlin.collections/List // app.cash.redwood.protocol.host/GeneratedProtocolFactory.widgetChildren|widgetChildren(app.cash.redwood.protocol.WidgetTag){}[0] } -abstract interface <#A: kotlin/Any> app.cash.redwood.protocol.host/ProtocolFactory { // app.cash.redwood.protocol.host/ProtocolFactory|null[0] - abstract val widgetSystem // app.cash.redwood.protocol.host/ProtocolFactory.widgetSystem|{}widgetSystem[0] - abstract fun (): app.cash.redwood.widget/WidgetSystem<#A> // app.cash.redwood.protocol.host/ProtocolFactory.widgetSystem.|(){}[0] -} - abstract interface app.cash.redwood.protocol.host/ProtocolMismatchHandler { // app.cash.redwood.protocol.host/ProtocolMismatchHandler|null[0] abstract fun onUnknownChildren(app.cash.redwood.protocol/WidgetTag, app.cash.redwood.protocol/ChildrenTag) // app.cash.redwood.protocol.host/ProtocolMismatchHandler.onUnknownChildren|onUnknownChildren(app.cash.redwood.protocol.WidgetTag;app.cash.redwood.protocol.ChildrenTag){}[0] abstract fun onUnknownModifier(app.cash.redwood.protocol/ModifierTag) // app.cash.redwood.protocol.host/ProtocolMismatchHandler.onUnknownModifier|onUnknownModifier(app.cash.redwood.protocol.ModifierTag){}[0] @@ -29,6 +24,11 @@ abstract interface app.cash.redwood.protocol.host/ProtocolMismatchHandler { // a } } +sealed interface <#A: kotlin/Any> app.cash.redwood.protocol.host/ProtocolFactory { // app.cash.redwood.protocol.host/ProtocolFactory|null[0] + abstract val widgetSystem // app.cash.redwood.protocol.host/ProtocolFactory.widgetSystem|{}widgetSystem[0] + abstract fun (): app.cash.redwood.widget/WidgetSystem<#A> // app.cash.redwood.protocol.host/ProtocolFactory.widgetSystem.|(){}[0] +} + abstract class <#A: kotlin/Any> app.cash.redwood.protocol.host/ProtocolNode { // app.cash.redwood.protocol.host/ProtocolNode|null[0] constructor (app.cash.redwood.protocol/Id, app.cash.redwood.protocol/WidgetTag) // app.cash.redwood.protocol.host/ProtocolNode.|(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.WidgetTag){}[0] diff --git a/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/ProtocolFactory.kt b/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/ProtocolFactory.kt index a5af9bb50a..feb605ee0c 100644 --- a/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/ProtocolFactory.kt +++ b/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/ProtocolFactory.kt @@ -30,7 +30,7 @@ import kotlin.native.ObjCName * @see HostProtocolAdapter */ @ObjCName("ProtocolFactory", exact = true) -public interface ProtocolFactory { +public sealed interface ProtocolFactory { public val widgetSystem: WidgetSystem }