-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #9171: Eliminate difference _ and Any in MT #9172
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ object Test { | |
case Int => LL[LL[X]] | ||
} | ||
def a: L[Boolean] = ??? | ||
def b: L[Int] = ??? | ||
// def b: L[Int] = ??? // times out | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do these time out now? Isn't that a problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because instead of stoping after one step of reduction we now try to keep reducing the match type body after the first step, which causes in infinite loop. All the infinite loops that we encountered in match type reduction would eventually run out of stack, but this nicely trampolines and ultimately fails with an out of memory error. This is indeed a problem, but the only solution I see would be to add some sort of reduction counter to match type reduction similar to |
||
def g[X]: L[X] = ??? | ||
val x: Int = g[Int] // error: found: L[Int], required: Int | ||
// val x: Int = g[Int] // times out | ||
|
||
def aa: LL[Boolean] = ??? | ||
def bb: LL[Int] = ??? // error: recursion limit exceeded with reduce type LazyRef(Test.LL[Int]) match ... | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// `case _ => expr` in a match expression should be equivalant to | ||
// `case _: Any => expr`. Likewise, in a match type, `case _ => T` | ||
// should be equivalant to `case Any => T`. | ||
|
||
object Test0 { | ||
type M[X] = X match { case String => Int case Any => String } | ||
def m[X](x: X): M[X] = x match { case _: String => 1 case _: Any => "s" } | ||
} | ||
|
||
object Test1 { | ||
type M[X] = X match { case String => Int case Any => String } | ||
def m[X](x: X): M[X] = x match { case _: String => 1 case _ => "s" } | ||
} | ||
|
||
object Test2 { | ||
type M[X] = X match { case String => Int case _ => String } | ||
def m[X](x: X): M[X] = x match { case _: String => 1 case _: Any => "s" } | ||
} | ||
|
||
object Test3 { | ||
type M[X] = X match { case String => Int case _ => String } | ||
def m[X](x: X): M[X] = x match { case _: String => 1 case _ => "s" } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
simplified
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added test case (with
case Int =>
instead ofcase _ =>
) fails to compile on master with the following:That's because when match type reduction simply reduces to
body
without going throughinstantiateParams
reduction would stop without trying to further simplify thebody
in question.