Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15b6afb

Browse files
committed
ApplyToImplicitArgs is Applied attachment
1 parent ca0ce4f commit 15b6afb

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
lines changed

src/compiler/scala/tools/nsc/transform/CleanUp.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
516516
!elemtpt.tpe.typeSymbol.isBottomClass && !elemtpt.tpe.typeSymbol.isPrimitiveValueClass /* can happen via specialization.*/
517517
=>
518518
classTagEvidence.attachments.get[analyzer.MacroExpansionAttachment] match {
519-
case Some(att) if att.expandee.symbol.name == nme.materializeClassTag && tree.isInstanceOf[ApplyToImplicitArgs] =>
519+
case Some(att) if att.expandee.symbol.name == nme.materializeClassTag && tree.hasAttachment[AppliedToImplicitArgs.type] =>
520520
super.transform(arg)
521521
case _ =>
522522
typedWithPos(tree.pos) {

src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait StdAttachments {
3535
def macroExpanderAttachment(tree: Tree): MacroExpanderAttachment =
3636
tree.attachments.get[MacroExpanderAttachment] getOrElse {
3737
tree match {
38-
case Apply(fn, _) if tree.isInstanceOf[ApplyToImplicitArgs] => macroExpanderAttachment(fn)
38+
case Apply(fn, _) if tree.hasAttachment[AppliedToImplicitArgs.type] => macroExpanderAttachment(fn)
3939
case _ => MacroExpanderAttachment(tree, EmptyTree)
4040
}
4141
}

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
283283
for (arg <- args) ar.subst traverse arg
284284
}
285285

286-
new ApplyToImplicitArgs(fun, args) setPos fun.pos
286+
ApplyToImplicitArgs(fun, args).setPos(fun.pos)
287287
case ErrorType =>
288288
fun
289289
case x => throw new MatchError(x)
@@ -5290,7 +5290,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
52905290

52915291
val tree1: Tree = resolveClassTag(tree.pos, tagType) match {
52925292
case EmptyTree => MissingClassTagError(tree, tagType)
5293-
case tag => atPos(tree.pos)(new ApplyToImplicitArgs(Select(tag, nme.newArray), arg :: Nil))
5293+
case tag => atPos(tree.pos)(ApplyToImplicitArgs(Select(tag, nme.newArray), arg :: Nil))
52945294
}
52955295
if (tree1.isErrorTyped) tree1 else typed(tree1, mode, pt)
52965296
case Apply(Select(fun, nme.apply), _) if treeInfo.isSuperConstrCall(fun) => TooManyArgumentListsForConstructor(tree) //scala/bug#5696
@@ -5347,7 +5347,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
53475347
mkAssign(Select(qq1, qual.symbol) setPos qual.pos)
53485348
}
53495349

5350-
case Apply(fn, extra) if qual.isInstanceOf[ApplyToImplicitArgs] =>
5350+
case Apply(fn, extra) if qual.hasAttachment[AppliedToImplicitArgs.type] =>
53515351
fn match {
53525352
case treeInfo.Applied(Select(table, nme.apply), _, indices :: Nil) =>
53535353
// table(indices)(implicits)

src/reflect/scala/reflect/internal/Importers.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,8 @@ trait Importers { to: SymbolTable =>
379379
new Typed(importTree(expr), importTree(tpt))
380380
case from.TypeApply(fun, args) =>
381381
new TypeApply(importTree(fun), args map importTree)
382-
case from.Apply(fun, args) => their match {
383-
case _: from.ApplyToImplicitArgs =>
384-
new ApplyToImplicitArgs(importTree(fun), args map importTree)
385-
case _ =>
386-
new Apply(importTree(fun), args map importTree)
387-
}
382+
case from.Apply(fun, args) =>
383+
new Apply(importTree(fun), args map importTree)
388384
case from.ApplyDynamic(qual, args) =>
389385
new ApplyDynamic(importTree(qual), args map importTree)
390386
case from.Super(qual, mix) =>

src/reflect/scala/reflect/internal/StdAttachments.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,6 @@ trait StdAttachments {
191191

192192
/** Application is an implicit view. */
193193
case object AppliedImplicitView extends PlainAttachment
194+
195+
case object AppliedToImplicitArgs extends PlainAttachment
194196
}

src/reflect/scala/reflect/internal/Trees.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,7 @@ trait Trees extends api.Trees {
805805
}
806806
object Apply extends ApplyExtractor
807807

808-
// TODO remove this class, add a tree attachment to Apply to track whether implicits were involved
809-
// copying trees will all too easily forget to distinguish subclasses
810-
class ApplyToImplicitArgs(fun: Tree, args: List[Tree]) extends Apply(fun, args)
808+
def ApplyToImplicitArgs(fun: Tree, args: List[Tree]) = Apply(fun, args).updateAttachment(AppliedToImplicitArgs)
811809

812810
def ApplyImplicitView(fun: Tree, args: List[Tree]) = Apply(fun, args).updateAttachment(AppliedImplicitView)
813811

@@ -1110,8 +1108,7 @@ trait Trees extends api.Trees {
11101108
def TypeApply(tree: Tree, fun: Tree, args: List[Tree]) =
11111109
new TypeApply(fun, args).copyAttrs(tree)
11121110
def Apply(tree: Tree, fun: Tree, args: List[Tree]) =
1113-
(tree match { // TODO: use a tree attachment to track whether this is an apply to implicit args or a view
1114-
case _: ApplyToImplicitArgs => new ApplyToImplicitArgs(fun, args)
1111+
(tree match {
11151112
// TODO: ApplyConstructor ???
11161113
case self.pendingSuperCall => self.pendingSuperCall
11171114
case _ => new Apply(fun, args)

src/reflect/scala/reflect/runtime/JavaUniverseForce.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
9494
this.RightAssociative
9595
this.RightAssociativeArg
9696
this.AppliedImplicitView
97+
this.AppliedToImplicitArgs
9798
this.noPrint
9899
this.typeDebug
99100
// inaccessible: this.posAssigner

0 commit comments

Comments
 (0)