Skip to content

Commit

Permalink
Do match type reduction atPhaseNoLater than ElimOpaque
Browse files Browse the repository at this point in the history
[Cherry-picked 6a40dd5][modified]
  • Loading branch information
WojciechMazur committed Jul 4, 2024
1 parent eb6c59d commit f4381a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ object Phases {
private var myPatmatPhase: Phase = _
private var myElimRepeatedPhase: Phase = _
private var myElimByNamePhase: Phase = _
private var myElimOpaquePhase: Phase = _
private var myExtensionMethodsPhase: Phase = _
private var myExplicitOuterPhase: Phase = _
private var myGettersPhase: Phase = _
Expand All @@ -244,6 +245,7 @@ object Phases {
final def patmatPhase: Phase = myPatmatPhase
final def elimRepeatedPhase: Phase = myElimRepeatedPhase
final def elimByNamePhase: Phase = myElimByNamePhase
final def elimOpaquePhase: Phase = myElimOpaquePhase
final def extensionMethodsPhase: Phase = myExtensionMethodsPhase
final def explicitOuterPhase: Phase = myExplicitOuterPhase
final def gettersPhase: Phase = myGettersPhase
Expand Down Expand Up @@ -271,6 +273,7 @@ object Phases {
myRefChecksPhase = phaseOfClass(classOf[RefChecks])
myElimRepeatedPhase = phaseOfClass(classOf[ElimRepeated])
myElimByNamePhase = phaseOfClass(classOf[ElimByName])
myElimOpaquePhase = phaseOfClass(classOf[ElimOpaque])
myExtensionMethodsPhase = phaseOfClass(classOf[ExtensionMethods])
myErasurePhase = phaseOfClass(classOf[Erasure])
myElimErasedValueTypePhase = phaseOfClass(classOf[ElimErasedValueType])
Expand Down Expand Up @@ -489,6 +492,7 @@ object Phases {
def refchecksPhase(using Context): Phase = ctx.base.refchecksPhase
def elimRepeatedPhase(using Context): Phase = ctx.base.elimRepeatedPhase
def elimByNamePhase(using Context): Phase = ctx.base.elimByNamePhase
def elimOpaquePhase(using Context): Phase = ctx.base.elimOpaquePhase
def extensionMethodsPhase(using Context): Phase = ctx.base.extensionMethodsPhase
def explicitOuterPhase(using Context): Phase = ctx.base.explicitOuterPhase
def gettersPhase(using Context): Phase = ctx.base.gettersPhase
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4936,7 +4936,7 @@ object Types extends TypeUtils {
case ex: Throwable =>
handleRecursive("normalizing", s"${scrutinee.show} match ..." , ex)

def reduced(using Context): Type = {
def reduced(using Context): Type = atPhaseNoLater(elimOpaquePhase) {

def contextInfo(tp: Type): Type = tp match {
case tp: TypeParamRef =>
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i19434.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

object Test:

object Named:
opaque type Named[name <: String & Singleton, A] >: A = A

type DropNames[T <: Tuple] = T match
case Named.Named[_, x] *: xs => x *: DropNames[xs]
case _ => T

def f[T <: Tuple]: DropNames[T] = ???

0 comments on commit f4381a9

Please sign in to comment.