Skip to content

Allow closures to read a protected base field#19991

Open
T-Gro wants to merge 2 commits into
mainfrom
fix/5302-protected-closure-access
Open

Allow closures to read a protected base field#19991
T-Gro wants to merge 2 commits into
mainfrom
fix/5302-protected-closure-access

Conversation

@T-Gro

@T-Gro T-Gro commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #5302

// C#: class BaseClass { protected string ProtectedField; }
type DerivedClass() =
    inherit BaseClass()
    member x.Run() = let f () = x.ProtectedField in f ()   // was FS1097

Object expressions stay the boundary — the override body is a separate type, not nested under DerivedClass:

{ new BaseClass() with
    override this.ToString() = (lazy this.ProtectedField).Value }   // still FS1097

--langversion:preview

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Jun 24, 2026
@T-Gro T-Gro requested a review from abonie June 25, 2026 13:48
@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Protected member inaccessible

1 participant