Skip to content

Commit 309da1d

Browse files
committed
Two fixes to transparent handling
and more tests
1 parent bd434a6 commit 309da1d

22 files changed

+1337
-13
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ object Inliner {
7070

7171
def postTransform(tree: Tree)(implicit ctx: Context) = tree match {
7272
case Assign(lhs, rhs) if lhs.symbol.name.is(InlineAccessorName) =>
73-
cpy.Apply(tree)(useSetter(lhs), rhs :: Nil)
73+
val setter = useSetter(lhs)
74+
if (inlineSym.isTransparentMethod) tree // just generate a setter, but don't integrate it in the tree
75+
else cpy.Apply(tree)(setter, rhs :: Nil)
7476
case _ =>
7577
tree
7678
}
@@ -686,6 +688,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
686688
*/
687689
trait InlineTyping extends Typer {
688690

691+
override def ensureAccessible(tpe: Type, superAccess: Boolean, pos: Position)(implicit ctx: Context): Type = {
692+
tpe match {
693+
case tpe @ TypeRef(pre, _) if !tpe.symbol.isAccessibleFrom(pre, superAccess) =>
694+
tpe.info match {
695+
case TypeAlias(alias) => return ensureAccessible(alias, superAccess, pos)
696+
case _ =>
697+
}
698+
case _ =>
699+
}
700+
super.ensureAccessible(tpe, superAccess, pos)
701+
}
702+
689703
override def typedIf(tree: untpd.If, pt: Type)(implicit ctx: Context) = {
690704
val cond1 = typed(tree.cond, defn.BooleanType)
691705
cond1.tpe.widenTermRefExpr match {
@@ -752,18 +766,6 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
752766
/** A re-typer used for inlined methods */
753767
private class InlineReTyper extends ReTyper with InlineTyping {
754768

755-
override def ensureAccessible(tpe: Type, superAccess: Boolean, pos: Position)(implicit ctx: Context): Type = {
756-
tpe match {
757-
case tpe @ TypeRef(pre, _) if !tpe.symbol.isAccessibleFrom(pre, superAccess) =>
758-
tpe.info match {
759-
case TypeAlias(alias) => return ensureAccessible(alias, superAccess, pos)
760-
case _ =>
761-
}
762-
case _ =>
763-
}
764-
super.ensureAccessible(tpe, superAccess, pos)
765-
}
766-
767769
override def typedIdent(tree: untpd.Ident, pt: Type)(implicit ctx: Context) =
768770
tree.asInstanceOf[tpd.Tree] match {
769771
case InlineableArg(rhs) => inlining.println(i"inline arg $tree -> $rhs"); rhs

0 commit comments

Comments
 (0)