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

SI-5954 Adds implementation restriction preventing companions in package... #1882

Merged
merged 1 commit into from Jan 14, 2013

Conversation

JamesIry
Copy link
Contributor

... objects

Companion objects (and thus also case classes) in package objects caused an
assert about an overloaded symbol when everything was compiled twice. It's a
hairy problem that doesn't fit in 2.10.1. So this fix adds an implementation
restriction. It also has a test to make sure the error messages are clean
and reasonably friendly, and the test includes a commented out test in case
somebody thinks they've solved the underlying problem.

@review gkossakowski

@retronym
Copy link
Member

Wouldn't the test be more straightforward as neg test?

@scala-jenkins
Copy link

Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1350/

@scala-jenkins
Copy link

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2065/

@scala-jenkins
Copy link

jenkins job pr-rangepos: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1350/

@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2065/

@JamesIry
Copy link
Contributor Author

@retronym Yup, didn't realize we had such things.

@JamesIry
Copy link
Contributor Author

Re-submitted as a single commit, with simpler test in neg.

@JamesIry
Copy link
Contributor Author

Oh, hey, the kitteh woke up and puked on my pr. (sigh)

@JamesIry
Copy link
Contributor Author

PLS REBUILD ALL

@scala-jenkins
Copy link

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2070/

@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2070/

@scala-jenkins
Copy link

Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1356/

@scala-jenkins
Copy link

jenkins job pr-rangepos: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1356/

@JamesIry
Copy link
Contributor Author

_< Builds clean on my box, but the kitteh don't lie, adding a value class to the test trips it up.

@JamesIry
Copy link
Contributor Author

PLS REBUILD ALL

@scala-jenkins
Copy link

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2071/

@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2071/

@scala-jenkins
Copy link

Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1357/

@scala-jenkins
Copy link

jenkins job pr-rangepos: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1357/

@JamesIry
Copy link
Contributor Author

Looking at the tests that are failing, some are tests that were for bugs that duplicate this one except that the tests fail to actually test the problem. But other tests are for other tangential issues. They just happen to also fall afoul of the re-compile problem that this restriction is preventing.

So my proposal is to add a compiler switch that disables the restriction being added in this PR and modify some of the failing tests to use that flag. That way we don't lose valuable tests that exercise functionality that will one-day actually be useful when the re-compile problem is solved.

How say you @retronym, @paulp, @adriaanm, @gkossakowski ?

@retronym
Copy link
Member

Sounds like a reasonable stepping stone to this musketeer, so long as we leave a ticket open.

@JamesIry
Copy link
Contributor Author

PLS REBUILD ALL

@scala-jenkins
Copy link

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2075/

@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2075/

@scala-jenkins
Copy link

Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1362/

@scala-jenkins
Copy link

jenkins job pr-rangepos: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1362/

@@ -0,0 +1,16 @@
t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. class D should be placed directly in package A instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't ${m} after .(dot) be capitalized?

  ...package object A cannot contain case class D. Class D should ...

@JamesIry
Copy link
Contributor Author

Hmm, this desperately needs squashing.

Companion objects (and thus also case classes) in package objects caused
an assert about an overloaded symbol when everything was compiled twice.
It's a hairy problem that doesn't fit in 2.10.1. So this fix adds an
implementation restriction. It also has a test to make sure the error
messages are clean and reasonably friendly, and does not catch other
things defined in package objects. The test includes a
commented out test in case somebody thinks they've solved the underlying
problem.

A handful of tests were falling afoul of the new implementation
restriction. I verified that they do in fact fail on second compile so
they aren't false casualties. But they do test real things we'd like
to work once the re-compile issue is fixed. So I added a -X flag to
disable the implementation restriction and made all the tests
accidentally clobbered by the restriction use that flag.
@scala-jenkins
Copy link

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2086/

@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2086/

@scala-jenkins
Copy link

Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1373/

@scala-jenkins
Copy link

jenkins job pr-rangepos: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1373/

@JamesIry
Copy link
Contributor Author

@retronym lets get this puppy put to bed

@retronym
Copy link
Member

🐶 Lucky! Go To Mattress!

@adriaanm
Copy link
Contributor

:squirrel:! (clarification: http://www.youtube.com/watch?v=bBWrMQVsuak)

adriaanm added a commit that referenced this pull request Jan 14, 2013
SI-5954 Adds implementation restriction preventing companions in package...
@adriaanm adriaanm merged commit 00914fc into scala:2.10.x Jan 14, 2013
@gkossakowski
Copy link
Member

@JamesIry Apparently I was too slow to provide useful feedback. I'm not a big fan of introducing more compiler options but your balance seems to be around 0 so far so this is fine.

Also, thanks for following style of other implementation restrictions and for providing very good comments in the code. This is an example of how we should roll in scala/scala.

Also, https://issues.scala-lang.org/browse/SI-6109 is still open if you have apetite for something bigger :-)

@JamesIry
Copy link
Contributor Author

I'm leaving the associated bug open because this implementation restriction is pretty arbitrary from a user point of view and it would be nice to solve the underlying problem.

adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 2, 2013
We want 2.10.1 to be a drop-in replacement for 2.10.0,
so we can't start warning where we weren't warning in 2.10.0.

See SI-5954 (scala#1882, scala#2079) for when it was an implementation restriction,
which was then weakened to a warning. It's now hidden behind -Ydebug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants