Skip to content

Moved Ambiguous Overload error in Typer to case class #2354

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 4 commits into from
May 12, 2017

Conversation

ennru
Copy link
Contributor

@ennru ennru commented May 2, 2017

@felixmulder Couldn't decide on best solution how typer.ErrorReporting.Errors methods should be used from error case class. There are more errors to move that will need it.

s"""|There are ${alts.length} methods that could be referenced as the compiler knows too little about the expected type.
|You may specify the expected type e.g. by
|- assigning it to a value with a specified type, or
|- adding a type ascription as in (MyClass.myMethod: String => Int)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the type ascription example should be myObject.myMethod: String => Int

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thank you. Preferrable I'd show the method in question, but as far as I know there is no easy way right now to print out the type with =>-syntax.

Copy link
Contributor

@felixmulder felixmulder left a comment

Choose a reason for hiding this comment

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

It looks like most of the functionality from ErrorReporting could be consolidated with the messages or at least moved to the reporting package. Not sure we should do this at this juncture - but if there are more tests that require Errors then perhaps it would be better to give it an apt name and put it in the reporting package.

Perhaps @odersky has some further opinions? It's his code after all 😄

Other than the comments in this review LGTM

s"""|There are ${alts.length} methods that could be referenced as the compiler knows too little about the expected type.
|You may specify the expected type e.g. by
|- assigning it to a value with a specified type, or
|- adding a type ascription as in `(instance.myMethod: String => Int)`
Copy link
Contributor

Choose a reason for hiding this comment

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

Highlight the code example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any sight of supporting a type.show-variant with notation as in source code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Types are Showable in Dotty as long as you have an implicit Context in scope, you can do tpe.show. If that's not what you meant, then please elaborate :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tpe.show gives (s: String)Int, but I'd like to get (String) => Int for better cut-and-paste fidelity.

override def kind: String = "Reference"

override def explanation: String =
s"""|There are ${alts.length} methods that could be referenced as the compiler knows too little about the expected type.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is > 100 columns. Eventually, maybe we should have the hl interpolator wrap the lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hl will need to start wrapping at some stage as we put in dynamic amount of text. I will wrap this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you're completely right. There are some cases where we don't want it to wrap. For instance on lines beginning with -, +, *, , and so on... maybe we could just principle it on wrapping over 80 characters until it hits two newlines or one of the disallowed symbols. It would also need to take into account ANSI escape codes for the colors.


private def all = if (alts.length == 2) "both" else "all"

override def msg: String =
Copy link
Contributor

Choose a reason for hiding this comment

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

These shouldn't be override, I'm guessing you looked at the one above and just assumed that we write it like this now. Could you change both? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Started off from the wrong example. Will fix.

@felixmulder
Copy link
Contributor

PS - commit messages should be in the imperative form. E.g. "Add X" over "Added X"

@felixmulder
Copy link
Contributor

LGTM, but needs a rebase

@ennru ennru force-pushed the ennru_AmbiguousOverload branch from 1a6cf58 to 458ee55 Compare May 9, 2017 06:02
@felixmulder felixmulder merged commit 1c1b78f into scala:master May 12, 2017
@ennru ennru deleted the ennru_AmbiguousOverload branch May 12, 2017 09:33
@ShaneDelmore
Copy link
Contributor

@felixmulder
Copy link
Contributor

felixmulder commented May 17, 2017

@ShaneDelmore - it should be the imperative mood, e.g "add" over "added" :)

So the examples are swapped - would you mind unswapping? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants