From 07441434d07c81164b002598569e6ff76da0e8bf Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Wed, 8 Jan 2025 06:30:01 -0500 Subject: [PATCH] Generate @available deprecations on short type aliases to avoid warnings (#471) --- Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift b/Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift index 80d5ae7..0f62b20 100644 --- a/Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift +++ b/Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift @@ -74,7 +74,10 @@ fileprivate func writeShortNameTypeAlias( _ typeDefinition: TypeDefinition, projection: Projection, to writer: SwiftSourceFileWriter) throws { + let attributes = try [ Projection.getAvailableAttribute(typeDefinition) ].compactMap { $0 } + try writer.writeTypeAlias( + attributes: attributes, visibility: Projection.toVisibility(typeDefinition.visibility), name: projection.toTypeName(typeDefinition, namespaced: false), typeParams: typeDefinition.genericParams.map { $0.name }, @@ -89,6 +92,7 @@ fileprivate func writeShortNameTypeAlias( // - When using `any IFooProtocol`, we are using an incompatible type from `any MyNamespace_IFooProtocol`, // however, the code should be using `IFoo`, which avoids this issue. try writer.writeProtocol( + attributes: attributes, visibility: Projection.toVisibility(interface.visibility), name: projection.toProtocolName(interface, namespaced: false), typeParams: interface.genericParams.map { $0.name }, @@ -97,6 +101,7 @@ fileprivate func writeShortNameTypeAlias( if typeDefinition is InterfaceDefinition || typeDefinition is DelegateDefinition { try writer.writeTypeAlias( + attributes: attributes, visibility: Projection.toVisibility(typeDefinition.visibility), name: projection.toBindingTypeName(typeDefinition, namespaced: false), target: projection.toBindingType(typeDefinition))