-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[SUPERSEDED] Unit companion is disallowed #6490
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
Conversation
| } | ||
| // See an explanation of compileTimeOnly in its scaladoc at scala.annotation.compileTimeOnly. | ||
| if (sym.isCompileTimeOnly && !currentOwner.ownerChain.exists(x => x.isCompileTimeOnly)) { | ||
| if (sym.isCompileTimeOnly && !inAnnotation && sym != SpecializedClass && !currentOwner.ownerChain.exists(x => x.isCompileTimeOnly)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add a @compileTimeOnly to specialized only to exclude it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just got the email for your comment on the other PR. Maybe throw types to the wind and say
lazy val SpecializedClass = getRequiredClass("scala.specialized")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, with a comment. that sounds better than the special case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, what comment on the other PR? Which other PR? What is this PR about again?
| override def getClass(): Class[Unit] = ??? | ||
| } | ||
|
|
||
| @scala.annotation.compileTimeOnly("not for use in source code. The unit value is written '()'.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what the best way to quote this is. I can imagine someone writing '()' and becoming confused. Maybe "Use () for the value of type Unit".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We went down that path on the other PR. It sounds like "Write 'Unit()'."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone who is going to read this is already confused about the term and type name of Unit. "not for use in source code." might be confusing since the person might say "what? I can write def foo(): Unit = Unit"
Maybe:
warn-unit.scala:14: error: `Unit` companion object is not allowed in source; instead, use `()` for the unit value
Unit
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you can probably tell that I came up with the "not for use" phrase myself, it wasn't vetted on the other PR. If this PR goes ahead, and passes jenkins somehow, I have a special weekend retreat lined up to reflect upon the sum of commentary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to run it by the ministry of quotations for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I expense the retreat though them, or is it not that sort of ministry? Or maybe they have a place in Big Sur.
|
There was an Another idea was that only |
|
Apparently I forgot to sign the CLA. What does the CLA opcode do again? |
|
Looks like scabot needed a kick in the pants after I rebooted the jenkins instance. |
Use `compileTimeOnly` mechanism to enforce it. Slap some `compileTimeOnly` on specialization to permit the infrastructure; and also explicitly omit specialized itself in check to allow `requiredClass[specialized]`.
cba161f to
de12406
Compare
|
Now it will need the special Ringo Starr treatment. Locally, I did the compiler first and then the library. I don't actually know what the procedure is here. Sorry I squashed it, too. |
lrytz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe split it up in separate commits for Unit and specialized.
|
The PR title sounds like a sad science fiction love story. |
|
closing for inactivity, but can be revived and reopened any time |
This is a spinoff from scala#6490.
|
I created a Unit spinoff here - #7400 |
|
the new hotness is #7567 |
|
the even newer, actually-got-merged hotness is |
Use
compileTimeOnlymechanism to enforce it.Slap some
compileTimeOnlyon specialization topermit the infrastructure; and also explicitly
omit specialized itself in check to allow
requiredClass[specialized].