Skip to content

Commit 19649d4

Browse files
committed
SI-6576 Workaround / diagnostic for IDE NPE.
Seems like this was too optimistic: > // later by lukas: disabled when fixing SI-5975 > // i think it cannot happen anymore - restored the null check - added logging when we set the namer in this attachment, in the hope of spotting a pattern in the wild. We don't have a test case yet; if we did we could most likely have a more principled fix. But this should suffice for 2.10.1.
1 parent cc89bd7 commit 19649d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ trait Namers extends MethodSynthesis {
908908
// to use. clazz is the ModuleClass. sourceModule works also for classes defined in methods.
909909
val module = clazz.sourceModule
910910
for (cda <- module.attachments.get[ConstructorDefaultsAttachment]) {
911+
debuglog(s"Storing the template namer in the ConstructorDefaultsAttachment of ${module.debugLocationString}.")
911912
cda.companionModuleClassNamer = templateNamer
912913
}
913914
val classTp = ClassInfoType(parents, decls, clazz)
@@ -1229,8 +1230,11 @@ trait Namers extends MethodSynthesis {
12291230
// module's templateNamer to classAndNamerOfModule
12301231
module.attachments.get[ConstructorDefaultsAttachment] match {
12311232
// by martin: the null case can happen in IDE; this is really an ugly hack on top of an ugly hack but it seems to work
1232-
// later by lukas: disabled when fixing SI-5975, i think it cannot happen anymore
1233-
case Some(cda) /*if cma.companionModuleClassNamer == null*/ =>
1233+
case Some(cda) =>
1234+
if (cda.companionModuleClassNamer == null) {
1235+
debugwarn(s"SI-6576 The companion module namer for $meth was unexpectedly null")
1236+
return
1237+
}
12341238
val p = (cda.classWithDefault, cda.companionModuleClassNamer)
12351239
moduleNamer = Some(p)
12361240
p

0 commit comments

Comments
 (0)