Skip to content

Fix #19789: Merge same TypeParamRef in orDominator - #20090

Merged
odersky merged 1 commit into
scala:mainfrom
dotty-staging:fix-19789
Apr 10, 2024
Merged

odersky merged 1 commit into
scala:mainfrom
dotty-staging:fix-19789

Conversation

@noti0na1

@noti0na1 noti0na1 commented Apr 4, 2024

Copy link
Copy Markdown
Member

Fix #19789

Merge refined or applied types if they share the same TypeParamRef as tycon in orDominator.

@noti0na1
noti0na1 requested a review from odersky April 4, 2024 19:53

@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.

I think this can be optimized by adding a first clause

 if tp1 eq tp2 then tp1

Also, instead of comparing TypeParamRefs directly we could just do it like this:

case tp1: TypeParamRef if tp1 == tp2 => tp1

Note the first test might still need the second, since hash-consing is not 100% assured (e.g. we might get copies after a table overflow). So exploiting hash consing should always be an optimization only.

@odersky odersky assigned noti0na1 and unassigned odersky Apr 7, 2024
Comment thread compiler/src/dotty/tools/dotc/core/TypeOps.scala Outdated
@odersky
odersky merged commit 9b3495a into scala:main Apr 10, 2024
@odersky
odersky deleted the fix-19789 branch April 10, 2024 20:48
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur added a commit that referenced this pull request Jul 5, 2024
…21056)

Backports #20090 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
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.

AssertionError: Failure to join alternatives

3 participants