-
Notifications
You must be signed in to change notification settings - Fork 11
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
Redesign Names. #366
Conversation
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.
Then remove `Name.tag`.
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.
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
So that it makes more sense.
`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.
cf1ffd1
to
fc96252
Compare
No description provided.