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

Move State companion to the package object #322

Merged
merged 3 commits into from
Jun 5, 2015

Conversation

eed3si9n
Copy link
Contributor

As it stands, State causes strange behaviors like State.apply working
the first time, but failing the second time to find apply. See https://gist.github.com/eed3si9n/9804d496bfeb457282c2
@retronym pointed me to SI-7139, which says that the REPL gets
confused about the type when there's a type alias and an object named
the same.

This adds the workaround posted on SI-7139, which is to move the name State into package object.

@non
Copy link
Contributor

non commented May 24, 2015

So just to be clear, people can still reference it as State due to the val you've defined in the package object right? So this is just a hidden kludge?

@eed3si9n
Copy link
Contributor Author

Yes and yes. The value alias in the package object allows us to use the name State.

@non
Copy link
Contributor

non commented May 24, 2015

👍 thanks!

@retronym
Copy link

An alternative would be:

package object state {
  type State = ...
  object State extends StateCompanion
}

// State.scala
class StateCompanion { ... }

That way, the ugly name State0 won't leak out in error messages, etc.

As it stands, `State` causes strange behaviors like State.apply working
the first time, but failing the second time to find apply.
@retronym pointed to me to SI-7139, which says that the REPL gets
confused about the type when there's a type alias and an object named
the same.

This adds the workaround to SI-7139 by moving State companion into the
package object.
@eed3si9n eed3si9n force-pushed the topic/state-repl-workaround branch from 37bf89a to 091f1ba Compare May 24, 2015 05:26
@eed3si9n
Copy link
Contributor Author

Pushed in a new commit with the class StateCompanion idea.

@eed3si9n eed3si9n changed the title Rename State companion to State0 Move State companion to the package object May 24, 2015
@eed3si9n
Copy link
Contributor Author

I just ran into the same issue with object Trampoline, so added a new commit.

@ceedubs
Copy link
Contributor

ceedubs commented Jun 2, 2015

👍

I had done something very similar in a follow-up State branch that it looks like I never turned into a PR. I'll try to come back to that soon.

stew added a commit that referenced this pull request Jun 5, 2015
Move State companion to the package object
@stew stew merged commit cb9a89e into typelevel:master Jun 5, 2015
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.

5 participants