Skip to content

Commit fe60cc1

Browse files
authored
Merge pull request #2978 from dotty-staging/fix-inline-apply
Avoid insertion of spurious applies when inlining
2 parents 46a933a + 53e35e0 commit fe60cc1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Contexts.Context
1616
import Names.{Name, TermName, EmptyTermName}
1717
import NameOps._
1818
import NameKinds.InlineAccessorName
19+
import ProtoTypes.selectionProto
1920
import SymDenotations.SymDenotation
2021
import Annotations._
2122
import transform.ExplicitOuter
@@ -524,7 +525,9 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
524525
}
525526

526527
override def typedSelect(tree: untpd.Select, pt: Type)(implicit ctx: Context): Tree = {
527-
val res = super.typedSelect(tree, pt)
528+
assert(tree.hasType, tree)
529+
val qual1 = typed(tree.qualifier, selectionProto(tree.name, pt, this))
530+
val res = untpd.cpy.Select(tree)(qual1, tree.name).withType(tree.typeOpt)
528531
ensureAccessible(res.tpe, tree.qualifier.isInstanceOf[untpd.Super], tree.pos)
529532
res
530533
}

tests/pos/inline-apply.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Context
2+
3+
object Test {
4+
5+
def transform()(implicit ctx: Context) = {
6+
@inline def withLocalOwner[T](op: Context => T) = op(ctx)
7+
8+
withLocalOwner { implicit ctx => }
9+
10+
}
11+
}

0 commit comments

Comments
 (0)