Fix #935 + implement #770: context-function-scoped path selectors - #948
Merged
MateuszKubuszok merged 3 commits intoSep 1, 2026
Merged
Conversation
When deriving Foo → Option[Bar], TransformToOptionRule wraps Foo into Option[Foo] and delegates to OptionToOption, which recurses into Foo → Bar. Source-side subtype overrides (from withEnumCaseHandled) are dropped during that recursion because their paths don't match the Option wrapper path, and their return type (Option[Bar]) doesn't match the inner target (Bar). Fix: when source-side subtype overrides exist and From is a sealed hierarchy, generate the pattern match directly at the From → Option[To] level — consuming overrides there and deriving non-overridden subtypes by name-matching against the inner target's subtypes.
Path extension methods (matching, everyItem, everyMapKey, everyMapValue, matchingSome, matchingLeft, matchingRight) were available on every value once dsl.* or syntax.* was imported. Now they require a ChimneySelector given, which is only provided inside DSL selector lambdas via context functions (ChimneySelector ?=> From => T). - Add sealed trait ChimneySelector phantom type in internal.runtime - Add `using ChimneySelector` to path extension blocks in syntax.scala - Change selector params in all Scala 3 DSL classes to context functions - Update DslDefinitions parser to unwrap Block/nested-lambda wrapping - Widen macro adapter selector params to Expr[Any] Not a breaking change: selector functions are inline macro parameters, so the context function wrapper is invisible to existing user code.
Remove dead `OptionFromType` implicit val from `wrapInOptionAndTransform` (moved to `wrapAndDelegateToOptionToOption` during #935 refactor) — Scala 2.13 -Werror rejects unused locals. Fix Scaladoc line wrap in ChimneySelector.scala for scalafmt.
MateuszKubuszok
deleted the
fix-935-and-770-context-function-selectors
branch
September 1, 2026 21:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
withEnumCaseHandledoverride silently dropped when target type isOption[B]— the override is now consumed at the correct derivation level before Option wrappingmatching,everyItem,everyMapKey, etc.) are now scoped to selector lambdas via context functions, no longer polluting the global scopeFix #935: withEnumCaseHandled with Option target
Root cause:
TransformToOptionRulewrapsFromintoOption[From]and delegates toOptionToOption, which recurses intoFrom → InnerTo. During recursion, source-side subtype overrides are dropped because:matching[Some[From]].value(the recursion prefix)Option[To]) doesn't match the inner target (InnerTo)Fix: When source-side subtype overrides exist and
Fromis a sealed hierarchy,TransformToOptionRulenow generates the pattern match directly at theFrom → Option[To]level — consuming overrides there (where the return type matches) and deriving non-overridden subtypes by name-matching againstInnerTo's subtypes.Implement #770: context-function-scoped path extensions
Path extension methods were available on every value once
dsl.*orsyntax.*was imported. Now they requireusing ChimneySelector, which is only provided inside DSL selector lambdas via context functions (ChimneySelector ?=> From => T).Changes:
ChimneySelectorsealed trait phantom type ininternal.runtimeusing ChimneySelectorconstraint on path extension blocks insyntax.scalaDslDefinitionsparser updated to unwrap Block/nested-lambda wrapping from context function resolutionExpr[Any]Not a breaking change: selector functions are
inlinemacro parameters, so the context function wrapper is invisible to existing user code.Test plan
withEnumCaseHandledtoOptiontarget)