Closed
Description
Compiler version
3.3.0-RC5
Minimized code
https://scastie.scala-lang.org/2FKUlvnQTQaY6iZceg9tug
trait TC[T]
object TC {
def optionTCForPart[T](implicit tc: TC[ExtractPart[T]]): TC[Option[ExtractPart[T]]] = new TC[Option[ExtractPart[T]]] {}
}
type ExtractPart[T] = T match {
case PartField[t] => t
}
type PartField[T] = Any { type Part = T }
class ValuePartHolder {
type Part = Value
}
class Value
object Value {
implicit val tcValue: TC[Value] = new {}
}
@main def main(): Unit = {
// import Value.tcValue // explicit import works around the issue, but shouldn't be necessary
val tc = TC.optionTCForPart[ValuePartHolder]
println(tc)
}
Output
val tc = TC.optionTCForPart[ValuePartHolder]
^
No given instance of type TC[ExtractPart[ValuePartHolder]]
was found for parameter tc of method optionTCForPart in object TC
The following import might fix the problem:
import Value.tcValue
Expectation
Expected to work, since ExtractPart[ValuePartHolder]]
evaluates to Value
and Value
companion object already contains the instance, making explicit import redundant.