Skip to content

Fix #1169: Fix strange type formatting in error message #3927

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 1 commit into from
Jan 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Bridges.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ class Bridges(root: ClassSymbol)(implicit ctx: Context) {
bridgesScope.lookupAll(member.name).exists(bridge =>
bridgeTarget(bridge) == member && bridge.signature == other.signature)
def info(sym: Symbol)(implicit ctx: Context) = sym.info
def desc(sym: Symbol)= i"$sym${info(sym)(preErasureCtx)} in ${sym.owner}"
def desc(sym: Symbol)= {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:

val infoStr = sym.showDcl(preErasureCtx)
i"$infoStr in ${sym.owner}"

This will print def produce: => X. But I think we could configure the printer to not print the =>. Other part of the compiler (such as error messages) could benefit from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that printing the type will always print the =>. Otherwise it would be confusing. I would should work on the Printer but it has to look at the larger context to do the right thing.

val infoStr = info(sym)(preErasureCtx) match {
case ExprType(info) => i": $info"
case info => info.show
}
i"$sym$infoStr in ${sym.owner}"
}
if (member.signature == other.signature) {
if (!member.info.matches(other.info))
ctx.error(em"""bridge generated for member ${desc(member)}
Expand Down
9 changes: 9 additions & 0 deletions tests/neg/i1169.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class X(val underlying: Object) extends AnyVal

trait Producer[T] {
def produce: T
}

class XProducer extends Producer[X] {
def produce = new X(null) // error
}