8000 Remove `@_implementationOnly` annotations · swiftlang/swift-syntax@5215d23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5215d23

Browse files
committed
Remove @_implementationOnly annotations
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
1 parent 7f41827 commit 5215d23

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

Sources/SwiftCompilerPlugin/CompilerPlugin.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@
1212
// NOTE: This basic plugin mechanism is mostly copied from
1313
// https://github.com/apple/swift-package-manager/blob/main/Sources/PackagePlugin/Plugin.swift
1414

15-
@_implementationOnly import Foundation
16-
@_implementationOnly import SwiftCompilerPluginMessageHandling
1715
import SwiftSyntaxMacros
1816

17+
#if swift(>=5.11)
18+
private import Foundation
19+
private import SwiftCompilerPluginMessageHandling
20+
#else
21+
import Foundation
22+
import SwiftCompilerPluginMessageHandling
23+
#endif
24+
1925
#if os(Windows)
20-
@_implementationOnly import ucrt
26+
#if swift(>=5.11)
27+
private import ucrt
28+
#else
29+
import ucrt
30+
#endif
2131
#endif
2232

2333
//
@@ -169,8 +179,8 @@ extension CompilerPlugin {
169179
}
170180

171181
internal struct PluginHostConnection: MessageConnection {
172-
let inputStream: FileHandle
173-
let outputStream: FileHandle
182+
fileprivate let inputStream: FileHandle
183+
fileprivate let outputStream: FileHandle
174184

175185
func sendMessage<TX: Encodable>(_ message: TX) throws {
176186
// Encode the message as JSON.

Sources/SwiftSyntax/SyntaxText.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,22 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=5.11)
1314
#if canImport(Darwin)
14-
@_implementationOnly import Darwin
15+
private import Darwin
1516
#elseif canImport(Glibc)
16-
@_implementationOnly import Glibc
17+
private import Glibc
1718
#elseif canImport(Musl)
18-
@_implementationOnly import Musl
19+
private import Musl
20+
#endif
21+
#else
22+
#if canImport(Darwin)
23+
import Darwin
24+
#elseif canImport(Glibc)
25+
import Glibc
26+
#elseif canImport(Musl)
27+
import Musl
28+
#endif
1929
#endif
2030

2131
/// Represent a string.

Tests/SwiftParserTest/LinkageTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ final class LinkageTest: ParserTestCase {
5353
.library("-lswiftCompatibilityConcurrency"),
5454
.library("-lswiftCompatibilityPacks", condition: .mayBeAbsent("Only in newer compilers")),
5555
.library("-lswiftCore"),
56+
.library("-lswiftDarwin"),
5657
.library("-lswiftSwiftOnoneSupport", condition: .when(configuration: .debug)),
5758
.library("-lswift_Concurrency"),
5859
.library("-lswift_StringProcessing", condition: .mayBeAbsent("Starting in Xcode 14 this library is not always autolinked")),
@@ -70,7 +71,7 @@ final class LinkageTest: ParserTestCase {
7071
.library("-lswiftCompatibilityPacks", condition: .mayBeAbsent("Only in newer compilers")),
7172
.library("-lswiftCore"),
7273
.library("-lswiftCoreFoundation", condition: .when(compilationCondition: .osLogDependency)),
73-
.library("-lswiftDarwin", condition: .when(compilationCondition: .osLogDependency)),
74+
.library("-lswiftDarwin"),
7475
.library("-lswiftDispatch", condition: .when(compilationCondition: .osLogDependency)),
7576
.library("-lswiftFoundation", condition: .when(compilationCondition: .osLogDependency)),
7677
.library("-lswiftIOKit", condition: .when(compilationCondition: .osLogDependency)),

0 commit comments

Comments
 (0)
0