Permalink
Browse files

SI-8024 Fix inaccurate message on overloaded ambiguous ident

`Symbol#owner` of an overloaded symbol doesn't necessarily correspond
to the owner of any of the alternatives, and as such it shouldn't
be used in error message.

neg/t8024.scala actually represents a progression since 2.10.3;
the ambiguity was not reported. I bisected the change to
#1554.
  • Loading branch information...
1 parent a443bae commit e6cee2627555f379ef6cd8cd554a1079a7e074aa @retronym retronym committed Dec 2, 2013
@@ -1108,7 +1108,7 @@ trait Contexts { self: Analyzer =>
impSym = NoSymbol
// Otherwise they are irreconcilably ambiguous
else
- return ambiguousDefnAndImport(defSym.owner, imp1)
+ return ambiguousDefnAndImport(defSym.alternatives.head.owner, imp1)
}
// At this point only one or the other of defSym and impSym might be set.
@@ -1,5 +1,5 @@
t8024.scala:13: error: reference to sqrt is ambiguous;
-it is both defined in object FastComplex and imported subsequently by
+it is both defined in package package and imported subsequently by
import java.lang.Math.sqrt
sqrt(0d)
^
@@ -1,14 +1,14 @@
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)
}
@@ -0,0 +1,6 @@
+t8024b.scala:15: 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
@@ -0,0 +1,17 @@
+package p
+
+trait NRoot[A]
+
+object FastComplex {
+ final def sqrt(x: Double): Double = Math.sqrt(x)
+ final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ???
+
+ object Inner {
+ import java.lang.Math.sqrt
+
+ // wrong message:
+ // error: reference to sqrt is ambiguous;
+ // it is both defined in object FastComplex and imported subsequently by
+ sqrt(0d)
+ }
+}

1 comment on commit e6cee26

Job pr-scala failed for e6cee26 Took 155 min. (ping @retronym) (results):


To retry exactly this commit, comment "PLS REBUILD/pr-scala@e6cee2627555f379ef6cd8cd554a1079a7e074aa" on PR 3214.
NOTE: New commits are rebuilt automatically as they appear. A forced rebuild is only necessary for transient failures.

Please sign in to comment.