Skip to content

Commit

Permalink
Improved fix for SI-1987, overloading in package objects.
Browse files Browse the repository at this point in the history
When reformulating an errant package object overload,
don't forget to fully qualify it lest you trade one error
for another.
  • Loading branch information
paulp committed Aug 22, 2012
1 parent 6e344bc commit fcf2b29
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -4730,8 +4730,13 @@ trait Typers extends Modes with Adaptations with Tags {
if (isInPackageObject(defEntry.sym, pre.typeSymbol)) {
defSym = pre.member(defEntry.sym.name)
if (defSym ne defEntry.sym) {
log("!!! Overloaded package object member resolved incorrectly.\n Discarded: " +
defEntry.sym.defString + "\n Using: " + defSym.defString)
qual = gen.mkAttributedQualifier(pre)
log(s"""
| !!! Overloaded package object member resolved incorrectly.
| prefix: $pre
| Discarded: ${defEntry.sym.defString}
| Using: ${defSym.defString}
""".stripMargin)
}
}
else
Expand Down
1 change: 1 addition & 0 deletions test/files/run/t1987b.check
@@ -0,0 +1 @@
ok!
17 changes: 17 additions & 0 deletions test/files/run/t1987b/PullIteratees.scala
@@ -0,0 +1,17 @@
package scales.xml

trait PullType
class QName
trait RetUrn[T]

/**
* Iteratees related to pull parsing
*/
trait PullIteratees {
/**
* Without the overload it doesn't trigger the CCE, even though its
* not used
*/
def iterate(path: List[QName], xml: String): RetUrn[String] = null
def iterate(path: List[QName], xml: Iterator[PullType]): RetUrn[String] = null
}
6 changes: 6 additions & 0 deletions test/files/run/t1987b/a.scala
@@ -0,0 +1,6 @@
object Test {
def main(args: Array[String]): Unit = {
scales.xml.CCE_Test.main(args)
println("ok!")
}
}
15 changes: 15 additions & 0 deletions test/files/run/t1987b/cce_test.scala
@@ -0,0 +1,15 @@
package scales.xml
//import scales.xml._ // using another pacakge and importing doesn't CCE

object CCE_Test {
def main(args: Array[String]): Unit = {
// without the import it doesn't trigger the CCE
import scaley.funny._

val pull = null.asInstanceOf[Iterator[PullType]]
val LogEntries = null.asInstanceOf[List[QName]]
// fully qualify with scales.xml. and it won't trigger it
iterate(LogEntries,
pull)
}
}
4 changes: 4 additions & 0 deletions test/files/run/t1987b/pkg1.scala
@@ -0,0 +1,4 @@
package scaley

package object funny {
}
3 changes: 3 additions & 0 deletions test/files/run/t1987b/pkg2.scala
@@ -0,0 +1,3 @@
package scales

package object xml extends PullIteratees

0 comments on commit fcf2b29

Please sign in to comment.