Skip to content

represent FlexibleType using AppliedType - #27004

Merged
olhotak merged 14 commits into
scala:mainfrom
dotty-staging:rebased-simplified-26245
Sep 18, 2026
Merged

olhotak merged 14 commits into
scala:mainfrom
dotty-staging:rebased-simplified-26245

Conversation

@olhotak

@olhotak olhotak commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This is a rebased version of #26245. It also removes the unrelated and now-outdated changes that enable explicit nulls by default, to make the changes for the representation of FlexibleType more clearly visible.

Have you relied on LLM-based tools in this contribution?

No

How was the solution tested?

Covered by existing tests (this is a refactoring)

override final def baseClasses(using Context): List[ClassSymbol] = hi.baseClasses
}
// override final def baseClasses(using Context): List[ClassSymbol] = hi.baseClasses
// }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leftover comments.

// It is not necessary according to the use cases, so we choose to use a simpler
// rule.

def unapply(tp: Type)(using Context): Option[Type] = tp match

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def unapply(tp: Type)(using Context): Option[Type] = tp match
def unapply(tp: AppliedType)(using Context): Option[Type] = tp match

@odersky odersky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A made derivedFlexibleType an extension method over AppliedTypes. That streamlines the treatmemt.

Otherwise, this looks good to me. I think overall this achieves some simplification.

@odersky odersky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A made derivedFlexibleType an extension method over AppliedTypes. That streamlines the treatmemt.

Otherwise, this looks good to me. I think overall this achieves some simplification.

HarrisL2 and others added 13 commits September 18, 2026 09:42
Inside QuotesImpl the opaque `type FlexibleType = Types.AppliedType` is
transparent, so `case FlexibleType(tp)` type-tests against AppliedType and
matched any applied type. Returning `Some(...)` unconditionally then made the
pattern irrefutable, and the inner `.get` threw NoSuchElementException for
non-flexible applied types (e.g. List[Int], Option[String]) in
TypeReprMethods.typeArgs.

Quotes.scala already declares this as `Option[TypeRepr]`, so returning the
dotc-level result directly is both simpler and within the published API.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@olhotak
olhotak force-pushed the rebased-simplified-26245 branch from 00f46f1 to c2aa21e Compare September 18, 2026 07:43
@olhotak
olhotak enabled auto-merge (squash) September 18, 2026 11:01
@olhotak
olhotak merged commit 7414c83 into scala:main Sep 18, 2026
64 checks passed
@olhotak
olhotak deleted the rebased-simplified-26245 branch September 18, 2026 11:51
@WojciechMazur WojciechMazur added this to the 3.10.1 milestone Oct 11, 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.

6 participants