Skip to content

Avoid insertion of spurious applies when inlining #2978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Contexts.Context
import Names.{Name, TermName, EmptyTermName}
import NameOps._
import NameKinds.InlineAccessorName
import ProtoTypes.selectionProto
import SymDenotations.SymDenotation
import Annotations._
import transform.ExplicitOuter
Expand Down Expand Up @@ -524,7 +525,9 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
}

override def typedSelect(tree: untpd.Select, pt: Type)(implicit ctx: Context): Tree = {
val res = super.typedSelect(tree, pt)
assert(tree.hasType, tree)
val qual1 = typed(tree.qualifier, selectionProto(tree.name, pt, this))
val res = untpd.cpy.Select(tree)(qual1, tree.name).withType(tree.typeOpt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why use AnySelectionProto instead of using selectionProto(tree.name, pt, this) as expected type in Retyper.typedSelect?

ensureAccessible(res.tpe, tree.qualifier.isInstanceOf[untpd.Super], tree.pos)
res
}
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/inline-apply.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Context

object Test {

def transform()(implicit ctx: Context) = {
@inline def withLocalOwner[T](op: Context => T) = op(ctx)

withLocalOwner { implicit ctx => }

}
}