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

Redesign Names. #366

Merged
merged 21 commits into from
Oct 20, 2023
Merged

Redesign Names. #366

merged 21 commits into from
Oct 20, 2023

Conversation

sjrd
Copy link
Contributor

@sjrd sjrd commented Oct 20, 2023

No description provided.

A name is almost never empty. The only known case is for a given
import, which already has a dedicated accessor `isGiven` to present
to the public API.
This means that `Printers` do not have to specifically print it
itself. It also means that the `SignatureSuite` becomes more
precise, as we can actually make the difference between class names
and module class names in the string representations that we use
for testing.
Previously, there was an invariant that the last name in a
signature name was always a `TypeName`, and all the other ones
were `TermName`s. Instead, we now declare that they must all be
`TermName`s.

This removes the need for a number of `mapLast`s, and simplifies
manipulations and invariants.
…ullName`.

`fullName` is not meaningful on arbitrary symbols. Having it
return a supposedly structured `FullyQualifiedName` is misleading.

We move it `PackageSymbol`, for which it is actually meaningful and
used.

In `Symbol`, we introduce `displayFullName` instead, which does
the same as what the previous `fullName` did but returned as a
`String`. This is meant to be used for display purposes only, such
as debugging or error messages.
@sjrd sjrd requested a review from bishabosha October 20, 2023 09:22
@@ -1689,6 +1696,12 @@ object Symbols {
this.withFlags(EmptyFlagSet, None)
this.setAnnotations(Nil)

private lazy val _fullName: FullyQualifiedName =
if owner == null || name == nme.EmptyPackageName then FullyQualifiedName.rootPackageName
Copy link
Member

@bishabosha bishabosha Oct 20, 2023

Choose a reason for hiding this comment

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

why isn't this emptyPackageName for the empty package? I guess consistency in that <empty> does not appear in the prefix, but just checking

Copy link
Member

Choose a reason for hiding this comment

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

I can see its just a refactoring, so not really important


object Loader:
private[Loaders] case class Root private[Loaders] (pkg: PackageSymbol, rootName: SimpleName):
def fullName: FullyQualifiedName =
pkg.fullName.select(rootName)
override def toString(): String = pkg.displayFullName + "." + rootName.toString
Copy link
Member

Choose a reason for hiding this comment

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

this will now print <empty>.Foo rather than Foo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

A `PackageFullName` only contains `SimpleName`s. A `SignatureName`
contains `SimpleName`s and `ObjectClassName`s.
Also directly use `tpnme.Wildcard` instead of
`TypeName(nme.Wildcard)`.
Use alternatives from `tpnme` instead.
`TypeName`s do not fundamentally wrap `TermName`s anymore. They
form their separate hierarchy. They are much simpler than term
names: there are only `SimpleTypeName`, `ObjectClassTypeName` and
`UniqueTypeName`.

All `TypeName`s can be converted to `TermName`s, but only
`SignatureNameItem`s can be converted to `ClassTypeName`s.
@sjrd sjrd merged commit 316490c into scalacenter:main Oct 20, 2023
4 checks passed
@sjrd sjrd deleted the redesign-names-2 branch October 20, 2023 12:10
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.

2 participants