Skip to content

Commit 15732b1

Browse files
committed
added debug information for naming crash
1 parent 9f63495 commit 15732b1

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,8 @@ trait Checking {
11081108
then
11091109
val conflicting = effectiveOwner.info.member(sym.name.toTypeName).symbol
11101110
if conflicting.exists then
1111+
println(s"checkNoModuleClash: sym: ${sym.fullName}, effectiveOwner=${effectiveOwner.className}")
1112+
Thread.dumpStack()
11111113
report.error(AlreadyDefined(sym.name, effectiveOwner, conflicting), sym.srcPos)
11121114

11131115
/** Check that `tp` is a class type.

compiler/src/dotty/tools/dotc/typer/Namer.scala

+6-2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class Namer { typer: Typer =>
142142
val other =
143143
if conflicting.is(ConstructorProxy) then conflicting.companionClass
144144
else conflicting
145+
Thread.dumpStack()
145146
report.error(AlreadyDefined(name, owner, other), ctx.source.atSpan(span))
146147
conflictsDetected = true
147148

@@ -150,13 +151,16 @@ class Namer { typer: Typer =>
150151
if (preExisting.isDefinedInCurrentRun || preExisting.lastKnownDenotation.is(Package))
151152
&& (!preExisting.lastKnownDenotation.is(Private) || preExisting.owner.is(Package))
152153
&& (!preExisting.lastKnownDenotation.isPackageObject
153-
|| preExisting.associatedFile != ctx.source.file)
154+
|| preExisting.associatedFile != ctx.source.file && preExisting.associatedFile != null)
154155
// isDefinedInCurrentRun does not work correctly for package objects, because
155156
// package objects are updated to the new run earlier than normal classes, everytime
156157
// some member of the enclosing package is accessed. Therefore, we use another
157158
// test: conflict if package objects have the same name but come from different
158159
// sources. See i9252.
159-
then conflict(preExisting)
160+
then
161+
println(s"preExisting.associatedFile = ${preExisting.associatedFile}")
162+
println(s"ctx.source.file = ${ctx.source.file}")
163+
conflict(preExisting)
160164

161165
def pkgObjs(pkg: Symbol) =
162166
pkg.denot.asInstanceOf[PackageClassDenotation].packageObjs.map(_.symbol)

compiler/src/dotty/tools/dotc/typer/Typer.scala

+1
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
33593359
}
33603360
case _ =>
33613361
// Package will not exist if a duplicate type has already been entered, see `tests/neg/1708.scala`
3362+
Thread.dumpStack()
33623363
errorTree(tree,
33633364
if pkg.exists then PackageNameAlreadyDefined(pkg)
33643365
else em"package ${tree.pid.name} does not exist")

0 commit comments

Comments
 (0)