Closed
Description
Minimized code
import scala.language.dynamics
object Dyn extends Dynamic:
def selectDynamic[T](name: String): Option[T] = None
val a: Option[(Int, Int)] = Dyn.asdf[Tuple2[Int, Int]] // works fine
val b: Option[(Int, Int)] = Dyn.selectDynamic[(Int, Int)]("asdf") // works fine
val c: Option[(Int, Int)] = Dyn.asdf[(Int, Int)] // fails
Output
scala> import scala.language.dynamics
scala> object Dyn extends Dynamic:
| def selectDynamic[T](name: String): Option[T] = None
|
// defined object Dyn
scala> val a: Option[(Int, Int)] = Dyn.asdf[Tuple2[Int, Int]] // works fine
val a: Option[(Int, Int)] = None
scala> val b: Option[(Int, Int)] = Dyn.selectDynamic[(Int, Int)]("asdf") // works fine
val b: Option[(Int, Int)] = None
scala> val c: Option[(Int, Int)] = Dyn.asdf[(Int, Int)] // fails
1 |val c: Option[(Int, Int)] = Dyn.asdf[(Int, Int)] // fails
| ^
|cannot infer type; expected type class dotty.tools.dotc.typer.ProtoTypes$AnyTypeConstructorProto$ is not fully defined
Expectation
the last line val a: Option[(Int, Int)] = Dyn.asdf[(Int, Int)]
should return None
rather than report an error. Running this in a scala 2.13.4 repl outputs the expected results.