Skip to content

Change backend name handling #2322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ object Names {
else {
if (Config.checkBackendNames) {
if (!toStringOK) {
// We print the stacktrace instead of doing an assert directly,
// because asserts are caught in exception handlers which might
// cause other failures. In that case the first, important failure
// is lost.
println("Backend should not call Name#toString, Name#mangledString should be used instead.")
Copy link
Member

@smarter smarter Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Console.err.println (or System.err.println) instead. printStackTrace will print on stderr, and if you use println right before it which prints on stdout, the output might get mixed.

new Error().printStackTrace()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicer way: Thread.dumpStack()

assert(false)
Expand All @@ -301,6 +305,9 @@ object Names {
new String(chrs, start, length)
}

/** It's OK to take a toString if the stacktrace does not occur a method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "a method" -> "in a method"
And on the line below: "or it also" -> "or if it also"

* in GenBCode or it also contains one of the whitelisted methods below.
*/
private def toStringOK = {
val trace = Thread.currentThread.getStackTrace
!trace.exists(_.getClassName.endsWith("GenBCode")) ||
Expand Down