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

incorrect owner printed after failed, overloaded scope lookup #8024

Closed
scabug opened this issue Dec 2, 2013 · 7 comments
Closed

incorrect owner printed after failed, overloaded scope lookup #8024

scabug opened this issue Dec 2, 2013 · 7 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Dec 2, 2013

Regressed in scala/scala#1554

scalac-hash 3d248efcc~1 test.scala
topic/2.11-compat ~/code/spire scalac-hash 3d248efcc test.scala
test.scala:13: error: reference to sqrt is ambiguous;
it is both defined in object FastComplex and imported subsequently by
import java.lang.Math.sqrt
  sqrt(0d)
  ^
one error found
package p

trait NRoot[A]

object `package` {
  final def sqrt(x: Double): Double = Math.sqrt(x)
  final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ???
}

object FastComplex {
  import java.lang.Math.sqrt

  sqrt(0d)
}

As seen in Spire: https://github.com/retronym/spire/tree/topic/2.11-compat

@scabug
Copy link
Author

scabug commented Dec 2, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8024?orig=1
Reporter: @retronym
Affected Versions: 2.11.0-M1

@scabug
Copy link
Author

scabug commented Dec 2, 2013

@retronym said:
/cc, just FYI, to Erik Osheim

@scabug
Copy link
Author

scabug commented Dec 2, 2013

@retronym said:
Actually, this looks like a progression, it is now consistent with a non-overloaded method in a package object and an example with nesting:

// Fails uniformly on 2.10 and 2.11
object Enc {
  def sqrt(x: Double): Double = Math.sqrt(x)
  def sqrt(x: String): Double = Math.sqrt(0)
  object FastComplex {
    import java.lang.Math.sqrt

    sqrt(0d)
  }
}

@scabug
Copy link
Author

scabug commented Dec 2, 2013

@retronym said:
... but at least the error message is wrong: "is both defined in object FastComplex". When I debugged, I saw that the method defined in the package object had somehow become owned by the module class FastComplex!

@scabug
Copy link
Author

scabug commented Dec 2, 2013

@retronym said:
Oh, it was overloaded, and calling OverloadedSymbol#owner isn't such a great idea: one must look at the owners of the alternatives.

@scabug
Copy link
Author

scabug commented Dec 2, 2013

@scabug
Copy link
Author

scabug commented Dec 3, 2013

@retronym said:
scala/scala#3214

@scabug scabug closed this as completed Dec 13, 2013
@scabug scabug added this to the 2.11.0-M8 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants