Skip to content

Change 'overrides nothing' to report via Message (see #1965) #1968

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 2 commits into from
Feb 12, 2017
Merged

Change 'overrides nothing' to report via Message (see #1965) #1968

merged 2 commits into from
Feb 12, 2017

Conversation

ennru
Copy link
Contributor

@ennru ennru commented Feb 11, 2017

'overrides nothing' is now reported as Message as descibed in #1589 (even though it is not listed in that issue.
I took the liberty to split the error into two different messages:

  • overrides nothing - when name doesn't exist
  • method foo has a different signature than the overridden declaration - when the name exists, but is not overriden by the declaration

Please review the explaining texts thoroughly as I'm not really sure what to call things properly.

I noticed SingleDenotation.showDcl creates non-valid code e.g. def foo(i: Int)Unit without the colon. Is there a better way to print declarations in the error messages?

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.

Some nitpicks, but otherwise LGTM :)


assertMessageCount(1, messages)
val OverridesNothing(member) :: Nil = messages
assertEquals("bar", member.name.toString)
Copy link
Contributor

Choose a reason for hiding this comment

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

member.name.toString => member.name.show

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't really matter in this case, but show automatically decodes "weird" names - so let's set a good precedence 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, than I reckon I should use member.name.show in the message and explanation, as well - or does hl do that for me?

Copy link
Contributor

Choose a reason for hiding this comment

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

hl should do that for you

val nonMatching = clazz.info.member(member.name).altsWith(alt => alt.owner != clazz && !alt.is(Final))
def issueError(suffix: String) =
ctx.error(i"$member overrides nothing$suffix", member.pos)
val nonMatching = clazz.info.member(member.name).altsWith(alt => alt.owner != clazz)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just looking at the compressed diff here - so I can't see the reason to cut !alt.is(Final)

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 former error message listed only non-final methods with the same name, but I think it is useful to have even final methods in the "not eligible" list of methods so that one can easily see it as the modifiers are included.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, makes sense :)

// check expected context data
assertEquals("bar", member.name.toString)
assertEquals(3, sameName.size)
assert(sameName.forall(_.symbol.name.toString == "bar"),
Copy link
Contributor

Choose a reason for hiding this comment

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

show

assertMessageCount(1, messages)
val OverridesNothingButNameExists(member, sameName) :: Nil = messages
// check expected context data
assertEquals("bar", member.name.toString)
Copy link
Contributor

Choose a reason for hiding this comment

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

show

@felixmulder
Copy link
Contributor

Regarding showDcl, it should probably be fixed outside of this PR eventually.

@felixmulder felixmulder merged commit 8bdc91f into scala:master Feb 12, 2017
@felixmulder
Copy link
Contributor

Thanks @ennru! 🎉

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.

2 participants