File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ object PostTyper {
17
17
18
18
/** A macro transform that runs immediately after typer and that performs the following functions:
19
19
*
20
- * (1) Add super accessors and protected accessors (@see SuperAccessors)
20
+ * (1) Add super accessors (@see SuperAccessors)
21
21
*
22
22
* (2) Convert parameter fields that have the same name as a corresponding
23
23
* public parameter field in a superclass to a forwarder to the superclass
Original file line number Diff line number Diff line change @@ -48,13 +48,16 @@ object Inliner {
48
48
def accessorNameKind = InlineAccessorName
49
49
50
50
/** A definition needs an accessor if it is private, protected, or qualified private
51
- * and it is not part of the tree that gets inlined. The latter test is implemented
52
- * by excluding all symbols properly contained in the inlined method.
53
- */
51
+ * and it is not part of the tree that gets inlined. The latter test is implemented
52
+ * by excluding all symbols properly contained in the inlined method.
53
+ *
54
+ * Constant vals don't need accessors since they are inlined in FirstTransform.
55
+ */
54
56
def needsAccessor (sym : Symbol )(implicit ctx : Context ) =
55
57
sym.isTerm &&
56
58
(sym.is(AccessFlags ) || sym.privateWithin.exists) &&
57
- ! sym.isContainedIn(inlineSym)
59
+ ! sym.isContainedIn(inlineSym) &&
60
+ ! (sym.isStable && sym.info.widenTermRefExpr.isInstanceOf [ConstantType ])
58
61
59
62
def preTransform (tree : Tree )(implicit ctx : Context ): Tree
60
63
Original file line number Diff line number Diff line change
1
+ object Foo {
2
+ private final val x = 1
3
+ private def y = 2
4
+ }
5
+
6
+ class Foo {
7
+ import Foo ._
8
+ inline def foo = x + Foo .x + y + Foo .y
9
+ }
10
+
11
+ class Test {
12
+ (new Foo ).foo
13
+ }
You can’t perform that action at this time.
0 commit comments