Closed
Description
Similar to #12072. In this case, inline match
expressions that work normally, fail to compile in overridden methods.
Compiler version
Both:
- 3.0.0-RC1
- 3.0.1-RC1-bin-20210411-b44cafa-NIGHTLY
Minimized code
transparent inline def f: Option[String] =
None
object Override {
trait Trait { def s: String }
object OK extends Trait {
override transparent inline def s: String =
inline f match {
case Some("x") => "x"
case Some("y") => "y"
case None => "-"
}
}
// error: Some("y") | None
object KO_1 extends Trait {
override transparent inline def s: String =
inline f match {
case Some("x") => "x"
case Some("y")
| None => "0"
}
}
// error: no None
object KO_2 extends Trait {
override transparent inline def s: String =
inline f match {
case Some("x") => "x"
case Some("y") => "y"
case Some(z) => "z"
// case None => "0"
}
}
}
object NonOverride {
transparent inline def ok_1: String =
inline f match {
case Some("x") => "x"
case Some("y") => "y"
case None => "-"
}
// ok: Some("y") | None
transparent inline def ok_2: String =
inline f match {
case Some("x") => "x"
case Some("y")
| None => "0"
}
// ok: no None
transparent inline def ok_3: String =
inline f match {
case Some("x") => "x"
case Some("y") => "y"
case Some(z) => "z"
// case None => "0"
}
}
Output
[error] -- Error: /home/golly/scala3bug/sbt/src/main/scala/BUG.scala:20:13 -------------
[error] 20 | inline f match {
[error] | ^
[error] | cannot reduce inline match with
[error] | scrutinee: None : None.type
[error] | patterns : case Some.unapply[String]("x"):Some[String]
[error] | case (Some.unapply[String]("y"):Some[String]) | None
[error] | This location contains code that was inlined from BUG.scala:20
[error] -- Error: /home/golly/scala3bug/sbt/src/main/scala/BUG.scala:30:13 -------------
[error] 30 | inline f match {
[error] | ^
[error] | cannot reduce inline match with
[error] | scrutinee: None : None.type
[error] | patterns : case Some.unapply[String]("x"):Some[String]
[error] | case Some.unapply[String]("y"):Some[String]
[error] | case Some.unapply[String](z @ _):Some[String]
[error] | This location contains code that was inlined from BUG.scala:30
[error] two errors found
Expectation
It should compile.