summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-12-22 09:56:21 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-12-22 09:56:21 +0000
commit192c943c33bf387241e45785073ab14618fbd5fc (patch)
tree63776798edf8ca4a94cede2f1903ada760433954
parentc163877ba88558c9f16393d3518b464c21c61ae5 (diff)
downloadscala-192c943c33bf387241e45785073ab14618fbd5fc.tar.gz
scala-192c943c33bf387241e45785073ab14618fbd5fc.tar.bz2
scala-192c943c33bf387241e45785073ab14618fbd5fc.zip
close #2809.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala4
-rw-r--r--test/files/pos/t2809.scala20
2 files changed, 22 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 4c919f227a..a51797fe25 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -78,7 +78,7 @@ abstract class RefChecks extends InfoTransform {
private def checkDefaultsInOverloaded(clazz: Symbol) {
def check(members: List[Symbol]): Unit = members match {
case x :: xs =>
- if (x.paramss.exists(_.exists(p => p.hasFlag(DEFAULTPARAM)))) {
+ if (x.paramss.exists(_.exists(p => p.hasFlag(DEFAULTPARAM))) && !nme.isProtectedAccessor(x.name)) {
val others = xs.filter(alt => {
alt.name == x.name &&
alt.paramss.exists(_.exists(_.hasFlag(DEFAULTPARAM))) &&
@@ -87,7 +87,7 @@ abstract class RefChecks extends InfoTransform {
if (!others.isEmpty) {
val all = x :: others
val rest = if (all.exists(_.owner != clazz)) ".\nThe members with defaults are defined in "+
- all.map(_.owner).mkString("", " and ", ".")
+ all.map(_.owner).mkString("", " and ", ".") else ""
unit.error(clazz.pos, "in "+ clazz +", multiple overloaded alternatives of "+ x +
" define default arguments"+ rest)
}
diff --git a/test/files/pos/t2809.scala b/test/files/pos/t2809.scala
new file mode 100644
index 0000000000..1f68b0b07a
--- /dev/null
+++ b/test/files/pos/t2809.scala
@@ -0,0 +1,20 @@
+package p1 {
+ abstract class T1 {
+ protected def bug(p: Int = 1): Int // without 'protected' compiles fine
+ }
+}
+package p2 { // all being in the same package compiles fine
+ import p1._
+ abstract class T2 extends T1 {
+ class A {
+ bug()
+ }
+ }
+
+ abstract class T3 extends T2 {
+ class A {
+ bug()
+ }
+ }
+}
+