Skip to content

Conversation

@som-snytt
Copy link
Contributor

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].

}
// 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)) {
Copy link
Contributor

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?

Copy link
Contributor

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")

Copy link
Member

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.

Copy link
Contributor Author

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 '()'.")
Copy link
Contributor

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".

Copy link
Contributor Author

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()'."

Copy link
Member

@eed3si9n eed3si9n Apr 5, 2018

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
    ^

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@som-snytt
Copy link
Contributor Author

som-snytt commented Apr 4, 2018

There was an a/an change to Int that is not autogenerated, so I removed the article from the template.

Another idea was that only StaticAnnotation args get a pass on compileTimeOnly, or maybe the other one is the only annotation to receive the check.

@som-snytt
Copy link
Contributor Author

Apparently I forgot to sign the CLA. What does the CLA opcode do again?

@adriaanm adriaanm added this to the 2.13.0-M4 milestone Apr 5, 2018
@adriaanm
Copy link
Contributor

adriaanm commented Apr 5, 2018

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]`.
@som-snytt
Copy link
Contributor Author

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.

Copy link
Member

@lrytz lrytz left a 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.

@adriaanm adriaanm modified the milestones: 2.13.0-M4, 2.13.0-M5 Apr 30, 2018
@som-snytt som-snytt added the WIP label Jun 4, 2018
@som-snytt
Copy link
Contributor Author

The PR title sounds like a sad science fiction love story.

@SethTisue SethTisue modified the milestones: 2.13.0-M5, 2.13.0-RC1 Aug 7, 2018
@adriaanm adriaanm modified the milestones: 2.13.0-RC1, 2.13.x Aug 7, 2018
@SethTisue
Copy link
Member

closing for inactivity, but can be revived and reopened any time

@SethTisue SethTisue closed this Nov 6, 2018
eed3si9n added a commit to eed3si9n/scala that referenced this pull request Nov 6, 2018
This is a spinoff from scala#6490.
@eed3si9n eed3si9n mentioned this pull request Nov 6, 2018
@eed3si9n
Copy link
Member

eed3si9n commented Nov 6, 2018

I created a Unit spinoff here - #7400

@SethTisue SethTisue removed this from the 2.13.1 milestone Jan 3, 2019
@SethTisue
Copy link
Member

the new hotness is #7567

@SethTisue
Copy link
Member

the even newer, actually-got-merged hotness is
#7698

@som-snytt som-snytt removed the WIP label Mar 22, 2019
@som-snytt som-snytt deleted the issue/bad-unit branch December 20, 2020 00:54
@som-snytt som-snytt changed the title Unit companion is disallowed [SUPERSEDED] Unit companion is disallowed Nov 9, 2024
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.

6 participants