Skip to content

Remove SymbolTestsCore fixtures for ABI-invisible features#63

Merged
Mx-Iris merged 2 commits intomainfrom
chore/prune-abi-invisible-fixtures
Apr 17, 2026
Merged

Remove SymbolTestsCore fixtures for ABI-invisible features#63
Mx-Iris merged 2 commits intomainfrom
chore/prune-abi-invisible-fixtures

Conversation

@Mx-Iris
Copy link
Copy Markdown
Member

@Mx-Iris Mx-Iris commented Apr 17, 2026

Summary

移除 SymbolTestsCore 中 9 个测试 fixture 文件,它们测试的特性在 Mach-O 二进制/metadata 中完全不可还原,只会作为噪音干扰 SwiftInterface 的符号测试。

删除的文件与理由

文件 不可还原的特性 证据
Frozen.swiftFrozenResilienceContrast.swift @frozen 纯 ABI resilience 标记,不在 runtime metadata
Typealiases.swift typealias 编译期展开
AccessLevels.swift public/private/internal/open 不改变 mangled name 与 descriptor
Availability.swift @available 编译期检查
PropertyObservers.swift willSet / didSet setter 实现细节,snapshot 里完全消失
DefaultArguments.swift 默认参数值 snapshot 显示所有 = value 全部丢失
RethrowingFunctions.swift rethrows mangle 与 throws 相同,snapshot 里变成 throws
NestedFunctions.swift 嵌套函数 nm 验证 inner function 和 LocalStruct 均无 nominal type descriptor

验证方式

  • nm -gU <file>.o | xcrun swift-demangle 检查符号表
  • 对比 Tests/SwiftInterfaceTests/Snapshots 现有快照验证特性在 SwiftInterface 输出中消失

Test plan

  • swift build 通过
  • swift test --filter SymbolTestsCoreIntegrationTests 通过(测试可能引用这些类型,需要检查)
  • swift test --filter MachOFileInterfaceSnapshotTests 通过(snapshot 需要重新生成)

These features leave no trace in Mach-O metadata that SwiftInterface can
recover from a release binary, so the fixtures only added noise to the
symbol tests:

- @Frozen / resilience contrast: compile-time ABI attribute only
- typealias: expanded at compile time
- access levels (public/private/internal/open): do not change mangling
- @available: compile-time availability check
- willSet/didSet: setter implementation detail, not in metadata
- default parameter values: not encoded in method signatures
- rethrows: mangles identically to throws
- nested functions: no nominal type descriptor emitted

Verified via nm + swift-demangle on the built .o files and by diffing
against the SwiftInterface snapshot output.
Copilot AI review requested due to automatic review settings April 17, 2026 09:40
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes several Swift test files related to access levels, availability, default arguments, and other metadata-driven features, while updating the Xcode scheme to include a new build entry for SwiftInspection. Feedback was provided regarding an unintentional downgrade of the LastUpgradeVersion in the scheme file, which should be reverted to ensure consistency across development environments.

<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2640"
LastUpgradeVersion = "2630"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

LastUpgradeVersion 从 "2640" 降级到了 "2630"。这通常是由于使用了旧版本的 Xcode 打开项目并自动修改了 scheme 文件导致的。建议恢复此版本号,以保持与团队其他成员使用的开发环境一致,并减少不必要的配置变动。

   LastUpgradeVersion = "2640"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes several SymbolTestsCore test fixture source files whose language features are not recoverable from Mach-O binary metadata, reducing noise in SwiftInterface-based symbol/snapshot tests.

Changes:

  • Delete 9 SymbolTestsCore fixture files covering ABI-/compile-time-only features (e.g. @frozen, typealias, default args, @available, rethrows, nested functions, property observers, access levels).
  • Update the Xcode SwiftPM generated scheme (MachOSwiftSection-Package.xcscheme) including LastUpgradeVersion and an added SwiftInspection build entry.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Tests/Projects/SymbolTests/SymbolTestsCore/Typealiases.swift Remove typealias-focused fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/RethrowingFunctions.swift Remove rethrows-focused fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/PropertyObservers.swift Remove willSet/didSet fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/NestedFunctions.swift Remove nested/local-function + local-type fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/FrozenResilienceContrast.swift Remove @frozen vs resilient contrast fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/Frozen.swift Remove @frozen/@inlinable/@usableFromInline fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/DefaultArguments.swift Remove default-argument fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/Availability.swift Remove @available fixture namespace
Tests/Projects/SymbolTests/SymbolTestsCore/AccessLevels.swift Remove access-level variation fixture namespace
.swiftpm/xcode/xcshareddata/xcschemes/MachOSwiftSection-Package.xcscheme Scheme metadata/build-entry changes (appears incidental to fixture removal)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2 to 4
<Scheme
LastUpgradeVersion = "2640"
LastUpgradeVersion = "2630"
version = "2.2">
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LastUpgradeVersion was changed to "2630", but the other shared Xcode schemes in .swiftpm/xcode/xcshareddata/xcschemes/ use "2640". Unless this downgrade is intentional, please keep LastUpgradeVersion consistent to avoid unnecessary scheme churn across Xcode versions.

Copilot uses AI. Check for mistakes.
Comment on lines +201 to +214
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SwiftInspection"
BuildableName = "SwiftInspection"
BlueprintName = "SwiftInspection"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scheme change adds a BuildActionEntry for the SwiftInspection target, which is unrelated to the PR’s stated goal (removing SymbolTestsCore fixtures). If this isn’t required to keep builds/tests working, consider reverting it to keep the PR focused and reduce incidental Xcode scheme diffs.

Copilot uses AI. Check for mistakes.
Comment on lines +201 to +214
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SwiftInspection"
BuildableName = "SwiftInspection"
BlueprintName = "SwiftInspection"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these SymbolTestsCore fixture sources will change the SwiftInterface output, but the PR does not update the existing snapshot baseline (e.g. Tests/SwiftInterfaceTests/Snapshots/__Snapshots__/MachOFileInterfaceSnapshotTests/interfaceSnapshot.1.txt currently contains enum AccessLevels, enum Availability, enum DefaultArguments, etc.). Please regenerate/update the affected snapshots in the same PR so snapshot tests don’t fail.

Copilot uses AI. Check for mistakes.
@Mx-Iris
Copy link
Copy Markdown
Member Author

Mx-Iris commented Apr 17, 2026

Code review

Found 2 issues:

  1. Snapshot not regenerated — MachOFileInterfaceSnapshotTests will fail on CI. The deleted fixtures still appear as enum AccessLevels, enum Availability, enum DefaultArguments, enum Frozen, enum FrozenResilienceContrast, enum NestedFunctions, enum PropertyObservers, enum RethrowingFunctions, enum Typealiases in the committed snapshot. PR's own test plan flags this as a TODO (snapshot 需要重新生成) but the diff does not include the regeneration.

}
}
enum NestedFunctions {
struct NestedFunctionHolderTest {
class LocalClass {
var label: Swift.String
}
func outerFunction(parameter: Swift.Int) -> Swift.Int
func outerGenericFunction<A>(element: A) -> [A]
func outerWithLocalType() -> Swift.Int
func outerWithLocalClass() -> Swift.String
}
}
enum NestedGenerics {

  1. NestedFunctions.swift deletion drops real coverage, not just noise. The PR rationale (nested functions: no nominal type descriptor emitted) applies to the inner functions, but the file's outerWithLocalClass() contains a function-local class LocalClass that does emit a nominal type descriptor — visible in the snapshot at line 1397 (class LocalClass inside struct NestedFunctionHolderTest). Spec docs/superpowers/specs/2026-04-13-symboltestscore-fixture-expansion-design.md explicitly lists this fixture (Align with the original Demangler & NodePrinter #15) as the _LXXX local-symbol mangling case, and no other fixture places a class inside a function body. Consider keeping outerWithLocalClass() (and optionally outerWithLocalType()) and dropping only the truly-invisible inner functions.

enum NestedFunctions {
struct NestedFunctionHolderTest {
class LocalClass {
var label: Swift.String
}
func outerFunction(parameter: Swift.Int) -> Swift.Int
func outerGenericFunction<A>(element: A) -> [A]
func outerWithLocalType() -> Swift.Int
func outerWithLocalClass() -> Swift.String
}
}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Address code review feedback:

- Restore NestedFunctions.swift with only `outerWithLocalClass()` and
  its function-local `LocalClass`. The fixture covers `_LXXX` local-symbol
  mangling — `LocalClass` emits a nominal type descriptor visible in
  SwiftInterface output. The truly-ABI-invisible pieces (inner functions,
  local struct) remain removed.

- Regenerate MachOFileInterfaceSnapshotTests and MachOFileDumpSnapshotTests
  snapshots so SymbolTestsCore-backed tests match the pruned fixture set.
@Mx-Iris Mx-Iris merged commit c7c2b3a into main Apr 17, 2026
@Mx-Iris Mx-Iris deleted the chore/prune-abi-invisible-fixtures branch April 17, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants