← Back to Pull requests

[swift2objc] Restore setters on stored global variables #3838

Open
unknown opened this pull request with 273 lines diff across 3 files
View on GitHub
unknown unknown commented on Dec 02, 2026 03:04 UTC
Author

Description

Stored global variables are currently wrapped as get-only properties. For example, public var globalRepresentableVariable = 1 generates:

@objc static public var globalRepresentableVariableWrapper: Int {
  get {
    globalRepresentableVariable
  }
}

so the variable can't be assigned from Dart.

This regressed in #2940. That PR changed _parsePropertyGetAndSet to return (getter: false, setter: false) for stored properties, and updated parsePropertyDeclaration to treat that case as settable. parseGlobalVariableDeclaration was not updated, and still computes isConstant: info.constant || !info.setter, which is now true for every stored global. The expected output of the global_variables_and_functions integration test was regenerated in that PR without the setters.

The fix is to only treat a global as constant if it's declared with let, or has a getter with no setter. This mirrors the hasSetter logic in parsePropertyDeclaration.

public private(set) var globals stay get-only, because the symbol graph reports them as { get }. I added one to the global_variables_and_functions test to cover that.

The available and optional expected outputs also change, because each contains a stored global var that gets its setter back.

Related Issues

I couldn't find an existing issue for this. I found it while writing the integration test for #2049.

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.

  • I've run dart tool/ci.dart --all locally and resolved all issues identified. Two tests outside this package fail on my machine and are unrelated to this change: native_toolchain_c/test/clinker/rust_test.dart (I don't have rustc installed) and a 30s timeout in hooks_runner/test/build_runner/build_planner_test.dart.

  • All existing and new tests are passing. I added new tests to check the change I am making.

  • The PR is actually solving the issue.

  • I have updated CHANGELOG.md for the relevant packages.

  • I have updated the pubspec package version (0.3.2-wip).
  • Diff: 273 lines (+204 / -69) across 3 files Reviewer: liamappelbe Review duration: 1626m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 273 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.336
    Real PR Conversation Timeline
    1 comments
    "Review active on #3838"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.5% (MEDIUM) · Higher = larger blast radius
    39.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%