Why does breaking up SwiftPM targets list cause typechecking to fall off a cliff?

i have a package manifest with a lot (>100) targets that was basically impossible to navigate. so i wanted to break it up into collapsible sections like this:

var a:[Target]
{
    [
        //  targets ...
    ]
}
var b:[Target]
{
    [
        //  targets ...
    ]
}
var c:[Target]
{
    [
        //  targets ...
    ]
}

... 
        .package(url: "https://github.com/apple/swift-system", .upToNextMinor(
            from: "1.2.1")),
        .package(url: "https://github.com/apple/swift-syntax",
            exact: "510.0.1"),
    ],
    targets: a + b + c)

for some reason, typechecking degrades non-linearly when i have more than two lists of targets, to the point where a simple swift package dump-package command takes many minutes to complete.

what is going on here? is there a better way to improve manifest navigability?

You can try adding your targets to your Package incrementally, like this:

let package = Package(…)

package.targets += a
package.targets += b
package.targets += c

Note that Package is a class, not a struct, so you don’t need to declare it var.

My guess is that type inference of the array in the computed property is being accidentally-exponential.

@mayoff's suggestion should work, or you can try let a: [Target] = []. Unfortunately, the heuristics used to make type-checking literals not-slow are somewhat mysterious to me.