Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 3b6b2bf

Browse files
committed
[backport] SI-9392 Clarify the workaround comment and introduce a devWarning
1 parent 091c1e6 commit 3b6b2bf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,15 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
351351
val isTopLevel = innerClassSym.rawowner.isPackageClass
352352
// impl classes are considered top-level, see comment in BTypes
353353
if (isTopLevel || considerAsTopLevelImplementationArtifact(innerClassSym)) None
354-
else if (innerClassSym.rawowner.isTerm)
355-
// SI-9392 An errant macro might leave a reference to a local class symbol that no longer exists in the tree,
356-
// this avoids an assertion error in that case. AFAICT, we don't actually need the `NestedInfo` for all BTypes,
357-
// only for ones that describe classes defined in the trees that reach the backend, so this is safe enough.
358-
//
359-
// TODO Can we avoid creating `NestedInfo` for each type that is referred to, and instead only create if for
360-
// symbols of ClassDefs?
354+
else if (innerClassSym.rawowner.isTerm) {
355+
// This case should never be reached: the lambdalift phase mutates the rawowner field of all
356+
// classes to be the enclosing class. SI-9392 shows an errant macro that leaves a reference
357+
// to a local class symbol that no longer exists, which is not updated by lambdalift.
358+
devWarning(innerClassSym.pos,
359+
s"""The class symbol $innerClassSym with the term symbol ${innerClassSym.rawowner} as `rawowner` reached the backend.
360+
|Most likely this indicates a stale reference to a non-existing class introduced by a macro, see SI-9392.""".stripMargin)
361361
None
362-
else {
362+
} else {
363363
// See comment in BTypes, when is a class marked static in the InnerClass table.
364364
val isStaticNestedClass = isOriginallyStaticOwner(innerClassSym.originalOwner)
365365

0 commit comments

Comments
 (0)