Skip to content

Commit fc03feb

Browse files
authored
Merge pull request #2807 from rintaro/assertion-fileid
Use #fileID for assertion
2 parents 6c09220 + b378c07 commit fc03feb

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
8484

8585
DeclSyntax(
8686
"""
87-
func verify<Node: RawSyntaxNodeProtocol>(_ raw: RawSyntax?, as _: Node.Type, file: StaticString = #filePath, line: UInt = #line) -> ValidationError? {
87+
func verify<Node: RawSyntaxNodeProtocol>(_ raw: RawSyntax?, as _: Node.Type, file: StaticString = #fileID, line: UInt = #line) -> ValidationError? {
8888
guard let raw = raw else {
8989
return .expectedNonNil(expectedKind: Node.self, file: file, line: line)
9090
}
@@ -98,7 +98,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
9898

9999
DeclSyntax(
100100
"""
101-
func verify<Node: RawSyntaxNodeProtocol>(_ raw: RawSyntax?, as _: Node?.Type, file: StaticString = #filePath, line: UInt = #line) -> ValidationError? {
101+
func verify<Node: RawSyntaxNodeProtocol>(_ raw: RawSyntax?, as _: Node?.Type, file: StaticString = #fileID, line: UInt = #line) -> ValidationError? {
102102
if raw != nil {
103103
return verify(raw, as: Node.self, file: file, line: line)
104104
}
@@ -109,7 +109,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
109109

110110
DeclSyntax(
111111
"""
112-
func verify(_ raw: RawSyntax?, as _: RawTokenSyntax?.Type, tokenChoices: [TokenChoice], file: StaticString = #filePath, line: UInt = #line) -> ValidationError? {
112+
func verify(_ raw: RawSyntax?, as _: RawTokenSyntax?.Type, tokenChoices: [TokenChoice], file: StaticString = #fileID, line: UInt = #line) -> ValidationError? {
113113
// Validation of token choice is currently causing assertion failures where
114114
// the list of expected token choices in the syntax tree doesn't match those
115115
// the parser generates. Disable the verification for now until all issues
@@ -124,7 +124,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
124124

125125
DeclSyntax(
126126
"""
127-
func verify(_ raw: RawSyntax?, as _: RawTokenSyntax.Type, tokenChoices: [TokenChoice], file: StaticString = #filePath, line: UInt = #line) -> ValidationError? {
127+
func verify(_ raw: RawSyntax?, as _: RawTokenSyntax.Type, tokenChoices: [TokenChoice], file: StaticString = #fileID, line: UInt = #line) -> ValidationError? {
128128
// Validation of token choice is currently causing assertion failures where
129129
// the list of expected token choices in the syntax tree doesn't match those
130130
// the parser generates. Disable the verification for now until all issues

Sources/SwiftSyntax/Assert.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public func assert(
3333
_ condition: @autoclosure () -> Bool,
3434
_ message: @autoclosure () -> String = String(),
35-
file: StaticString = #file,
35+
file: StaticString = #fileID,
3636
line: UInt = #line
3737
) {
3838
#if SWIFTSYNTAX_ENABLE_ASSERTIONS
@@ -51,7 +51,7 @@ public func assert(
5151
@_transparent
5252
public func assertionFailure(
5353
_ message: @autoclosure () -> String = String(),
54-
file: StaticString = #file,
54+
file: StaticString = #fileID,
5555
line: UInt = #line
5656
) {
5757
#if SWIFTSYNTAX_ENABLE_ASSERTIONS
@@ -71,7 +71,7 @@ public func assertionFailure(
7171
public func precondition(
7272
_ condition: @autoclosure () -> Bool,
7373
_ message: @autoclosure () -> String = String(),
74-
file: StaticString = #file,
74+
file: StaticString = #fileID,
7575
line: UInt = #line
7676
) {
7777
#if !SWIFTSYNTAX_DISABLE_PRECONDITIONS

Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
8686
func verify<Node: RawSyntaxNodeProtocol>(
8787
_ raw: RawSyntax?,
8888
as _: Node.Type,
89-
file: StaticString = #filePath,
89+
file: StaticString = #fileID,
9090
line: UInt = #line
9191
) -> ValidationError? {
9292
guard let raw = raw else {
@@ -105,7 +105,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
105105
func verify<Node: RawSyntaxNodeProtocol>(
106106
_ raw: RawSyntax?,
107107
as _: Node?.Type,
108-
file: StaticString = #filePath,
108+
file: StaticString = #fileID,
109109
line: UInt = #line
110110
) -> ValidationError? {
111111
if raw != nil {
@@ -122,7 +122,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
122122
_ raw: RawSyntax?,
123123
as _: RawTokenSyntax?.Type,
124124
tokenChoices: [TokenChoice],
125-
file: StaticString = #filePath,
125+
file: StaticString = #fileID,
126126
line: UInt = #line
127127
) -> ValidationError? {
128128
// Validation of token choice is currently causing assertion failures where
@@ -144,7 +144,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
144144
_ raw: RawSyntax?,
145145
as _: RawTokenSyntax.Type,
146146
tokenChoices: [TokenChoice],
147-
file: StaticString = #filePath,
147+
file: StaticString = #fileID,
148148
line: UInt = #line
149149
) -> ValidationError? {
150150
// Validation of token choice is currently causing assertion failures where

0 commit comments

Comments
 (0)