Skip to content

#1589: add dedicated error message for missing companion for static members #3530

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
Nov 27, 2017

Conversation

esarbe
Copy link
Contributor

@esarbe esarbe commented Nov 22, 2017

No description provided.

checkMessagesAfter("checkStatic") {
"""
|object Foo {
| @annotation.static def bar(): Unit = bar()
Copy link
Contributor

Choose a reason for hiding this comment

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

def bar(): Unit = ()

assertEquals(member.show, "method bar")
}

@Test def notMissingCompanionForStatic =
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remote this test. Here we only test the content of error messages.
We already have tests for correct and incorrect programs: tests/run/statics.scala, tests/neg/static-no-companion.scala

val msg = hl"${member.owner} does not have a companion class"
val kind = "Syntax"
val explanation =
hl"object that contains @static members must have a companion class."
Copy link
Contributor

Choose a reason for hiding this comment

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

hl"Object that contain ${"@static"} members must have a companion class."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I propose a slight change:
hl"An object that contains ${"@static"} members must have a companion class."

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

@esarbe esarbe force-pushed the staticMissesCompanion branch from 8746fdb to f3ffd52 Compare November 23, 2017 19:17
@allanrenucci
Copy link
Contributor

Can you rebase?

@esarbe esarbe force-pushed the staticMissesCompanion branch from f3ffd52 to 46e1aad Compare November 27, 2017 17:53
@esarbe
Copy link
Contributor Author

esarbe commented Nov 27, 2017

Of course.

@allanrenucci allanrenucci merged commit 6ac9d10 into scala:master Nov 27, 2017
@allanrenucci
Copy link
Contributor

Thanks @esarbe!

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