Closed
Description
Compiler version
3.0.0
Minimized code
package bugreport
import scala.compiletime.erasedValue
trait Show[A]:
def show(a: A): String
inline def showTuple[Types]: Show[Types] =
inline erasedValue[Types] match
case _: (head *: tail) =>
val instance =
new Show[head *: tail]:
def show(tuple: head *: tail): String = "dummy"
instance.asInstanceOf[Show[Types]]
@main def run() =
showTuple[(Int, Int)]
Output
[error] -- Error: bugreport.scala:26:11
[error] 26 | showTuple[(Int, Int)]
[error] | ^^^^^^^^^^^^^^^^^^^^^
[error] |object creation impossible, since def show(a: A): String in trait Show in package derivation is not defined
[error] |(Note that
[error] | parameter A in def show(a: A): String in trait Show in package derivation does not match
[error] | parameter (Int, Int) in def show(tuple: (Int, Int)): String in anonymous class Object with derivation.Show[head *: tail] {...}
[error] | )
[error] | This location contains code that was inlined from bugreport.scala:12
Expectation
It compiles.
Note that if I introduce a type alias within the branch and then I always refer to that type alias it works:
package derivation
import scala.compiletime.erasedValue
trait Show[A]:
def show(a: A): String
inline def showTuple[Types]: Show[Types] =
inline erasedValue[Types] match
case _: (head *: tail) =>
type X = head *: tail // Introduce a type alias
val instance =
new Show[X]:
def show(tuple: X): String = "dummy"
instance.asInstanceOf[Show[Types]]
@main def run() =
showTuple[(Int, Int)] // OK