From 192c943c33bf387241e45785073ab14618fbd5fc Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 22 Dec 2009 09:56:21 +0000 Subject: close #2809. --- .../scala/tools/nsc/typechecker/RefChecks.scala | 4 ++-- test/files/pos/t2809.scala | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/files/pos/t2809.scala 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() + } + } +} + -- cgit v1.2.3