Skip to content

Commit 2a96910

Browse files
committed
Allow accesses to private constant values
Need to tweak ensureAccessible to use the constant type instead of the reference.
1 parent ff6a9b6 commit 2a96910

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ object Inliner {
127127
if needsAccessor(tree.symbol) && tree.isTerm && !tree.symbol.isConstructor =>
128128
val (refPart, targs, argss) = decomposeCall(tree)
129129
val qual = qualifier(refPart)
130-
println(i"adding receiver passing inline accessor for $tree/$refPart -> (${qual.tpe}, $refPart: ${refPart.getClass}, [$targs%, %], ($argss%, %))")
130+
inlining.println(i"adding receiver passing inline accessor for $tree/$refPart -> (${qual.tpe}, $refPart: ${refPart.getClass}, [$targs%, %], ($argss%, %))")
131131

132132
// Need to dealias in order to cagtch all possible references to abstracted over types in
133133
// substitutions
@@ -545,9 +545,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
545545

546546
override def ensureAccessible(tpe: Type, superAccess: Boolean, pos: Position)(implicit ctx: Context): Type = {
547547
tpe match {
548-
case tpe @ TypeRef(pre, _) if !tpe.symbol.isAccessibleFrom(pre, superAccess) =>
548+
case tpe: NamedType if !tpe.symbol.isAccessibleFrom(tpe.prefix, superAccess) =>
549549
tpe.info match {
550550
case TypeAlias(alias) => return ensureAccessible(alias, superAccess, pos)
551+
case info: ConstantType => return info
551552
case _ =>
552553
}
553554
case _ =>

0 commit comments

Comments
 (0)