File tree 1 file changed +22
-0
lines changed 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Check that exports do not leak private types
2
+ object Signature {
3
+
4
+ private type T
5
+
6
+ object O1 {
7
+ private [Signature ] def bar : T = ???
8
+ }
9
+ export O1 ._ // error: non-private method bar refers to private type T
10
+
11
+ object O2 {
12
+ private [Signature ] val foo : T = ???
13
+ }
14
+ export O2 ._ // OK
15
+ // The reason this works is that private escape checking only looks at real private members,
16
+ // not at private[C] members. So, by itself the expansion of the export
17
+ // <stable> def foo: O2.foo.type = O2.foo
18
+ // is legal. The underlying type of `O2.foo.type` does violate no-escape rules, but we do not
19
+ // check for it. Maybe we should. But then the question comes up whether we should
20
+ // also check all possible supertypes of a type for privacy violations. These are more
21
+ // general questions that are not related to exports.
22
+ }
You can’t perform that action at this time.
0 commit comments