Skip to content

Commit d724230

Browse files
committed
Add casting of exported source file syntax to SourceFileSyntax.
1 parent 34c90f1 commit d724230

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/ASTGen/Sources/ASTGen/LexicalLookup.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import ASTBridging
1414
import BasicBridging
15+
import SwiftIfConfig
1516
@_spi(Experimental) import SwiftLexicalLookup
1617
import SwiftSyntax
17-
import SwiftIfConfig
1818

1919
private let rowCharWidth: Int = 30
2020

@@ -46,7 +46,10 @@ public func unqualifiedLookup(
4646
) -> Bool {
4747
// Obtain source file and lookup position
4848
let sourceFile = sourceFilePtr.assumingMemoryBound(to: ExportedSourceFile.self)
49-
let sourceFileSyntax = sourceFile.pointee.syntax
49+
guard let sourceFileSyntax = sourceFile.pointee.syntax.as(SourceFileSyntax.self) else {
50+
print("Could not cast exported source file to SourceFileSyntax")
51+
return false
52+
}
5053
let sourceLocationConverter = sourceFile.pointee.sourceLocationConverter
5154
let buildConfiguration = CompilerBuildConfiguration(
5255
ctx: astContext,

0 commit comments

Comments
 (0)