Skip to content

Commit ae69de4

Browse files
committed
SI-7335 Add logging for a now-impossible* case in Symbol#exists.
* Impossible (to the best of my knowledge) because LowPriorityImplicits is now defined in Predef.scala. Were I more sure, we could trip an assertion here, rather than the devWarning.
1 parent 9d7f811 commit ae69de4

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,23 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
887887
supersym == NoSymbol || supersym.isIncompleteIn(base)
888888
}
889889

890-
// Does not always work if the rawInfo is a SourcefileLoader, see comment
891-
// in "def coreClassesFirst" in Global.
892-
def exists = !isTopLevel || { rawInfo.load(this); rawInfo != NoType }
890+
def exists: Boolean = !isTopLevel || {
891+
val isSourceLoader = rawInfo match {
892+
case sl: SymLoader => sl.fromSource
893+
case _ => false
894+
}
895+
def warnIfSourceLoader() {
896+
if (isSourceLoader)
897+
// Predef is completed early due to its autoimport; we used to get here when type checking its
898+
// parent LowPriorityImplicits. See comment in c5441dc for more elaboration.
899+
// Since the fix for SI-7335 Predef parents must be defined in Predef.scala, and we should not
900+
// get here anymore.
901+
devWarning(s"calling Symbol#exists with sourcefile based symbol loader may give incorrect results.");
902+
}
903+
904+
rawInfo load this
905+
rawInfo != NoType || { warnIfSourceLoader(); false }
906+
}
893907

894908
final def isInitialized: Boolean =
895909
validTo != NoPeriod

0 commit comments

Comments
 (0)