-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:nullabilityarea:private optionsIssues tied to -Y private/internal compiler settings.Issues tied to -Y private/internal compiler settings.itype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore
Description
Compiler version
3.7.4 - warning
3.7.2 - ok
3.3.7 - ok
Minimized code
//> using scala "3.7.4"
//> using option "-Yexplicit-nulls"
import scala.annotation.nowarn
import java.time.Instant
sealed trait Eff[+A]:
def run: A = this match
case x: Eff.Impure[A] => x()
object Eff:
sealed abstract class Impure[+A]() extends Eff[A] with Function0[A]
@nowarn("msg=anonymous class definition")
inline def impure[A](inline a: => A): Eff[A] =
new Impure[A]:
override def apply(): A = a
def instant: Eff[Instant] = impure(Instant.now().nn)
@main def main =
Eff.impure:
println("hell world")
.runOutput
[warn] method apply exposes a flexible type in its inferred result type (java.time.Instant)?. Consider annotating the type explicitly
[warn] def instant: Eff[Instant] = impure(Instant.now().nn)
[warn] Expectation
Compiles without warning.
We can make the warning go away, by applying one of the following modifications:
- Remove
inlines - Remove covariance from
Eff[+A]andImpure[+A] - Add explicit type parameter to the last
impurecall:def instant: Eff[Instant] = impure[Instant](Instant.now().nn)
Metadata
Metadata
Assignees
Labels
area:nullabilityarea:private optionsIssues tied to -Y private/internal compiler settings.Issues tied to -Y private/internal compiler settings.itype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore