Add sources of synthetic classes to sources jar#20904
Add sources of synthetic classes to sources jar#20904WojciechMazur merged 2 commits intoscala:mainfrom
Conversation
| * | ||
| * See [[https://docs.scala-lang.org/scala3/reference/other-new-features/kind-polymorphism.html]]. | ||
| */ | ||
| final abstract class AnyKind |
There was a problem hiding this comment.
It makes no sense for this type to be final. It definitely has subclasses, including AnyRef.
| final abstract class AnyKind | |
| abstract class AnyKind |
There was a problem hiding this comment.
I based it on Definitions.scala:
scala3/compiler/src/dotty/tools/dotc/core/Definitions.scala
Lines 450 to 451 in 75a15c2
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
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
The docs even say "It is declared abstract and final"
| @@ -0,0 +1,7 @@ | |||
| package scala | |||
|
|
|||
| /** The super-type of all types. | |||
There was a problem hiding this comment.
| /** 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. |
There was a problem hiding this comment.
This docstring is copied from Definitions.scala:
scala3/compiler/src/dotty/tools/dotc/core/Definitions.scala
Lines 2453 to 2458 in 010ed5a
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?
|
@WojciechMazur what about the change to the AnyKind docs in the comments? |
and exclude some synthetic sources that recently became part of the source jar (scala/scala3#20904)
and exclude some synthetic sources that recently became part of the source jar (scala/scala3#20904)
Closes #20073