From 28d9403e48633ce3a13feec888bdb7076820aee9 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Sat, 20 Jan 2024 15:07:50 -0800 Subject: [PATCH] Remove `@_implementationOnly` annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These annotations produce warnings when compiling swift-syntax without library evolution using Swift ≥5.10. Replace them by `private import` when compiling using Swift ≥5.11. Also mark the import of XCTest from `SwiftSyntaxMacrosTestSupport` as `private`, fixing rdar://119517162. rdar://119517162 --- .../SwiftCompilerPlugin/CompilerPlugin.swift | 20 ++++++++++++++----- Sources/SwiftSyntax/SyntaxText.swift | 16 ++++++++++++--- .../Assertions.swift | 7 ++++++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Sources/SwiftCompilerPlugin/CompilerPlugin.swift b/Sources/SwiftCompilerPlugin/CompilerPlugin.swift index c16a8390c85..b4efd0d1258 100644 --- a/Sources/SwiftCompilerPlugin/CompilerPlugin.swift +++ b/Sources/SwiftCompilerPlugin/CompilerPlugin.swift @@ -12,12 +12,22 @@ // NOTE: This basic plugin mechanism is mostly copied from // https://github.com/apple/swift-package-manager/blob/main/Sources/PackagePlugin/Plugin.swift -@_implementationOnly import Foundation -@_implementationOnly import SwiftCompilerPluginMessageHandling import SwiftSyntaxMacros +#if swift(>=5.11) +private import Foundation +private import SwiftCompilerPluginMessageHandling +#else +import Foundation +import SwiftCompilerPluginMessageHandling +#endif + #if os(Windows) -@_implementationOnly import ucrt +#if swift(>=5.11) +private import ucrt +#else +import ucrt +#endif #endif // @@ -167,8 +177,8 @@ extension CompilerPlugin { } internal struct PluginHostConnection: MessageConnection { - let inputStream: FileHandle - let outputStream: FileHandle + fileprivate let inputStream: FileHandle + fileprivate let outputStream: FileHandle func sendMessage(_ message: TX) throws { // Encode the message as JSON. diff --git a/Sources/SwiftSyntax/SyntaxText.swift b/Sources/SwiftSyntax/SyntaxText.swift index c5068a76aa4..a15ef1a7b15 100644 --- a/Sources/SwiftSyntax/SyntaxText.swift +++ b/Sources/SwiftSyntax/SyntaxText.swift @@ -10,12 +10,22 @@ // //===----------------------------------------------------------------------===// +#if swift(>=5.11) #if canImport(Darwin) -@_implementationOnly import Darwin +private import Darwin #elseif canImport(Glibc) -@_implementationOnly import Glibc +private import Glibc #elseif canImport(Musl) -@_implementationOnly import Musl +private import Musl +#endif +#else +#if canImport(Darwin) +import Darwin +#elseif canImport(Glibc) +import Glibc +#elseif canImport(Musl) +import Musl +#endif #endif /// Represent a string. diff --git a/Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift b/Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift index 5a3fcdbd2c8..7f7d2f40dac 100644 --- a/Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift +++ b/Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift @@ -17,9 +17,14 @@ import SwiftParserDiagnostics import SwiftSyntax import SwiftSyntaxMacroExpansion import SwiftSyntaxMacros -import XCTest import _SwiftSyntaxTestSupport +#if swift(>=5.11) +private import XCTest +#else +import XCTest +#endif + // MARK: - Note /// Describes a diagnostic note that tests expect to be created by a macro expansion.