Skip to content

Fix #5966: Narrow criterion for when we have an inserted apply #5973

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
Feb 22, 2019
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ object Trees {
extends GenericApply[T] {
type ThisTree[-T >: Untyped] = Apply[T]

def isContextual = getAttachment(untpd.WithApply).nonEmpty
def isContextual = getAttachment(untpd.ApplyGiven).nonEmpty
}

/** fun[args] */
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
*/
val OriginalSymbol: Property.Key[Symbol] = new Property.Key

/** Property key for contextual Apply trees of the form `fn with arg` */
val WithApply: Property.StickyKey[Unit] = new Property.StickyKey
/** Property key for contextual Apply trees of the form `fn given arg` */
val ApplyGiven: Property.StickyKey[Unit] = new Property.StickyKey

// ------ Creation methods for untyped only -----------------

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ object Parsers {
val args = if (in.token == LPAREN) parArgumentExprs() else operand() :: Nil
Apply(top, args)
}
app.pushAttachment(WithApply, ())
app.pushAttachment(ApplyGiven, ())
recur(app)
}
else reduceStack(base, top, minPrec, leftAssoc = true, in.name, isType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case dummyTreeOfType(tp) :: Nil if !(tp isRef defn.NullClass) => "null: " ~ toText(tp)
case _ => toTextGlobal(args, ", ")
}
return "FunProto(" ~ argsText ~ "):" ~ toText(resultType)
return "FunProto(" ~ (Str("given ") provided tp.isContextual) ~ argsText ~ "):" ~ toText(resultType)
case IgnoredProto(ignored) =>
return "?" ~ (("(ignored: " ~ toText(ignored) ~ ")") provided ctx.settings.verbose.value)
case tp @ PolyProto(targs, resType) =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ object EtaExpansion extends LiftImpure {
if (mt.paramInfos.nonEmpty && mt.paramInfos.last.isRepeatedParam)
ids = ids.init :+ repeated(ids.last)
var body: Tree = Apply(lifted, ids)
if (mt.isContextual) body.pushAttachment(WithApply, ())
if (mt.isContextual) body.pushAttachment(ApplyGiven, ())
if (!isLastApplication) body = PostfixOp(body, Ident(nme.WILDCARD))
val fn =
if (mt.isContextual) new untpd.FunctionWithMods(params, body, Modifiers(Implicit | Given))
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2200,15 +2200,13 @@ class Typer extends Namer
* with `fallBack` otherwise. `fallBack` is supposed to always give an error.
*/
def tryInsertApplyOrImplicit(tree: Tree, pt: ProtoType, locked: TypeVars)(fallBack: => Tree)(implicit ctx: Context): Tree = {

def isMethod(tree: Tree) = tree.tpe match {
case ref: TermRef => ref.denot.alternatives.forall(_.info.widen.isInstanceOf[MethodicType])
case _ => false
}

def isSyntheticApply(tree: Tree): Boolean = tree match {
case tree: Select => tree.getAttachment(InsertedApply).isDefined
case Apply(fn, _) => fn.getAttachment(InsertedApply).isDefined
case _ => false
}

Expand Down