Skip to content

implicit with singleton type works around explicit result type for implicits #3996

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
olafurpg opened this issue Feb 13, 2018 · 2 comments
Closed

Comments

@olafurpg
Copy link
Contributor

object singleton {
  val x = "Hello!"
  implicit val y: x.type = x
  implicitly[String].length
}

I expected the program to be rejected because the type of x is inferred and Dotty requires an explicit result type for implicits.

@Blaisorblade
Copy link
Contributor

Explicit result types are requested for implicits because of potential cycles in inference—the details are here, though I haven't decoded that yet:
scala/bug#8697 (comment)

To triage this one could turn the described issue into problematic code, adapt the problematic code using the above trick, and see what happens. I might get to try this.

@odersky
Copy link
Contributor

odersky commented Feb 18, 2018

No, that one counts as explicit result type.

@odersky odersky closed this as completed Feb 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants