-
Notifications
You must be signed in to change notification settings - Fork 21
Open
scala/scala
#11052Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)implicitinfer
Milestone
Description
reproduction steps
This is a short example:
import scala.concurrent._
trait TestModule {
implicit val ec: ExecutionContext
}
class ClassA()(implicit ec: ExecutionContext) {}
trait Trait1 {
this: TestModule =>
implicit val ec: ExecutionContext
lazy val a: ClassA = new ClassA()
}It compiles fine until you remove an explicit type declaration in the last line:
lazy val a = new ClassA()
and now it starts complaining about implicit parameters (ExecutionContext in this example).
Behaviour presents on Scala 2.13.4 / 2.12.12
But not on dotty/Scala 3, so might be fixed there.
problem
Unclear behaviour either of type inference or implicit resolution.
There are different ways to make it compile, another way is removing duplicate implicit val ec: ExecutionContext but why it behaves like this unclear. Not sure if this was reported before or expected behaviour.
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)implicitinfer