-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #7781: Loosen check for classes in wrong directory #7786
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
Conversation
The previous check demanded that the package prefix of a file corresponds one-to-one with the directory name. This makes it illegal to have classes in nested package clauses inside a file, which seems unreasonable. We now only require that the file path is a prefix of the package path.
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.
The issue number on the commit should be #7781. Otherwise LGTM.
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 also lacks a test.
@smarter do you know how to create a test that triggers this warning? |
Use tests/pos-special/sourcepath and tests/neg-custom-args/sourcepath |
I don't think so. Why would it?
Well, in a sense the quoted.Expr example is the test. That's what failed before, anyway. I won't be able to work on this anymore, but it needs to be part of the release. @smarter or @nicolasstucki maybe you want to add a test? If there's no time for that let's merge anyway. |
Because // A.scala
package foo
package bar
class A // B.scala
type Bla = foo.bar.A % mkdir sp/foo
% mv A.scala sp/foo
% dotc -sourcepath sp B.scala
-- [E008] Member Not Found Error: B.scala:1:15 ------------------------------
1 |type Bla = foo.bar.A
| ^^^^^^^
| value bar is not a member of foo - did you mean foo.A? No symbol was created for
I think merging #7784 would be more conservative. |
@smarter I see what you mean. That aspect did not change. So, basically, outline parsing with nested packages was broken and is still broken now. #7784 "fixes" this by not using the feature in our own codebase. But others will run into the same problem. So I think we should either fix it or disable it (by issuing a "not implemented error") before the release. |
But before this PR the same code would have lead to a warning "class A is in the wrong directory." and wouldn't have added A to foo. Is there some other scenario where current master would add the symbol anyway ? |
That's not quite as bad, but still counts as broken. The problem is, #7784 changes the public API of the core Type and Expr types in a non-desirable way to circumvent our lack of support for nested packages. So I much prefer we fix it instead. |
I see it's not so easy to fix, since there is quite involved logic in Namer for creating packages. It's not clear we want to push all that into the outline parser. So, let's close this and revive #7784. |
The previous check demanded that the package prefix of a file corresponds
one-to-one with the directory name. This makes it illegal to have classes
in nested package clauses inside a file, which seems unreasonable. We now
only require that the file path is a prefix of the package path.