Repository navigation
Conversation
A builder in a mock's overrides replaces how a type is built. It is now typed with those of the type's mockAttributes that its initializer or hand-written mock spells too, so a closure a preview passes runs in that construction's isolation. Before, an actor mock root made the type's configuration @sendable module-wide, and a closure that called a @mainactor hand-written mock stopped compiling, though it compiled on 2.2.0. A public configuration, whose one builder serves both of the type's constructions, spells only what both spell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
…s them The rule now compares only what the user spelled in mockAttributes: a builder takes its type's mockAttributes when every mock root in the module that reaches the type spells the same ones, and no Sendable wrapper, public mock or seam reaches it. A closure passed in from a preview has no generated caller, so it does not count. Every other builder stays as before. Only attributes a closure type takes are carried; @available stays on the declarations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
…-knsfr2-mainactor-builder # Conflicts: # Sources/SafeDICore/Generators/NodeRecords/NodeRecords+MockCycle.swift
A builder now also takes its type's mockAttributes when the type's initializer or instantiate(), and its hand-written mock where it has one, spell them too, such as a @mainactor init beside a @mainactor static func mock. Every place that calls the builder already calls one of those constructions synchronously, so a builder isolated as they are is callable there. This covers callers that are main-actor only through a superclass, such as a UIKit view controller, which spell no mockAttributes and so kept the builder plain under the rule that every generated caller spells the same attributes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
Timing of 8603613Wall times measured in this run. A wall time, peak memory, size or growth row over its limit is reported here and fails no check; a shape the tool cannot generate still fails "Check Generate Time on Linux". Every run rewrites this comment, and a check that did not run in it is not listed.
Every shape and row
Growth, the head tool alone: each row at its layers and at 2 more, or at the two numbers it names; median of 3 alternating runs for time, and of 3 more with one allocator arena for peak memory. A measure fails at 2 times the smaller graph's, or at the limit beside it.
Reported and not failed:
Every shape and row
The compiler's time on single functions: 0 finding(s), reported and not failed. The compiler's time on single functions of SafeDICore, release build.
|
One base graph in sixteen, on a stream of its own, gains MainLoader, a @mainactor class whose mockAttributes spell the main actor, built by an actor's main-actor mock and by a second mocked type: a @mainactor class whose mock spells the main actor too, or a class main-actor only through its superclass whose loader's initializer and hand-written mock spell @mainactor. A preview the compile adds beside the generated code passes each mock a closure for the loader's builder that touches main-actor state. With the builder fix reverted, seeds 38 and 59 fail to compile. The mock mirror oracle skips the draw's mocked types, which a nonisolated root cannot build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
… the pass The pass that decides which builders spell their type's mockAttributes now reads the attributes from their parsed syntax instead of scanning the string, computes each type's builder attributes once and hands every spelling site the result, returns at once where no type spells a closure attribute or every one that does has constructions spelling them all, walks only what the mock roots reach otherwise, and reads each declaration from its own concrete type's entry. Its walks count their steps, and a test checks that doubling the mock roots at most doubles them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
Swift 6.2.4's release builds abort in swift_task_dealloc ("freed pointer was
not the last allocation") where nested async withValue calls are inlined into
one frame, as the builder attributes' binding was beside generateMockCode's
own. The binding now runs in an unoptimized function kept out of line, the
function it wraps is kept out of line too, and a module whose builders spell
no attributes binds nothing. The rules sentence is shortened to keep the
rules a generator file loads within their budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
…leases The draw's actor is a shape 2.3.0 rejects, so the release acceptance fixture, drawn for comparison, leaves it out the way the other actor draws do. The draw also moved the smoke and known-issue fixture and partition hashes, which this re-pins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
Requested by Dan · project thread
What changes
A builder in a mock's overrides is the closure that replaces how a type is built. Its type now carries the type's
mockAttributes, for example(@MainActor (Shelf) -> Loader)?, or(@Sendable @MainActor (Shelf) -> Loader)?where the overrides take theirSendableform. That happens in either of two cases:Sendablewrapper, public mock or seam builds it.instantiate(), and its hand-written mock where it has one, as with a@MainActor initbeside a@MainActor static func mock. Each place that calls the builder already calls one of those constructions synchronously, so a builder with the same isolation can be called there too. This covers callers that are main-actor only through a superclass, such as a UIKit view controller, which spell nomockAttributes. The builder takes only the attributes that every construction spells, because the type's one configuration serves every place that builds it.Otherwise the builder keeps today's type. SafeDI copies attributes as the user spelled them, read from their syntax. It never infers isolation from a declaration's kind, a superclass or an attribute's name. Only what a closure type can carry is copied: attributes with arguments, such as
@available(…), and the compiler's declaration-only attributes stay on the declarations.The pass that decides this runs once per module. It does nothing more where no type spells a closure attribute in
mockAttributes, or where every type that does has constructions spelling them all. Otherwise it walks only what the mock roots reach, and a counted step checks that it grows no faster than the module.Why
When an actor's mock builds a type, that type's overrides take their
@Sendableform. Take a preview that passes a closure calling a main-actor initializer or mock, such as.init(loader: { shelf in .mock(shelf: shelf) }). That compiled on 2.2.0 and does not compile on 2.4.5, because the closure is@Sendableand nonisolated there. With this change the closure is isolated as the user spelled it.Tests
SafeDIToolMockBuilderIsolationTests: five tests, each compiling its generated code together with the fixture's preview. They cover:Sendable;@availableinmockAttributes;SendableInstantiatorwith a nonisolated initializer, which stays plain;MockBuilderIsolationStepCountTestschecks that doubling the mock roots at most doubles the pass's steps.MainLoaderfrom an actor's main-actor mock and from a second mocked type. That second type is either a main-actor class whose mock spells the main actor, or a class that is main-actor only through its superclass. A preview the compile adds beside the generated code passes each mock a closure that touches main-actor state. 295 of the corpus's 5,000 seeds draw it. With the fix reverted, seeds 38 (superclass) and 59 (spelled callers) fail to compile. The value oracle's mock mirrors skip the draw's types, because a nonisolated root cannot build them.Found and not fixed
Nothing.
https://claude.ai/code/session_01HLuVQL2AyjmTVDPHyoJd4Z
Generated by Claude Code