Skip to content

Widen skolem types when adding parent refinements #22488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/NamerOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ object NamerOps:
*/
extension (tp: Type)
def separateRefinements(cls: ClassSymbol, refinements: mutable.LinkedHashMap[Name, Type] | Null)(using Context): Type =
val widenSkolemsMap = new TypeMap:
def apply(tp: Type) = mapOver(tp.widenSkolem)
tp match
case RefinedType(tp1, rname, rinfo) =>
try tp1.separateRefinements(cls, refinements)
finally
if refinements != null then
val rinfo1 = widenSkolemsMap(rinfo)
refinements(rname) = refinements.get(rname) match
case Some(tp) => tp & rinfo
case None => rinfo
case Some(tp) => tp & rinfo1
case None => rinfo1
case tp @ AnnotatedType(tp1, ann) =>
tp.derivedAnnotatedType(tp1.separateRefinements(cls, refinements), ann)
case tp: RecType =>
Expand Down
4 changes: 4 additions & 0 deletions tests/pos/i22456.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import language.experimental.modularity

class T(tracked val y: Int)
class C(tracked val x: Int) extends T(x + 1)