-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
@static
annotation does not work for given
#19304
Comments
This should work: @static private val myFoo: Foo[String] = new {}
@static given Foo[String] = myFoo |
Unfortunately it does not work: import scala.annotation.static
trait Foo[A]
object Foo:
@static private val myFoo: Foo[String] = new {}
@static given Foo[String] = myFoo // error: Lazy @static fields are not supported |
The issue is that We could force it to be a |
Would simply dropping the @static on the given work? Never mind, I think we can fix this by tweaking the way givens are translated. |
The should work now: import scala.annotation.static
trait Foo[A]
object Foo:
@static val myFoo: Foo[String] = new {}
@static given Foo[String] = myFoo |
Compiler version
3.3.1
Minimized code
Output
Expectation
Declaring it as an
implicit val
compiles fine. So my expectation is that there is a way to do this withgiven
as well.An
implicit def
also works.The text was updated successfully, but these errors were encountered: