-
Notifications
You must be signed in to change notification settings - Fork 21
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
private class escapes defining scope #2441
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2441?orig=1 |
@paulp said: Either way, the error message is incredibly unhelpful in terms of indicating what has to happen for it to compile. If you don't already know what's up, you will be head scratching. Here is my example, which I enclose because it is somewhat different: the "private class" in question is private not by virtue of an access modifier but because it's a member of a constructor parameter. In trunk as of r20562 if you make these changes: // add these two lines to MarkupParserCommon
type ElementType
def mkProcInstr(position: PositionType): ElementType
// add these two to MarkupParsers after line 71
type ElementType = Tree
def mkProcInstr(position: Position) = handle.procInstr(position, "", "") And we get: [scalacfork] /scratch/trunk2/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala:74: error: private value parser escapes its defining scope as part of type MarkupParser.this.parser.symbXMLBuilder.global.Tree
[scalacfork] def mkProcInstr(position: Position) = handle.procInstr(position, "", "")
[scalacfork] ^ Define mkProcInstr with return type Tree, and all is well. |
@paulp said: I had closed #2441 as a duplicate of that, but unfortunately #4114 did |
The following code should not compile, but does:
This piece of code contains a programming mistake which should be detected by the compile: the line
should instead read
because otherwise the result type will be inferred as Option[B.Y], revealing the private class Y through the public method f, so that any other module can access Y.y:
The error is correctly detected if object B is private or Y is a member of class B.
[[BR]][[BR]]
Tested with versions 2.7.7.RC1 and 2.7.3final.
The text was updated successfully, but these errors were encountered: