Skip to content

Commit 83b5d4c

Browse files
committed
Comments explaining some brokenness in Namers.
1 parent b45a91f commit 83b5d4c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ trait Namers extends MethodSynthesis {
161161
else innerNamer
162162
}
163163

164+
// FIXME - this logic needs to be thoroughly explained
165+
// and justified. I know it's wrong with repect to package
166+
// objects, but I think it's also wrong in other ways.
164167
protected def conflict(newS: Symbol, oldS: Symbol) = (
165168
( !oldS.isSourceMethod
166169
|| nme.isSetterName(newS.name)
@@ -188,6 +191,19 @@ trait Namers extends MethodSynthesis {
188191

189192
/** Enter symbol into given scope and return symbol itself */
190193
def enterInScope(sym: Symbol, scope: Scope): Symbol = {
194+
// FIXME - this is broken in a number of ways.
195+
//
196+
// 1) If "sym" allows overloading, that is not itself sufficient to skip
197+
// the check, because "prev.sym" also must allow overloading.
198+
//
199+
// 2) There is nothing which reconciles a package's scope with
200+
// the package object's scope. This is the source of many bugs
201+
// with e.g. defining a case class in a package object. When
202+
// compiling against classes, the class symbol is created in the
203+
// package and in the package object, and the conflict is undetected.
204+
// There is also a non-deterministic outcome for situations like
205+
// an object with the same name as a method in the package object.
206+
191207
// allow for overloaded methods
192208
if (!allowsOverload(sym)) {
193209
val prev = scope.lookupEntry(sym.name)

0 commit comments

Comments
 (0)