@@ -26,6 +26,7 @@ import ErrorReporting.errorTree
26
26
import collection .mutable
27
27
import transform .TypeUtils ._
28
28
import reporting .trace
29
+ import util .Positions .Position
29
30
30
31
object Inliner {
31
32
import tpd ._
@@ -91,26 +92,26 @@ object Inliner {
91
92
def addAccessor (tree : Tree , refPart : Tree , targs : List [Tree ], argss : List [List [Tree ]],
92
93
accessedType : Type , rhs : (Tree , List [Type ], List [List [Tree ]]) => Tree )(implicit ctx : Context ): Tree = {
93
94
val qual = qualifier(refPart)
94
-
95
+
95
96
def refIsLocal = qual match {
96
97
case qual : This => qual.symbol == refPart.symbol.owner
97
98
case _ => false
98
99
}
99
-
100
+
100
101
def addAcc (accessorDef : MemberDef ) = {
101
102
accessors += accessorDef
102
103
inlining.println(i " added inline accessor: $accessorDef" )
103
104
}
104
-
105
+
105
106
if (refPart.symbol.isStatic || refIsLocal) {
106
107
// Easy case: Reference to a static symbol or a symbol referenced via `this.`
107
108
val accessorType = accessedType.ensureMethodic
108
109
val accessor = accessorSymbol(tree, accessorType).asTerm
109
-
110
+
110
111
addAcc(
111
112
polyDefDef(accessor, tps => argss =>
112
113
rhs(refPart, tps, argss).withPos(tree.pos.focus)))
113
-
114
+
114
115
ref(accessor).appliedToTypeTrees(targs).appliedToArgss(argss).withPos(tree.pos)
115
116
}
116
117
else {
@@ -150,7 +151,7 @@ object Inliner {
150
151
polyDefDef(accessor, tps => argss =>
151
152
rhs(argss.head.head.select(refPart.symbol), tps.drop(localRefs.length), argss.tail)
152
153
.withPos(tree.pos.focus)))
153
-
154
+
154
155
ref(accessor)
155
156
.appliedToTypeTrees(localRefs.map(TypeTree (_)) ++ targs)
156
157
.appliedToArgss((qual :: Nil ) :: argss)
@@ -547,6 +548,18 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
547
548
548
549
var retainedInlineables = Set [Symbol ]()
549
550
551
+ override def ensureAccessible (tpe : Type , superAccess : Boolean , pos : Position )(implicit ctx : Context ): Type = {
552
+ tpe match {
553
+ case tpe @ TypeRef (pre, _) if ! tpe.symbol.isAccessibleFrom(pre, superAccess) =>
554
+ tpe.info match {
555
+ case TypeAlias (alias) => return ensureAccessible(alias, superAccess, pos)
556
+ case _ =>
557
+ }
558
+ case _ =>
559
+ }
560
+ super .ensureAccessible(tpe, superAccess, pos)
561
+ }
562
+
550
563
override def typedIdent (tree : untpd.Ident , pt : Type )(implicit ctx : Context ) =
551
564
tree.asInstanceOf [tpd.Tree ] match {
552
565
case InlineableArg (rhs) => inlining.println(i " inline arg $tree -> $rhs" ); rhs
0 commit comments