Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 869be1a

Browse files
authored
Merge pull request #51 from SwiftDocOrg/source-file-visitor-fix
Fix SourceFile Visitor
2 parents c34ccc1 + 7896787 commit 869be1a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Checkout
1111
uses: actions/checkout@v1
1212
- name: Build and Test
13-
run: swift test
13+
run: swift test -c release
1414
env:
1515
DEVELOPER_DIR: /Applications/Xcode_11.4.app/Contents/Developer
1616

@@ -28,4 +28,4 @@ jobs:
2828
apt-get update
2929
apt-get install -y libxml2-dev
3030
- name: Build and Test
31-
run: swift test --enable-test-discovery
31+
run: swift test -c release --enable-test-discovery

Sources/SwiftDoc/SourceFile.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public struct SourceFile: Hashable, Codable {
8989
visitedImports.append(`import`)
9090
}
9191

92+
@discardableResult
9293
func pop() -> Contextual? {
9394
return context.popLast()
9495
}
@@ -187,27 +188,33 @@ public struct SourceFile: Hashable, Codable {
187188
// MARK: -
188189

189190
override func visitPost(_ node: ClassDeclSyntax) {
190-
assert((pop() as? Symbol)?.api is Class)
191+
let context = pop()
192+
assert((context as? Symbol)?.api is Class)
191193
}
192194

193195
override func visitPost(_ node: EnumDeclSyntax) {
194-
assert((pop() as? Symbol)?.api is Enumeration)
196+
let context = pop()
197+
assert((context as? Symbol)?.api is Enumeration)
195198
}
196199

197200
override func visitPost(_ node: ExtensionDeclSyntax) {
198-
assert(pop() is Extension)
201+
let context = pop()
202+
assert(context is Extension)
199203
}
200204

201205
override func visitPost(_ node: IfConfigClauseSyntax) {
202-
assert(pop() is CompilationCondition)
206+
let context = pop()
207+
assert(context is CompilationCondition)
203208
}
204209

205210
override func visitPost(_ node: ProtocolDeclSyntax) {
206-
assert((pop() as? Symbol)?.api is Protocol)
211+
let context = pop()
212+
assert((context as? Symbol)?.api is Protocol)
207213
}
208214

209215
override func visitPost(_ node: StructDeclSyntax) {
210-
assert((pop() as? Symbol)?.api is Structure)
216+
let context = pop()
217+
assert((context as? Symbol)?.api is Structure)
211218
}
212219
}
213220
}

Tests/SwiftDocTests/SourceFileTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import XCTest
22

3-
@testable import SwiftDoc
3+
import SwiftDoc
44
import SwiftSemantics
55
import struct SwiftSemantics.Protocol
66
import SwiftSyntax

0 commit comments

Comments
 (0)