Skip to content
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

Do match type reduction atPhaseNoLater than ElimOpaque #20017

Merged
merged 1 commit into from
Mar 27, 2024
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
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 @@ -220,6 +220,7 @@ object Phases {
private var myPatmatPhase: Phase = uninitialized
private var myElimRepeatedPhase: Phase = uninitialized
private var myElimByNamePhase: Phase = uninitialized
private var myElimOpaquePhase: Phase = uninitialized
private var myExtensionMethodsPhase: Phase = uninitialized
private var myExplicitOuterPhase: Phase = uninitialized
private var myGettersPhase: Phase = uninitialized
Expand All @@ -245,6 +246,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 @@ -272,6 +274,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 @@ -511,6 +514,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 @@ -5026,7 +5026,7 @@ object Types extends TypeUtils {

private def thisMatchType = this

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] = ???
Loading