summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-23 17:51:43 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-09-23 17:51:43 +0200
commitd882ec053c9a70d29e668bc80bb3f1aa830c0281 (patch)
treec3b1a54b4291c4f5f7f23b3542cd63f6be9bb780 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent65817bd2b71f5ea0e39af1b1c2b085562cd8e925 (diff)
downloadscala-d882ec053c9a70d29e668bc80bb3f1aa830c0281.tar.gz
scala-d882ec053c9a70d29e668bc80bb3f1aa830c0281.tar.bz2
scala-d882ec053c9a70d29e668bc80bb3f1aa830c0281.zip
SI-7870 Detect default getter clashes in constructors
Default getters for constructors live in the companion module. These eluded the check for clashes in default getter names due to overloading, which aims to give a more user friendly error than "double definition: meth$default$1". This commit checks for default getters in the companion module, in addition to those in the template itself.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 32e908e03b..61759a9f00 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -121,13 +121,13 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
var checkedCombinations = Set[List[Type]]()
// only one overloaded alternative is allowed to define default arguments
- private def checkOverloadedRestrictions(clazz: Symbol): Unit = {
+ private def checkOverloadedRestrictions(clazz: Symbol, defaultClass: Symbol): Unit = {
// Using the default getters (such as methodName$default$1) as a cheap way of
// finding methods with default parameters. This way, we can limit the members to
// those with the DEFAULTPARAM flag, and infer the methods. Looking for the methods
// directly requires inspecting the parameter list of every one. That modification
// shaved 95% off the time spent in this method.
- val defaultGetters = clazz.info.findMembers(0L, DEFAULTPARAM)
+ val defaultGetters = defaultClass.info.findMembers(0L, DEFAULTPARAM)
val defaultMethodNames = defaultGetters map (sym => nme.defaultGetterToMethod(sym.name))
defaultMethodNames.toList.distinct foreach { name =>
@@ -1638,7 +1638,9 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Template(parents, self, body) =>
localTyper = localTyper.atOwner(tree, currentOwner)
validateBaseTypes(currentOwner)
- checkOverloadedRestrictions(currentOwner)
+ checkOverloadedRestrictions(currentOwner, currentOwner)
+ // SI-7870 default getters for constructors live in the companion module
+ checkOverloadedRestrictions(currentOwner, currentOwner.companionModule)
val bridges = addVarargBridges(currentOwner)
checkAllOverrides(currentOwner)
checkAnyValSubclass(currentOwner)