package f
type R
type I >: R
sealed trait F[+R, +A]
object F {
def p[A](x: A): F[Nothing, A] = ???
def r[E : T](e: E): F[R, Nothing] = ???
/* this method is never used, but affects compilation
* the code compiles without it!
*/
def unused[A](f: A): F[I, A] = F.r(1)
}
val _ = (x: F[I, Unit])
p.scala:
package f
val x: F[I, Unit] = F.p(())
T.scala:
package f
import scala.quoted._
class T[X]
object T {
inline given derivedT[X]: T[X] = ${ derivedTImpl[X] }
def derivedTImpl[X](using t: Type[X])(using ctx: Quotes): Expr[T[X]] = {
'{ new T }
}
}
Output
[error] -- [E007] Type Mismatch Error: /home/<redacted>/f.scala:18:9
[error] 18 |val _ = (x: F[I, Unit])
[error] | ^
[error] | Found: (f.x : f.F[f.I, Unit])
[error] | Required: f.F[f.I², Unit]
[error] |
[error] | where: I is a type in package object f$package with bounds >: f.R
[error] | I² is a type in package object f$package with bounds >: f.R
Expectation
Code compiles.
Note that this error appears only on clean; compile - second compile seems to succeed.
Removal of some (seemingly unrelated) code also fixes the issue.
Compiler version
3.1.3
Minimized code
f.scala:
p.scala:
T.scala:
Output
Expectation
Code compiles. Note that this error appears only on clean; compile - second compile seems to succeed. Removal of some (seemingly unrelated) code also fixes the issue.