Skip to content

Commit 3c6f20d

Browse files
committed
New implicit scope scheme
Compute anchors directly instead of relying on namedPartsWith. This gives more precise control for what is part of the implicit scope.
1 parent da50c71 commit 3c6f20d

File tree

5 files changed

+229
-167
lines changed

5 files changed

+229
-167
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,7 @@ object Trees {
15401540
receiver: tpd.Tree, method: TermName, args: List[Tree], targs: List[Type],
15411541
expectedType: Type)(using parentCtx: Context): tpd.Tree = {
15421542
given ctx as Context = parentCtx.retractMode(Mode.ImplicitsEnabled)
1543+
import dotty.tools.dotc.ast.tpd.TreeOps
15431544

15441545
val typer = ctx.typer
15451546
val proto = FunProto(args, expectedType)

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
510510
/** A repeated argument such as `arg: _*` */
511511
def repeated(arg: Tree)(implicit ctx: Context): Typed = Typed(arg, Ident(tpnme.WILDCARD_STAR))
512512

513-
// ----- Accessing modifiers ----------------------------------------------------
514513

515514
// --------- Copier/Transformer/Accumulator classes for untyped trees -----
516515

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5462,14 +5462,15 @@ object Types {
54625462
def apply(x: Unit, tp: Type): Unit = foldOver(p(tp), tp)
54635463
}
54645464

5465+
class TypeHashSet extends util.HashSet[Type](64):
5466+
override def hash(x: Type): Int = System.identityHashCode(x)
5467+
override def isEqual(x: Type, y: Type) = x.eq(y)
5468+
54655469
class NamedPartsAccumulator(p: NamedType => Boolean, excludeLowerBounds: Boolean = false)
54665470
(implicit ctx: Context) extends TypeAccumulator[mutable.Set[NamedType]] {
54675471
override def stopAtStatic: Boolean = false
54685472
def maybeAdd(x: mutable.Set[NamedType], tp: NamedType): mutable.Set[NamedType] = if (p(tp)) x += tp else x
5469-
val seen: util.HashSet[Type] = new util.HashSet[Type](64) {
5470-
override def hash(x: Type): Int = System.identityHashCode(x)
5471-
override def isEqual(x: Type, y: Type) = x.eq(y)
5472-
}
5473+
val seen = TypeHashSet()
54735474
def apply(x: mutable.Set[NamedType], tp: Type): mutable.Set[NamedType] =
54745475
if (seen contains tp) x
54755476
else {

0 commit comments

Comments
 (0)