You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objectFred {
inlinedefjim(seq:Seq[Int]) = {
inline seq match { // If this is not inline, this code works as expected, with the inline it fails as belowcase s:Seq[Int] if s.isEmpty => println("seq is empty")
case s:Seq[Int] => println("seq is not empty")
case _ => println("somthing hinky happened")
}
}
defmain(args:Array[String]):Unit= {
Fred.jim(Seq())
Fred.jim(Seq(1,2))
}
}
Output
seq is not empty
seq is not empty
Expectation
seq is empty
seq is not empty
Discussion
I am unsure whether the compiler is supposed to be able to evaluate this kind of match at compile time (which is after all when an inline match in an inline def is evaluated), so either the compiler should reject this as something that can only be be done in a runtime (i.e. non-inline) match, or it should produce the expected result.
If the inline on the match is removed, this code works as expected.
The text was updated successfully, but these errors were encountered:
Compiler version
3.02 and 3.1.0-RC1
Minimized code
Output
seq is not empty
seq is not empty
Expectation
seq is empty
seq is not empty
Discussion
I am unsure whether the compiler is supposed to be able to evaluate this kind of match at compile time (which is after all when an inline match in an inline def is evaluated), so either the compiler should reject this as something that can only be be done in a runtime (i.e. non-inline) match, or it should produce the expected result.
If the inline on the match is removed, this code works as expected.
The text was updated successfully, but these errors were encountered: