Skip to content

Commit

Permalink
Generate @available deprecations on short type aliases to avoid warni…
Browse files Browse the repository at this point in the history
…ngs (#471)
  • Loading branch information
tristanlabelle authored Jan 8, 2025
1 parent 38a63d0 commit 0744143
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Generator/Sources/SwiftWinRT/Writing/NamespaceModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand All @@ -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))
Expand Down

0 comments on commit 0744143

Please sign in to comment.