diff --git a/Sources/SwiftCompilerPlugin/CompilerPlugin.swift b/Sources/SwiftCompilerPlugin/CompilerPlugin.swift index 23a2b22cdb2..2e8c2edbd76 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 // @@ -169,8 +179,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 310bcb22836..59aa52c4f68 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/Tests/SwiftParserTest/LinkageTests.swift b/Tests/SwiftParserTest/LinkageTests.swift index 8c9f736fb15..f5f663e3200 100644 --- a/Tests/SwiftParserTest/LinkageTests.swift +++ b/Tests/SwiftParserTest/LinkageTests.swift @@ -53,6 +53,7 @@ final class LinkageTest: ParserTestCase { .library("-lswiftCompatibilityConcurrency"), .library("-lswiftCompatibilityPacks", condition: .mayBeAbsent("Only in newer compilers")), .library("-lswiftCore"), + .library("-lswiftDarwin"), .library("-lswiftSwiftOnoneSupport", condition: .when(configuration: .debug)), .library("-lswift_Concurrency"), .library("-lswift_StringProcessing", condition: .mayBeAbsent("Starting in Xcode 14 this library is not always autolinked")), @@ -70,7 +71,7 @@ final class LinkageTest: ParserTestCase { .library("-lswiftCompatibilityPacks", condition: .mayBeAbsent("Only in newer compilers")), .library("-lswiftCore"), .library("-lswiftCoreFoundation", condition: .when(compilationCondition: .osLogDependency)), - .library("-lswiftDarwin", condition: .when(compilationCondition: .osLogDependency)), + .library("-lswiftDarwin"), .library("-lswiftDispatch", condition: .when(compilationCondition: .osLogDependency)), .library("-lswiftFoundation", condition: .when(compilationCondition: .osLogDependency)), .library("-lswiftIOKit", condition: .when(compilationCondition: .osLogDependency)),