Skip to content
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

Companion warning when compilation fails #11864

Open
Jasper-M opened this issue Jan 27, 2020 · 1 comment
Open

Companion warning when compilation fails #11864

Jasper-M opened this issue Jan 27, 2020 · 1 comment
Labels
Milestone

Comments

@Jasper-M
Copy link
Member

@Jasper-M Jasper-M commented Jan 27, 2020

scala> object Foo { private def foo = 0 }
object Foo

scala> class Foo
class Foo
warning: previously defined object Foo is not a companion to class Foo.
Companions must be defined together; you may wish to use :paste mode for this.
scala> object Bar { private def bar = 0 }
object Bar

scala> class Bar { def a = Bar.bar }
                               ^
       error: method bar in object Bar cannot be accessed as a member of object Bar from class Bar

Would be very helpful if you'd also get the warning when compilation of the non-companion fails.
As seen on https://stackoverflow.com/q/59914517/1374461.

@dwijnand dwijnand added the repl label Jan 27, 2020
@som-snytt

This comment has been minimized.

Copy link

@som-snytt som-snytt commented Jan 27, 2020

Currently it lints every successful compilation, and warns even if the other class is buried deep in history.

An improved behavior would be to detect a candidate companion in the previous line and restart the multiline edit. User can then decide to hit enter if that's what they intended, or make corrections.

@lrytz lrytz added this to the Backlog milestone Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.