I have a code like the following:
implicit val _ = new MyClass()
And I am getting the following error:
Implicit pattern definition binds no variables
Why?
I am using Scala -> 2.13.3, SBT -> 1.3.13, and Java -> OpenJDK v14.0.2
I have a code like the following:
implicit val _ = new MyClass()
And I am getting the following error:
Implicit pattern definition binds no variables
Why?
I am using Scala -> 2.13.3, SBT -> 1.3.13, and Java -> OpenJDK v14.0.2
https://github.com/scala/scala/pull/8699
https://github.com/scala/bug/issues/11618
If a pattern definition binds no variables, it is probably a mistake if it is marked implicit, because it introduces no implicit values, or if it is a template statement, because it accidentally introduces a template member.
Please warn on:
implicit val _ = 42 implicitly[Int]
In Scala 3 (Dotty) we could provide unnamed implicit value like so
scala> class MyClass(val x: Int)
// defined class MyClass
scala> given MyClass(41)
// defined object given_MyClass
scala> summon[MyClass].x + 1
val res0: Int = 42