-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Warn about encoded pkg obj names #22707
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
Warn about encoded pkg obj names #22707
Conversation
|
Practicing closing PRs for reworking instead of leaving them as drafts. |
|
Related issue #22866 was scaladoc receiving names via tasty, where the package prefix and class name must be encoded (apparently because scaladoc would split on dot?). I don't remember the details, but it sounds ad hoc and perhaps wrong. The scaladoc issue was the filename A package must preserve segments; the name is If that isn't handled uniformly (correctly), then warning is the best effort. |
|
status quo for hyphen in package name but not in file package object name: So it's sufficient to add the warning for file package object name. It's desirable not to warn for snippets. |
f916723 to
425ad15
Compare
425ad15 to
b08fba6
Compare
|
Added Added The rule is not to warn for package objects in the empty package, which is deemed "casual code". It's not obvious whether test code ought to meet that criterion. |
b08fba6 to
4595b63
Compare
|
added the |
|
@Gedochao I'm not sure "private / forking" option needs to be advertised in release notes. Also, I was unsure whether to introduce an option that names a Reporter class (I think Scala 2 has I'm available to make an adjustment per review. Edit: that's kind of obvious, so I'll push |
@som-snytt I guess generally speaking, |
| case CannotInstantiateQuotedTypeVarID // errorNumber: 219 | ||
| case DefaultShadowsGivenID // errorNumber: 220 | ||
| case RecurseWithDefaultID // errorNumber: 221 | ||
| case EncodedPackageNameID // 222 |
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.
// errorNumber: 222There 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 was too quick to innovate. I'll revert it, but I was thinking that it would be nice if the compiler added the line comment for me, as a code action or quickfix. That is future work; and also verify that compilation does not reorder the existing enum.
| i"""Tooling may not cope with directories whose names do not match their package name. | ||
| |For example, `p-q` is encoded as `p$$minusq` and written that way to the file system. | ||
| | | ||
| |Package objects have names derived from their file names, so that names such as | ||
| |`myfile.test.scala` and `myfile-test.scala` will result in encoded names for package objects. | ||
| | | ||
| |The name `$name` is encoded to `${name.encode}`.""" |
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"""Tools may not handle directories whose names differ from their corresponding package names.
|For example, `p-q` is encoded as `p$$minusq` when written to the file system.
|
|Package objects derive their names from the file names, so files such as
|`myfile.test.scala` or `myfile-test.scala` can produce encoded names for the generated package objects.
|
|In this case, the name `$name` is encoded as `${name.encode}`."""4595b63 to
ddf613a
Compare
|
Original comment: Original ticket for warning is #14448 Doesn't yet address Also Also we write |
ddf613a to
eabc2cf
Compare
noti0na1
left a comment
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.
LGTM
| * be using for the package object that will wrap them. | ||
| */ | ||
| def packageObjectName(src: SourceFile): TermName = | ||
| def packageObjectName(src: SourceFile, srcPos: SrcPos)(using Context): TermName = |
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.
param appears unused
eabc2cf to
9b88195
Compare
Extend "encoded package name" warning to file package object names.
Avoid warning about "casual" code in the empty package.
Add
-Yreporteras a testing convenience.Fixes #22670