Skip to content

Commit 0c73f5c

Browse files
committed
Accept access level attributes on imports
This feature will be protected by an experimental flag on the compiler side.
1 parent bcaad6d commit 0c73f5c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CodeGeneration/Sources/SyntaxSupport/gyb_generated/AttributeKinds.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ public let DECL_MODIFIER_KINDS: [Attribute] = [
286286
"OnSubscript",
287287
"OnConstructor",
288288
"OnMacro",
289+
"OnImport",
289290
"DeclModifier",
290291
"NotSerialized",
291292
"ABIStableToAdd",

Tests/SwiftParserTest/AttributeTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,18 @@ final class AttributeTests: XCTestCase {
556556
"""
557557
)
558558
}
559+
560+
func testImportAttributes() {
561+
AssertParse(
562+
"""
563+
import A
564+
@_implementationOnly import B
565+
public import C
566+
package import D
567+
internal import E
568+
fileprivate import F
569+
private import G
570+
"""
571+
)
572+
}
559573
}

gyb_syntax_support/AttributeKinds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def __init__(self, name, swift_name=None):
818818
code=44),
819819
DeclAttribute('private', 'AccessControl',
820820
OnFunc, OnAccessor, OnExtension, OnGenericType, OnVar, OnSubscript,
821-
OnConstructor, OnMacro,
821+
OnConstructor, OnMacro, OnImport,
822822
DeclModifier,
823823
NotSerialized,
824824
ABIStableToAdd, ABIStableToRemove, APIStableToAdd, APIStableToRemove,

0 commit comments

Comments
 (0)