Skip to content

Commit 27ab7ae

Browse files
committed
More comments and drop debug statement
1 parent 2256ca5 commit 27ab7ae

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Namer.scala

+10-7
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ class Namer { typer: Typer =>
302302

303303
typr.println(i"creating symbol for $tree in ${ctx.mode}")
304304

305+
/** Check that a new definition with given name and privacy status
306+
* in current context would not conflict with existing currently
307+
* compiled definitions.
308+
* The logic here is very subtle and fragile due to the fact that
309+
* we are not allowed to force anything.
310+
*/
305311
def checkNoConflict(name: Name, isPrivate: Boolean): Name =
306312
val owner = ctx.owner
307313
var conflictsDetected = false
@@ -314,24 +320,21 @@ class Namer { typer: Typer =>
314320
ctx.error(i"$name is already defined as $conflicting$where", tree.sourcePos)
315321
conflictsDetected = true
316322

317-
def checkNoConflictWith(preExisting: Symbol) =
323+
def checkNoConflictIn(preExisting: Symbol) =
324+
val preExisting = owner.unforcedDecls.lookup(name)
318325
if (preExisting.isDefinedInCurrentRun || preExisting.lastKnownDenotation.is(Package))
319326
&& (!preExisting.lastKnownDenotation.is(Private) || preExisting.owner.is(Package))
320327
then conflict(preExisting)
321328

322-
def checkNoConflictIn(owner: Symbol) =
323-
checkNoConflictWith( owner.unforcedDecls.lookup(name))
324-
325329
def pkgObjs(pkg: Symbol) =
326330
pkg.denot.asInstanceOf[PackageClassDenotation].packageObjs.map(_.symbol)
327331

328-
def preExisting = ctx.effectiveScope.lookup(name)
329332
if owner.is(PackageClass) then
330-
checkNoConflictWith(preExisting)
331-
return name
333+
checkNoConflictIn(owner)
332334
for pkgObj <- pkgObjs(owner) do
333335
checkNoConflictIn(pkgObj)
334336
else
337+
def preExisting = ctx.effectiveScope.lookup(name)
335338
if (!owner.isClass || name.isTypeName) && preExisting.exists then
336339
conflict(preExisting)
337340
else if owner.isPackageObject && !isPrivate && name != nme.CONSTRUCTOR then

0 commit comments

Comments
 (0)