Skip to content

Commit 99433ce

Browse files
committed
Add explicit internal annotation to imports
Otherwise we get errors `ambiguous implicit access level for import` if one file imports a module as `public` and another file imports it without access modifiers.
1 parent 7b750bf commit 99433ce

File tree

68 files changed

+285
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+285
-32
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftparser/TokenSpecStaticMembersFile.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import SyntaxSupport
1616
import Utils
1717

1818
let tokenSpecStaticMembersFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
19-
DeclSyntax("@_spi(RawSyntax) import SwiftSyntax")
19+
DeclSyntax(
20+
"""
21+
#if swift(>=6)
22+
@_spi(RawSyntax) internal import SwiftSyntax
23+
#else
24+
@_spi(RawSyntax) import SwiftSyntax
25+
#endif
26+
"""
27+
)
2028

2129
try! ExtensionDeclSyntax("extension TokenSpec") {
2230
for tokenSpec in Token.allCases.map(\.spec) where tokenSpec.kind != .keyword {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import SyntaxSupport
1616
import Utils
1717

1818
let childNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
19-
DeclSyntax("@_spi(ExperimentalLanguageFeatures) import SwiftSyntax")
19+
DeclSyntax(
20+
"""
21+
#if swift(>=6)
22+
@_spi(ExperimentalLanguageFeatures) internal import SwiftSyntax
23+
#else
24+
@_spi(ExperimentalLanguageFeatures) import SwiftSyntax
25+
#endif
26+
"""
27+
)
2028

2129
try! FunctionDeclSyntax(
2230
"private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String?"

CodeGeneration/Sources/generate-swift-syntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import SyntaxSupport
1616
import Utils
1717

1818
let syntaxKindNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
19-
DeclSyntax("@_spi(ExperimentalLanguageFeatures) import SwiftSyntax")
19+
DeclSyntax(
20+
"""
21+
#if swift(>=6)
22+
@_spi(ExperimentalLanguageFeatures) internal import SwiftSyntax
23+
#else
24+
@_spi(ExperimentalLanguageFeatures) import SwiftSyntax
25+
#endif
26+
"""
27+
)
2028

2129
try! ExtensionDeclSyntax("extension SyntaxKind") {
2230
try VariableDeclSyntax("var nameForDiagnostics: String?") {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftparserdiagnostics/TokenNameForDiagnosticsFile.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import SyntaxSupport
1616
import Utils
1717

1818
let tokenNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
19-
DeclSyntax("@_spi(RawSyntax) import SwiftSyntax")
19+
DeclSyntax(
20+
"""
21+
#if swift(>=6)
22+
@_spi(RawSyntax) internal import SwiftSyntax
23+
#else
24+
@_spi(RawSyntax) import SwiftSyntax
25+
#endif
26+
"""
27+
)
2028

2129
try! ExtensionDeclSyntax("extension TokenKind") {
2230
try! VariableDeclSyntax("var nameForDiagnostics: String") {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntaxbuilder/SyntaxExpressibleByStringInterpolationConformancesFile.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ import SyntaxSupport
1616
import Utils
1717

1818
let syntaxExpressibleByStringInterpolationConformancesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
19-
DeclSyntax("import SwiftSyntax")
19+
DeclSyntax(
20+
"""
21+
#if swift(>=6)
22+
internal import SwiftSyntax
23+
#else
24+
import SwiftSyntax
25+
#endif
26+
"""
27+
)
2028

2129
let typesExpressibleByStringInterpolation =
2230
SYNTAX_NODES

Sources/SwiftCompilerPluginMessageHandling/Diagnostics.swift

+5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftDiagnostics
15+
internal import SwiftSyntax
16+
#else
1317
import SwiftDiagnostics
1418
import SwiftSyntax
19+
#endif
1520

1621
/// Errors in macro handing.
1722
enum MacroExpansionError {

Sources/SwiftCompilerPluginMessageHandling/Macros.swift

+9
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftBasicFormat
15+
internal import SwiftDiagnostics
16+
internal import SwiftOperators
17+
internal import SwiftSyntax
18+
@_spi(MacroExpansion) @_spi(ExperimentalLanguageFeature) internal import SwiftSyntaxMacroExpansion
19+
@_spi(ExperimentalLanguageFeature) internal import SwiftSyntaxMacros
20+
#else
1321
import SwiftBasicFormat
1422
import SwiftDiagnostics
1523
import SwiftOperators
1624
import SwiftSyntax
1725
@_spi(MacroExpansion) @_spi(ExperimentalLanguageFeature) import SwiftSyntaxMacroExpansion
1826
@_spi(ExperimentalLanguageFeature) import SwiftSyntaxMacros
27+
#endif
1928

2029
extension CompilerPluginMessageHandler {
2130
/// Get concrete macro type from a pair of module name and type name.

Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift

+8
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftDiagnostics
15+
internal import SwiftOperators
16+
internal import SwiftParser
17+
internal import SwiftSyntax
18+
internal import SwiftSyntaxMacros
19+
#else
1320
import SwiftDiagnostics
1421
import SwiftOperators
1522
import SwiftParser
1623
import SwiftSyntax
1724
import SwiftSyntaxMacros
25+
#endif
1826

1927
/// Manages known source code combined with their filename/fileID. This can be
2028
/// used to get line/column from a syntax node in the managed source code.

Sources/SwiftIDEUtils/SyntaxClassification.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
public enum SyntaxClassification: Sendable {
1620
/// An attribute starting with an `@`.

Sources/SwiftIDEUtils/Utils.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftSyntax
15+
#else
1316
import SwiftSyntax
17+
#endif
1418

1519
extension Range<AbsolutePosition> {
1620
/// Shift the range `utf8Offset` bytes to the right, ie. add `utf8Offset` to the upper and lower bound.

Sources/SwiftOperators/OperatorError+Diagnostics.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#if swift(>=6)
1414
public import SwiftDiagnostics
15-
import SwiftParser
16-
import SwiftSyntax
15+
internal import SwiftParser
16+
internal import SwiftSyntax
1717
#else
1818
import SwiftDiagnostics
1919
import SwiftParser

Sources/SwiftOperators/OperatorTable+Defaults.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftSyntax
15+
#else
1316
import SwiftSyntax
17+
#endif
1418

1519
/// Prefabricated operator precedence graphs.
1620
extension OperatorTable {

Sources/SwiftOperators/OperatorTable.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftSyntax
15+
#else
1316
import SwiftSyntax
17+
#endif
1418

1519
/// Maintains and validates information about all operators in a Swift program.
1620
///

Sources/SwiftOperators/PrecedenceGraph.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
internal import SwiftSyntax
15+
#else
1316
import SwiftSyntax
17+
#endif
1418

1519
/// Describes the relative precedence of two groups.
1620
enum Precedence: Sendable {

Sources/SwiftParser/Attributes.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
mutating func parseAttributeList() -> RawAttributeListSyntax {

Sources/SwiftParser/Availability.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
/// Parse a list of availability arguments.

Sources/SwiftParser/Declarations.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension DeclarationModifier {
1620
var canHaveParenthesizedArgument: Bool {

Sources/SwiftParser/Directives.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
private enum IfConfigContinuationClauseStartKeyword: TokenSpecSet {

Sources/SwiftParser/Expressions.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension TokenConsumer {
1620
mutating func atStartOfExpression() -> Bool {

Sources/SwiftParser/IsValidIdentifier.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
/// Context in which to check if a name can be used as an identifier.
1620
///

Sources/SwiftParser/Lexer/Cursor.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) @_spi(BumpPtrAllocator) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) @_spi(BumpPtrAllocator) import SwiftSyntax
17+
#endif
1418

1519
extension SyntaxText {
1620
fileprivate func containsPlaceholderEnd() -> Bool {

Sources/SwiftParser/Lexer/LexemeSequence.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) @_spi(BumpPtrAllocator) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) @_spi(BumpPtrAllocator) import SwiftSyntax
17+
#endif
1418

1519
extension Lexer {
1620
/// A sequence of ``Lexer/Lexeme`` tokens starting from a ``Lexer/Cursor``

Sources/SwiftParser/Lexer/RegexLiteralLexer.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) @_spi(BumpPtrAllocator) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) @_spi(BumpPtrAllocator) import SwiftSyntax
17+
#endif
1418

1519
/// A separate lexer specifically for regex literals.
1620
fileprivate struct RegexLiteralLexer {

Sources/SwiftParser/Lookahead.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
/// Token lookahead for the parser.

Sources/SwiftParser/LoopProgressCondition.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
/// A type that can be used to make sure that a loop in the parser makes process.
1620
///

Sources/SwiftParser/Modifiers.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
mutating func parseDeclModifierList() -> RawDeclModifierListSyntax {

Sources/SwiftParser/Names.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension Parser {
1620
mutating func parseAnyIdentifier() -> RawTokenSyntax {

Sources/SwiftParser/Nominals.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
protocol NominalTypeDeclarationTrait {
1620
associatedtype PrimaryOrGenerics

Sources/SwiftParser/Parameters.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) internal import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
// MARK: - Traits
1620

0 commit comments

Comments
 (0)