Skip to content

Fix 25830 Inference of Capture-Polymorphic Lambdas#25853

Closed
bracevac wants to merge 2 commits intoscala:mainfrom
dotty-staging:ob/fix-25830-rework
Closed

Fix 25830 Inference of Capture-Polymorphic Lambdas#25853
bracevac wants to merge 2 commits intoscala:mainfrom
dotty-staging:ob/fix-25830-rework

Conversation

@bracevac
Copy link
Copy Markdown
Contributor

Fixes #25830

Alternative to #25833

How much have you relied on LLM-based tools in this contribution?

Extensively, for everything.

How was the solution tested?

New automated tests (including the issue's reproducer, if applicable)

@bracevac bracevac marked this pull request as draft April 17, 2026 20:31
@bracevac bracevac force-pushed the ob/fix-25830-rework branch 2 times, most recently from 9988b87 to a3b38c9 Compare April 20, 2026 14:18
@bracevac bracevac marked this pull request as ready for review April 20, 2026 14:20
@bracevac bracevac assigned bracevac and odersky and unassigned bracevac Apr 20, 2026
needsVariable(parent)
&& refs.isConst // if refs is a variable, no need to add another
&& !refs.isUniversal // if refs is {caps.any}, an added variable would not change anything
&& !refs.elems.exists(_.coreType.derivesFromCapSet)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@odersky the exists instead of forall is for the case we have mixed retains of the form {C, x}.

Originally added in scala#24560 to strip inferred retains from inlined call
trees before they reach the pickler. The cc setup pipeline now handles
retains correctly without this preemptive strip, and removing it
leaves scala3-bootstrapped/testCompilation green.
Fixes scala#25830. Covers plain poly lambdas, curried lambdas, mixed
outer/local scopes, capset type members, and bounded polymorphism
(see tests/pos-custom-args/captures/i25830*).
@bracevac
Copy link
Copy Markdown
Contributor Author

Continues in #25905

@bracevac bracevac closed this Apr 22, 2026
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.

CC: Type inference for capture-polymorphic lambdas is broken

2 participants