SourceKit - Compilation Condition - Error Response

Hello,

I've got some questions regarding 'sourcekit response for compilation conditions' and I truly need you guys for directions.

Create a "CursorInfo" request for the below code:

import Foundation

class Foo {
    var prop: String?
    
    func test() {
        #if targetEnvironment(simulator)
        prop = "simulator"
        #else
        prop = "device"
        #endif
    }
}

Problem

I'm looking to get a response for both conditions. The 'if condition' response it's as expected but the 'else condition' is throwing an error and I was expecting a response instead.

Questions

How can I get a response for the 'else condition' - prop = "device"?
Or is this expected and should work only for the active compilation condition? Maybe there is a way to ignore the condition?

Thank you in advance.

Response

-- begin response ------------
{
key.kind: source.lang.swift.ref.var.instance,
key.name: "prop",
key.usr: "s:4main3FooC4propSSSgvp",
key.filepath: ".../cursor-req.swift",
key.offset: 39,
key.length: 4,
key.typename: "String?",
key.annotated_decl: "var prop: <Type usr="s:SS">String?",
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>prop</decl.name>: <decl.var.type><ref.struct usr="s:SS">String</ref.struct>?</decl.var.type></decl.var.instance>",
key.typeusr: "$sSSSgD",
key.containertypeusr: "$s4main3FooCD",
key.refactor_actions: [
{
key.actionname: "Global Rename",
key.actionuid: source.refactoring.kind.rename.global
}
]
}
-- end response --------------
Produced: Response for CursorInfo in .../cursor-req.swift at offset 166 with args: -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk -target x86_64-apple-ios11.0-simulator .../cursor-req.swift
-- begin response ------------
{
key.internal_diagnostic: "Unable to resolve cursor info."
}
-- end response --------------

How do I test?

alias sk-stress="/Library/Developer/Toolchains/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-11-11-a.xctoolchain/usr/bin/sk-stress-test

sk-stress --report-responses -r CursorInfo -m none .../cursor-req.swift swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk -target x86_64-apple-ios11.0-simulator .../cursor-req.swift

Unfortunately, it's expected that it only works in the active condition, since only the active condition gets type-checking and name binding.

I'm using SourceKit to parse and find the "prop" in both conditions. I guess a workaround is needed here.

Ben, thanks for the clarification.