Skip to content

Commit c3cc84f

Browse files
committed
Document name checking
1 parent d7eea41 commit c3cc84f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ object Names {
293293
else {
294294
if (Config.checkBackendNames) {
295295
if (!toStringOK) {
296+
// We print the stacktrace instead of doing an assert directly,
297+
// because asserts are caught in exception handlers which might
298+
// cause other failures. In that case the first, important failure
299+
// is lost.
296300
println("Backend should not call Name#toString, Name#mangledString should be used instead.")
297301
new Error().printStackTrace()
298302
assert(false)
@@ -301,6 +305,9 @@ object Names {
301305
new String(chrs, start, length)
302306
}
303307

308+
/** It's OK to take a toString if the stacktrace does not occur a method
309+
* in GenBCode or it also contains one of the whitelisted methods below.
310+
*/
304311
private def toStringOK = {
305312
val trace = Thread.currentThread.getStackTrace
306313
!trace.exists(_.getClassName.endsWith("GenBCode")) ||

0 commit comments

Comments
 (0)