Skip to content

implicit search fails to find implicit object depending on declaration order #11260

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
smarter opened this issue Nov 16, 2018 · 3 comments
Closed
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) implicit typer

Comments

@smarter
Copy link
Member

smarter commented Nov 16, 2018

This compiles:

class Foo
object Foo {
  implicit object myImplicit extends Foo
}

class Bar {
  def needsImplicit()(implicit a: Foo) = { }
  
  def boom = {
    needsImplicit()
  }
}

... but this doesn't:

class Bar {
  def needsImplicit()(implicit a: Foo) = { }
  
  def boom = {
    needsImplicit()  // error: could not find implicit value for parameter a: Foo
  }
}

class Foo
object Foo {
  implicit object myImplicit extends Foo
}

(both compile with Dotty)

@smarter smarter added typer implicit fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) labels Nov 16, 2018
@virusdave
Copy link

Scastie example - uncommenting the seemingly useless statement makes implicit search work:
https://scastie.scala-lang.org/SS8Rb5YZSjKVOMl4ygINiQ

@som-snytt
Copy link

Duplicates #8697

@smarter
Copy link
Member Author

smarter commented Nov 17, 2018

Indeed, closing then

@smarter smarter closed this as completed Nov 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) implicit typer
Projects
None yet
Development

No branches or pull requests

3 participants