ITADN

Bug: @Test/@Suite silently not discovered in extensions of concrete generic type specializations

#1508Closedcoenttb 创建于 2026-01-28
C
coenttbcommented
## Description `@Test` and `@Suite` macros compile without error inside extensions of concrete generic type specializations (e.g., `extension Container<Int>`), but the resulting tests are silently invisible to `swift test list` and never execute. No warning or diagnostic is emitted. ## Environment - **Swift version**: Apple Swift version 6.2.3 (swiftlang-6.2.3.3.21 clang-1700.6.3.2) - **Target**: arm64-apple-macosx26.0 ## Minimal Reproduction (6 lines) ```swift import Testing struct Container<T> {} extension Container<Int> { @Suite struct Tests { @Test("never discovered") func bug() { #expect(Bool(true)) } } } ``` ## To Reproduce ```bash git clone https://github.com/coenttb/swift-issue-testing-suite-discovery-generic-specialization cd swift-issue-testing-suite-discovery-generic-specialization swift test list ``` **Expected**: `Container<Swift.Int>/Tests/bug()` appears in output **Actual**: Only `Control/Tests/control()` appears; `Container<Int>/Tests` is absent ## Conditions Required All 3 conditions must be present: | # | Condition | Description | |---|-----------|-------------| | 1 | Generic struct | e.g., `struct Container<T> {}` | | 2 | Concrete specialization extension | e.g., `extension Container<Int>` | | 3 | @Test macro | Applied to method inside that extension | ## Verified Test Results | Configuration | Result | |---------------|--------| | `extension Container<Int> { @Suite ... }` | ❌ Compiles, NOT discovered | | `extension Control { @Suite ... }` (non-generic struct) | ✅ Discovered, passes | | `extension Container { @Suite ... }` (unconstrained) | ❌ Does not compile ("static stored properties not supported in generic types") | ## Reproduction Repository https://github.com/coenttb/swift-issue-testing-suite-discovery-generic-specialization ## Related Issues - #941 — Similar symptom (tests not discovered in extensions), but that issue was about cross-module extensions of non-generic types, which works. This issue is specifically about generic type specializations within the same module. ## Impact This prevents organizing test suites as extensions of the types they test when those types are generic. Workaround: use a non-generic struct or enum as the test suite container.
关闭于 2026-01-28 1 条评论