Closed
Description
Minimized code
macros.scala:
import scala.quoted._
type Foo
type F[X]
def varargsFunc(funcs0: Foo*) = ???
inline def mcr1: F[String] = ${ mcr1Impl }
def mcr1Impl(using QuoteContext): Expr[F[String]] = '{???}
inline def mcr2: Unit = ${mcr2Impl}
def mcr2Impl(using ctx: QuoteContext): Expr[Unit] =
val func: Expr[Seq[Foo] => Unit] =
'{ (esx: Seq[Foo]) => varargsFunc(esx: _*) }
val trees: Expr[Seq[Foo]] =
'{Nil}
Expr.betaReduce(func)(trees)
Test.scala:
def f(x: => Any) = ???
def g = f {
mcr1
mcr2
}
Compile without any flags.
Output
-- Error: /Users/kmetiuk/Projects/scala3/playground/upickle-nullability/Test.scala:2:10
2 |def g = f {
| ^
|This argument was typed using flow assumptions about mutable variables
|but it is passed to a by-name parameter where such flow assumptions are unsound.
|Wrapping the argument in `byName(...)` fixes the problem by disabling the flow assumptions.
|
|`byName` needs to be imported from the `scala.compiletime` package.
3 | mcr1
4 | mcr2
5 |}
1 error found
Expectation
The above is a nullability error. It should not appear since I am not compiling with -Yexplicit-nulls
.