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

Add sources of synthetic classes to sources jar #20904

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

Florian3k
Copy link
Contributor

Closes #20073

@Gedochao Gedochao requested a review from sjrd July 3, 2024 11:24
@WojciechMazur WojciechMazur added this to the 3.5.1 milestone Jul 3, 2024
@WojciechMazur WojciechMazur added the backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" label Jul 3, 2024
library-aux/src/scala/AnyKind.scala Outdated Show resolved Hide resolved
*
* See [[https://docs.scala-lang.org/scala3/reference/other-new-features/kind-polymorphism.html]].
*/
final abstract class AnyKind
Copy link
Member

Choose a reason for hiding this comment

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

It makes no sense for this type to be final. It definitely has subclasses, including AnyRef.

Suggested change
final abstract class AnyKind
abstract class AnyKind

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I based it on Definitions.scala:

@tu lazy val AnyKindClass: ClassSymbol = {
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil, newScope(0))

When trying to extend AnyKind, the following errors are reported:

$ scala-cli repl            
Welcome to Scala 3.4.2 (11, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                                                                                   
scala> class Test extends AnyKind
-- [E093] Syntax Error: --------------------------------------------------------
1 |class Test extends AnyKind
  |      ^
  |      class Test cannot extend final class AnyKind
  |
  | longer explanation available when compiling with `-explain`
-- Error: ----------------------------------------------------------------------
1 |class Test extends AnyKind
  |                   ^^^^^^^
  |                   AnyKind does not have a constructor
2 errors found

Copy link
Member

Choose a reason for hiding this comment

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

Definitions is what works for the compiler with the minimum amount of work. From a spec point of view, AnyKind is not even a class (nor a trait). It's a completely unique thing. The error message that you mention is definitely not a good message. We shouldn't tailor the doc to that poor message. We should tailor it to the real spec as much as possible instead.

(Arguably it should even be an abstract type as well, but since Nothing is presented as a class, it makes "less not" sense to also use a class here.)

Copy link
Member

Choose a reason for hiding this comment

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

The docs even say "It is declared abstract and final"

library-aux/src/scala/andType.scala Outdated Show resolved Hide resolved
@Florian3k Florian3k requested a review from sjrd July 3, 2024 18:39
@@ -0,0 +1,7 @@
package scala

/** The super-type of all types.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** The super-type of all types.
/** AnyKind plays a special role in Scala's subtype system:
* It is a supertype of all other types no matter what their kind is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This docstring is copied from Definitions.scala:

add(AnyKindClass,
"""/** The super-type of all types.
| *
| * See [[https://docs.scala-lang.org/scala3/reference/other-new-features/kind-polymorphism.html]].
| */
""".stripMargin)

It is also source of truth for scaladoc generation. I think those comments should be kept in sync.
Should I change it in Definitions.scala as well?

Copy link
Member

Choose a reason for hiding this comment

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

Yes please!

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

LGTM, but I do think the docs page description for AnyKind is better.

@WojciechMazur WojciechMazur merged commit 97a711c into scala:main Jul 12, 2024
24 checks passed
@WojciechMazur WojciechMazur added backport:done This PR was successfully backported. and removed backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" labels Jul 14, 2024
@dwijnand
Copy link
Member

@WojciechMazur what about the change to the AnyKind docs in the comments?

SethTisue pushed a commit to scala-steward/scala-3 that referenced this pull request Aug 8, 2024
and exclude some synthetic sources that recently became
part of the source jar (scala/scala3#20904)
SethTisue pushed a commit to scala-steward/scala-3 that referenced this pull request Aug 14, 2024
and exclude some synthetic sources that recently became
part of the source jar (scala/scala3#20904)
WojciechMazur added a commit that referenced this pull request Dec 2, 2024
…1992)

Backports #20904 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:done This PR was successfully backported.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

publish sources of synthetic classes and types in -sources.jar artefacts
4 participants