Skip to content
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

Implicit *object* not found if it occurs later in same file #9674

Closed
scabug opened this issue Feb 24, 2016 · 3 comments
Closed

Implicit *object* not found if it occurs later in same file #9674

scabug opened this issue Feb 24, 2016 · 3 comments

Comments

@scabug
Copy link

scabug commented Feb 24, 2016

Similar to #1209, #1814 and #801, except the workaround of specifying the return type of the method doesn't work because it's an implicit object, not an implicit method.

case class MyClass()

object BugReport {
  implicitly[Ordering[MyClass]] // error: No implicit Ordering defined for MyClass.
}

// if this module is moved above BugReport, the compilation error disappears
object MyClass {
  implicit object MyOrdering extends Ordering[MyClass] {
    def compare(x: MyClass, y: MyClass) = ???
  }
}
@scabug
Copy link
Author

scabug commented Feb 24, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9674?orig=1
Reporter: Samuel Gélineau (gelisam)
Affected Versions: 2.11.7
See #8697, #1209, #1814, #801, #5265

@scabug
Copy link
Author

scabug commented Feb 24, 2016

Samuel Gélineau (gelisam) said:
This issue relates to #5265, which tackles the problem of order-relevant implicits by displaying a warning whenever an implicit def doesn't specify its return type. This works for implicit defs, however as my example demonstrates, there are other cases in which the order-relevance of implicits leads to hard-to-fix error messages, and the suggested warning wouldn't cover those cases.

@scabug
Copy link
Author

scabug commented Mar 15, 2016

@paulp said:
This is a duplicate of #8697 (and not the first.)

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

No branches or pull requests

1 participant