Skip to content

Error when using tuple type with selectDynamic method syntax #10951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
albertpchen opened this issue Dec 29, 2020 · 0 comments · Fixed by #10952
Closed

Error when using tuple type with selectDynamic method syntax #10951

albertpchen opened this issue Dec 29, 2020 · 0 comments · Fixed by #10952
Milestone

Comments

@albertpchen
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants