Skip to content

@static annotation does not work for given #19304

Closed
@armanbilge

Description

@armanbilge

Compiler version

3.3.1

Minimized code

import scala.annotation.static
trait Foo[A]
object Foo:
  @static given foo: Foo[String] = new {}

Output

4 |  @static given foo: Foo[String] = new {}
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |  Lazy @static fields are not supported
1 error found

Expectation

Declaring it as an implicit val compiles fine. So my expectation is that there is a way to do this with given as well.

@static implicit val foo: Foo[String] = new {}

An implicit def also works.

@static implicit def foo: Foo[String] = new {}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions