Closed
Description
Compiler version
3.1.0
Minimized code
FirstName.scala
opaque type FirstName = String
object FirstName {
def apply(s: String): FirstName = s
}
FullName.scala
opaque type FullName = String
object FullName {
def apply(s: String): FullName = s
given Conversion[FullName, FirstName] with {
def apply(fullName: FullName): FirstName = fullName.split(" ")(0)
}
}
Main.scala
object Main extends App {
def printFirstName(f: FirstName): Unit = {
println(f)
}
val fn = FullName("Johnny Test")
printFirstName(fn)
}
Output
Inifinite Loop / Hang
Expectation
Should not compile as the Conversion given should not know that String =:= FirstName