Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Dec 23, 2018

Annotations get a dispensation for the ref check.

The Group mechanism for specialized only uses the type args, so avoid using Unit to define a value.

Forward ports #6490, which didn't cope with Group definitions.

@lihaoyi
Copy link
Contributor

lihaoyi commented Dec 24, 2018

If you don't want people to accidentally access the unit companion object Unit, why not just rename it from Unit into something like UnitLolz? Seems easier than trying to do funny things with types inside the compiler internals

@som-snytt
Copy link
Contributor Author

som-snytt commented Dec 24, 2018

@lihaoyi I don't disagree with you, see https://twitter.com/dwijnand/status/1073149475936485376 which says apparently anyone can confuse it.

I'm just trying to help the folks on current version of Scala, using available mechanisms.

Also note that there are no weird tricks here. @compileTimeOnly is used as advertised.

(Edit: the weird specializable idiom using the companion object is not great and also determines the name.)

@hmemcpy
Copy link

hmemcpy commented Dec 24, 2018

Heh, even @odersky confused them on stage at ScalaExchange :)

@scala-jenkins scala-jenkins added this to the 2.13.0-RC1 milestone Dec 27, 2018
@som-snytt som-snytt requested a review from hrhino January 2, 2019 23:36
@som-snytt som-snytt changed the title Setup Unit companion as CompileTimeOnly Unit companion is compileTimeOnly Jan 2, 2019
@som-snytt
Copy link
Contributor Author

Of course, this makes it harder to test methods on Unit.

@som-snytt
Copy link
Contributor Author

I think it worked:

Macros_1.scala:46: error: `Unit` companion object is not allowed in source; instead, use `()` for the unit value
      if (fields.length == 0) Literal(Constant(Unit))
                                               ^
one error found

@som-snytt som-snytt force-pushed the issue/Unit-disallowed-2.13 branch 2 times, most recently from a819871 to dfcc5db Compare January 3, 2019 01:06
@som-snytt

This comment has been minimized.

Annotations get a dispensation for the ref check.

The `Group` mechanism for specialized is moved
to the type level.
Add some convenience groups to Specializable and
avoid usages of Unit companion in library so that
Unit companion can be compileTimeOnly without
compiler assistance.
@som-snytt som-snytt force-pushed the issue/Unit-disallowed-2.13 branch from dfcc5db to ff9a527 Compare January 20, 2019 09:18
@som-snytt
Copy link
Contributor Author

Probably this PR had seniority over recent efforts to leave fingerprints on Function0.

@som-snytt som-snytt closed this Jan 20, 2019
@som-snytt som-snytt deleted the issue/Unit-disallowed-2.13 branch January 20, 2019 14:35
@dwijnand
Copy link
Member

@eed3si9n's turn to PR again?

@SethTisue
Copy link
Member

new hotness is #7698

@SethTisue SethTisue removed this from the 2.13.0-RC1 milestone Feb 22, 2019
@som-snytt som-snytt changed the title Unit companion is compileTimeOnly [SUPERSEDED] Unit companion is compileTimeOnly 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