Skip to content

Commit e1d8de1

Browse files
committed
Skip testJumpToSatisfiedProtocolRequirementInExtension if the toolchain does not mark overridable function declarations as dynamic
This test requires swiftlang/swift#74080 and should be skipped if the host toolchain does not have that change.
1 parent 1e0639c commit e1d8de1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,37 @@ public actor SkipUnless {
233233
}
234234
}
235235

236+
/// Checks if the toolchain contains https://github.com/apple/swift/pull/74080.
237+
public static func sourcekitdReportsOverridableFunctionDefinitionsAsDynamic(
238+
file: StaticString = #filePath,
239+
line: UInt = #line
240+
) async throws {
241+
struct ExpectedLocationsResponse: Error {}
242+
243+
return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 0), file: file, line: line) {
244+
let project = try await IndexedSingleSwiftFileTestProject(
245+
"""
246+
protocol TestProtocol {
247+
func 1️⃣doThing()
248+
}
249+
250+
struct TestImpl: TestProtocol {}
251+
extension TestImpl {
252+
func 2️⃣doThing() { }
253+
}
254+
"""
255+
)
256+
257+
let response = try await project.testClient.send(
258+
DefinitionRequest(textDocument: TextDocumentIdentifier(project.fileURI), position: project.positions["1️⃣"])
259+
)
260+
guard case .locations(let locations) = response else {
261+
throw ExpectedLocationsResponse()
262+
}
263+
return locations.contains { $0.range == Range(project.positions["2️⃣"]) }
264+
}
265+
}
266+
236267
public static func sourcekitdReturnsRawDocumentationResponse(
237268
file: StaticString = #filePath,
238269
line: UInt = #line

Tests/SourceKitLSPTests/DefinitionTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ class DefinitionTests: XCTestCase {
603603
}
604604

605605
func testJumpToSatisfiedProtocolRequirementInExtension() async throws {
606+
try await SkipUnless.sourcekitdReportsOverridableFunctionDefinitionsAsDynamic()
607+
606608
let project = try await IndexedSingleSwiftFileTestProject(
607609
"""
608610
protocol TestProtocol {

0 commit comments

Comments
 (0)