-
Notifications
You must be signed in to change notification settings - Fork 1.1k
strange MatchError if match body has generic method call without explicit type param #12976
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
Comments
Is the expected type |
Here's the code of the main method after pattern matcher: def main(args: Array[String]): Unit =
{
val a: A = A.apply("aaa")
val b: B = new B()
matchResult4[String]:
{
case val x5: (a : A) = a
if x5.ne(null) then
{
case val x6: A = A.unapply(x5)
case val x7: String = x6._1
case val s: String = x7
return[matchResult4]
{
b.b1[Any](s)
}
}
else ()
throw new MatchError(x5)
}
matchResult5[Boolean]:
{
case val x8: (a : A) = a
if x8.ne(null) then
{
case val x9: A = A.unapply(x8)
case val x10: String = x9._1
case val s: String = x10
return[matchResult5]
{
b.b2[Boolean](s)
}
}
else ()
throw new MatchError(x8)
}
matchResult6[Nothing]:
{
case val x11: (a : A) = a
if x11.ne(null) then
{
case val x12: A = A.unapply(x11)
case val x13: String = x12._1
case val s: String = x13
b.b2[Nothing](s)
}
else ()
throw new MatchError(x11)
}
} In the third case, the I think we should either reject that case statically, or not leave out the |
The case where it happens is here (line 931 of Pattern Matcher) case ResultPlan(tree) =>
if (tree.tpe <:< defn.NothingType) tree // For example MatchError
else Return(tree, ref(resultLabel)) The commit is from #5082. |
Reverting to the first version of scala#5082. Fixes scala#12976
Reverting to the first version of scala#5082. Fixes scala#12976
Compiler version
3.0.0
,3.0.1-RC2
and3.0.2-RC1-bin-20210626-f33bc8d-NIGHTLY
Minimized code
Output
Expectation
The text was updated successfully, but these errors were encountered: