feat(kernel): R7b Swift walker — swift module, tree-sitter-swift 0.7.3 bump, swift default-routed (#1381)
Fifth R7b batch-3 port, checklist-first recipe (docs/design/swift-kernel-port-checklist.md, 1,056 lines — the largest of the arc, with a built-extractor-validated emission pin and a childForFieldName truth table). Grammar bump first, validated standalone: tree-sitter-wasms ^0.4.0 (ABI 13) → crate 0.7.3 — with a provenance twist: the wasm is built from the CRATE TARBALL's src/ (alex-pinkus keeps generated files off main and the 0.7.3-with-generated-files tag ships an older ABI-14 generation that can never sha-match; grammar.json rules are JSON-equal; the tarball is byte-for-byte what the kernel's cargo build compiles — table identity by construction). Older crates evaluated and rejected: clean-parse shapes are byte-identical on 0.7.3 (53-line CST battery diff, all inert), so an older pin buys nothing and loses the macro-era wins. Delta = error-set membership (63 old-error files parse clean: swift-testing #expect, #Preview/#GET macros, package access, typed throws — vapor 23.1%→9.3%; 21 NEW-only regressions in 3 probed construct classes) + two gate-found categories: docstring boundaries near #if directives (7 clean files, docstring-field-only — verified mechanically) and array-literal-callee call refs (2 refs, 1 file). Every hunk classified via the error-union rule + parked-ref↔edge ripple pairing. Walker (the arc's biggest) centers on the #1020 DEDICATED property branch: computed properties → property nodes with the getter walked under the property (SwiftUI body), static let/var → constant/variable, stored → field, decorator/type-annotation/@Siblings-attr-arg refs all attached to the ENCLOSING TYPE, stored initializer calls attributed to the class. Preserved bug-for-bug: the never-resolving 'parameter' field (zero param type refs, zero signatures), present-false isAsync, open→internal visibility, everything-is-extends inheritance (first type_identifier per specifier), no instantiates refs ever, subscript reads as `calls arr`, `defer` as `calls defer`, multi-case enum entries minting only the first case, /** */ block docs ignored AND chain-breaking, init/deinit/subscript minting no nodes with visitNode-routed bodies (calls → class, static reads → nothing), multi- segment extension resolveName, sugar extension names, the #selector shapes, and the value_argument label-forward skip. ONE fix found by the sweep (then pinned in the fixture + checklist): the shared `assignment` shadow-prune case is swift-live — declared-then-assigned `let X: T` prunes X as a value-ref target. Gates: sweeps 0-diff Alamofire 89/98, vapor 224/247, swift-nio 407/554 (--max-deferral 0.3 — swift error incidence is 9–27% on BOTH arms, structural; every deferral count matches the survey's table exactly); full-init dumps byte-identical ×3 (31.9k/20.7k/126.3k lines); the Alamofire census reproduces property=348 (the #1020 number) on the kernel arm; kernel-swift-parity suite (206-line torture + CRLF + the #if-between-enum- cases defer fixture) + swift grammar-parity row; full suite 2,626 green ×2 under CODEGRAPH_KERNEL_EXPECT=1. DEFAULT_ROUTED += swift (14 langs). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a6c62d77df
commit
09e301bbfa
@@ -0,0 +1,206 @@
|
||||
import Foundation
|
||||
import UIKit.UIView
|
||||
|
||||
/// Class doc line one
|
||||
/// Class doc line two
|
||||
public final class Session: NSObject, RequestDelegate {
|
||||
let rootQueue: DispatchQueue = DispatchQueue(label: "root")
|
||||
var mutable = 0
|
||||
static let SHARED_MAX: Int = 5
|
||||
static var counter = 0
|
||||
lazy var expensive: Cache = Cache.build()
|
||||
@Published private var wrapped: Bool = false
|
||||
weak var delegate: SessionDelegate?
|
||||
var observed: Int = 0 {
|
||||
willSet { prepare(newValue) }
|
||||
didSet { react(oldValue) }
|
||||
}
|
||||
var isCloudProxy: Bool { return check(SHARED_MAX) }
|
||||
open class func classFunc() {}
|
||||
|
||||
/// method doc
|
||||
public func request(_ convertible: URLConvertible, method: HTTPMethod) -> DataRequest {
|
||||
let req = DataRequest.make().validate()
|
||||
let m = HTTPMethod.get
|
||||
let g = Session.SHARED_MAX
|
||||
self.own()
|
||||
super.retain()
|
||||
rootQueue.async { self.perform(req) }
|
||||
return req
|
||||
}
|
||||
init(raw: String) {
|
||||
self.raw = raw
|
||||
setupMonitor()
|
||||
}
|
||||
deinit { cleanup() }
|
||||
subscript(index: Int) -> Foo { get { store[index] } set { store[index] = newValue } }
|
||||
}
|
||||
|
||||
struct HTTPMethod: RawRepresentable, Equatable {
|
||||
let rawValue: String
|
||||
static let get = HTTPMethod(rawValue: "GET")
|
||||
}
|
||||
|
||||
enum AFError: Error, CustomStringConvertible {
|
||||
case invalidURL(url: URLConvertible)
|
||||
case explicitlyCancelled, sessionDeinitialized
|
||||
indirect case wrapped(AFError)
|
||||
var description: String { renderDescription() }
|
||||
static func make() -> AFError { .explicitlyCancelled }
|
||||
}
|
||||
|
||||
protocol RequestDelegate: AnyObject {
|
||||
var sessionState: Int { get }
|
||||
func didFinish(_ request: Request)
|
||||
static func build() -> Self
|
||||
}
|
||||
|
||||
extension Session: EventMonitor {
|
||||
func heard(event: Event) { record(event) }
|
||||
}
|
||||
|
||||
extension KF.Builder {
|
||||
func done() -> KF.Builder { self }
|
||||
}
|
||||
|
||||
extension Array where Element: Equatable {
|
||||
func dedup() -> [Element] { self }
|
||||
}
|
||||
|
||||
actor Counter {
|
||||
var n = 0
|
||||
func bump() { n += 1 }
|
||||
}
|
||||
|
||||
typealias Handler = (Data) -> Void
|
||||
typealias BuilderAlias = KF.Builder
|
||||
|
||||
let TOP_LEVEL_MAX = 3
|
||||
var topVar: Int = compute()
|
||||
|
||||
func freeFn(a: Int, cb: @escaping (Int) -> Void) -> Session? {
|
||||
helper()
|
||||
Foo()
|
||||
obj.method(1)
|
||||
a.b.deep()
|
||||
x?.optCall()
|
||||
y!.forced()
|
||||
Foo.make().draw()
|
||||
foo.bar().baz()
|
||||
"lit".upper()
|
||||
arr.map { $0.name }
|
||||
let tbl = [cbA, cbB]
|
||||
o.cb = handler
|
||||
reg2(onFire)
|
||||
forward(value: value)
|
||||
let sel = #selector(Holder.fire)
|
||||
defer { cleanup() }
|
||||
let d = dict["k"]
|
||||
return nil
|
||||
}
|
||||
|
||||
func onFire() {}
|
||||
func handler() {}
|
||||
func cbA() {}
|
||||
func cbB() {}
|
||||
|
||||
// ---- extension rows (checklist inventory) ----
|
||||
// non-ASCII line before a symbol: café ünïcode 😀
|
||||
@objc enum Suit: Int {
|
||||
case hearts = 1
|
||||
case spades
|
||||
}
|
||||
|
||||
@main struct MainApp {
|
||||
var body: some View { VStack { Text(label) } }
|
||||
}
|
||||
|
||||
/** block doc is IGNORED and breaks the chain */
|
||||
func blockDoc() {}
|
||||
|
||||
/// kept over attribute
|
||||
@objc func attributed() {}
|
||||
|
||||
func <+> (lhs: Session, rhs: Session) -> Session { lhs }
|
||||
|
||||
public class Visi {
|
||||
public private(set) var setterGated = 1
|
||||
static let A_B: Int = 2
|
||||
let (tup, tup2) = makePair()
|
||||
@Siblings(through: Pivot.self, from: \.$left) var siblings: [Tag]
|
||||
}
|
||||
|
||||
protocol Inherited: AnyObject, Identifiable {
|
||||
var reqComputed: String { get set }
|
||||
static var reqStatic: Int { get }
|
||||
}
|
||||
|
||||
extension [ServerTrustEvaluating] {
|
||||
func sugarExt() {}
|
||||
}
|
||||
|
||||
func voidParamProof(cb: (Void) -> Void) -> Result<Foo, Err> {
|
||||
callMe()
|
||||
return .success(Foo())
|
||||
}
|
||||
|
||||
func nestedGenericRet() -> Result<Array<Foo>, Err> { fail() }
|
||||
func voidRet() -> Void { noop() }
|
||||
func tupleRet() -> (Int, Foo) { (1, Foo()) }
|
||||
func fnRet() -> (Int) -> Foo { { _ in Foo() } }
|
||||
func optRet() -> Session? { nil }
|
||||
func builderRet() -> KF.Builder { KF.Builder() }
|
||||
|
||||
func callZooExtra(m: [[Int]], arr: [Int], f: () -> Void) {
|
||||
Foo.init(raw: "x")
|
||||
"""
|
||||
multi
|
||||
""".trimmed()
|
||||
["k": 1].lookup()
|
||||
(f)()
|
||||
arr[0]
|
||||
m[1][2]
|
||||
.make()
|
||||
try? thrower()
|
||||
Task { await asyncFn() }
|
||||
let msg = "count \(counter.next())"
|
||||
#warning("torture warning")
|
||||
}
|
||||
|
||||
func staticReads(u: User) {
|
||||
let c = Color.red
|
||||
let r = Suit.hearts.rawValue
|
||||
let s = UserModel.self
|
||||
let d = Deep.Nested.leaf
|
||||
let i = lowercase.field
|
||||
let k = \Foo.bar
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
func insideDirective() { directiveCall() }
|
||||
#endif
|
||||
|
||||
// declared-then-assigned: the assignment-prune case (kernel-sweep-caught) —
|
||||
// laterAssigned MUST be pruned as a value-ref target.
|
||||
let laterAssigned: Int
|
||||
if TOP_LEVEL_MAX > 2 {
|
||||
laterAssigned = 1
|
||||
} else {
|
||||
laterAssigned = 2
|
||||
}
|
||||
let readsLater = laterAssigned + TOP_LEVEL_MAX
|
||||
|
||||
func guardNoPrune() {
|
||||
guard let TOP_LEVEL_MAX = optSource() else { return }
|
||||
use(TOP_LEVEL_MAX)
|
||||
}
|
||||
|
||||
func fnRefExtras() {
|
||||
reg(cb: onFire)
|
||||
let sel1 = #selector(fire)
|
||||
let sel2 = #selector(onNote(_:))
|
||||
self.x = x
|
||||
}
|
||||
|
||||
import class Darwin.FILE
|
||||
@testable import TortureKit
|
||||
Reference in New Issue
Block a user