-
Notifications
You must be signed in to change notification settings - Fork 1.1k
inline if
over an inline def
doesn't work when overriding a method
#12072
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
Labels
Milestone
Comments
FYI this situation was a little bit worse in 3.0.0-RC1. Here's a very similar case where calling import scala.quoted.*
object M {
transparent inline def f(inline s: String): String | Null =
${ f('s) }
def f(s: Expr[String])(using Quotes): Expr[String | Null] = {
s.valueOrError // required
'{ null }
}
} object T2 {
import M.f
private inline val V = "V"
private inline def D = "D"
trait Trait { def s: String }
object MatchFV extends Trait {
override transparent inline def s: String =
inline f(V) match { case "V" => "o"; case _ => "x" } // error in RC1
}
object MatchFD extends Trait {
override transparent inline def s: String =
inline f(D) match { case "D" => "o"; case _ => "x" }
}
}
|
Minimized inline def c: Int = 2
trait A:
def f: Unit
class B extends A:
override inline def f: Unit =
inline if c == 2 then () else () |
Mimimized transparent inline def f: Null = null
inline def g: Unit =
inline if f == "V" then () else ()
def test = g |
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2021
* Better handling of inlined expression * Handle `null` in `==` and `!=` Fixes scala#12072
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2021
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2021
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2021
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2021
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 14, 2021
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
Hey btw, just wanted to say thanks @nicolasstucki. You're fixing many a bug and pretty quickly too. It's appreciated! 🙂 🌹 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
Both:
Minimized code
Output
Expectation
It should all compile.
What's even more interesting about this is that you change
to
then errors 2 and 3 disappear, but the first error remains.
The text was updated successfully, but these errors were encountered: