Skip to content

Commit b6785c0

Browse files
committed
Address review comments
1 parent 463de11 commit b6785c0

File tree

11 files changed

+22
-22
lines changed

11 files changed

+22
-22
lines changed

Diff for: compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class InlineReducer(inliner: Inliner)(using Context):
198198
val evTyper = new Typer(ctx.nestingLevel + 1)
199199
val evCtx = ctx.fresh.setTyper(evTyper)
200200
inContext(evCtx) {
201-
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span, ignored = Set.empty)
201+
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)
202202
evidence.tpe match {
203203
case fail: Implicits.AmbiguousImplicits =>
204204
report.error(evTyper.missingArgMsg(evidence, tpt.tpe, ""), tpt.srcPos)

Diff for: compiler/src/dotty/tools/dotc/inlines/Inlines.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ object Inlines:
506506
val evTyper = new Typer(ctx.nestingLevel + 1)
507507
val evCtx = ctx.fresh.setTyper(evTyper)
508508
inContext(evCtx) {
509-
val evidence = evTyper.inferImplicitArg(tpe, callTypeArgs.head.span, ignored = Set.empty)
509+
val evidence = evTyper.inferImplicitArg(tpe, callTypeArgs.head.span)
510510
evidence.tpe match
511511
case fail: Implicits.SearchFailureType =>
512512
errorTree(call, evTyper.missingArgMsg(evidence, tpe, ""))

Diff for: compiler/src/dotty/tools/dotc/staging/HealType.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
8686
*/
8787
protected def tryHeal(tp: TypeRef): Type = {
8888
val reqType = defn.QuotedTypeClass.typeRef.appliedTo(tp)
89-
val tag = ctx.typer.inferImplicitArg(reqType, pos.span, ignored = Set.empty)
89+
val tag = ctx.typer.inferImplicitArg(reqType, pos.span)
9090
tag.tpe match
9191
case tp: TermRef =>
9292
ctx.typer.checkStable(tp, pos, "type witness")

Diff for: compiler/src/dotty/tools/dotc/typer/Implicits.scala

+9-9
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ trait Implicits:
901901
}
902902

903903
try
904-
val inferred = inferImplicit(adjust(to), from, from.span, ignored = Set.empty)
904+
val inferred = inferImplicit(adjust(to), from, from.span)
905905

906906
inferred match {
907907
case SearchSuccess(_, ref, _, false) if isOldStyleFunctionConversion(ref.underlying) =>
@@ -928,7 +928,7 @@ trait Implicits:
928928
/** Find an implicit argument for parameter `formal`.
929929
* Return a failure as a SearchFailureType in the type of the returned tree.
930930
*/
931-
def inferImplicitArg(formal: Type, span: Span, ignored: Set[Symbol])(using Context): Tree =
931+
def inferImplicitArg(formal: Type, span: Span, ignored: Set[Symbol] = Set.empty)(using Context): Tree =
932932
inferImplicit(formal, EmptyTree, span, ignored) match
933933
case SearchSuccess(arg, _, _, _) => arg
934934
case fail @ SearchFailure(failed) =>
@@ -944,7 +944,7 @@ trait Implicits:
944944

945945
/** Search an implicit argument and report error if not found */
946946
def implicitArgTree(formal: Type, span: Span, where: => String = "")(using Context): Tree = {
947-
val arg = inferImplicitArg(formal, span, ignored = Set.empty)
947+
val arg = inferImplicitArg(formal, span)
948948
if (arg.tpe.isInstanceOf[SearchFailureType])
949949
report.error(missingArgMsg(arg, formal, where), ctx.source.atSpan(span))
950950
arg
@@ -968,7 +968,7 @@ trait Implicits:
968968
def ignoredInstanceNormalImport = arg.tpe match
969969
case fail: SearchFailureType =>
970970
if (fail.expectedType eq pt) || isFullyDefined(fail.expectedType, ForceDegree.none) then
971-
inferImplicit(fail.expectedType, fail.argument, arg.span, Set.empty)(
971+
inferImplicit(fail.expectedType, fail.argument, arg.span)(
972972
using findHiddenImplicitsCtx(ctx)) match {
973973
case s: SearchSuccess => Some(s)
974974
case f: SearchFailure =>
@@ -1082,7 +1082,7 @@ trait Implicits:
10821082
* it should be applied, EmptyTree otherwise.
10831083
* @param span The position where errors should be reported.
10841084
*/
1085-
def inferImplicit(pt: Type, argument: Tree, span: Span, ignored: Set[Symbol])(using Context): SearchResult = ctx.profiler.onImplicitSearch(pt):
1085+
def inferImplicit(pt: Type, argument: Tree, span: Span, ignored: Set[Symbol] = Set.empty)(using Context): SearchResult = ctx.profiler.onImplicitSearch(pt):
10861086
trace(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) {
10871087
record("inferImplicit")
10881088
assert(ctx.phase.allowsImplicitSearch,
@@ -1670,17 +1670,17 @@ trait Implicits:
16701670
SearchFailure(TooUnspecific(pt), span)
16711671
else
16721672
val contextual = ctxImplicits != null
1673-
val prePreEligible = // the eligible candidates, ignoring positions
1673+
var preEligible = // the eligible candidates, ignoring positions
16741674
if ctxImplicits != null then
16751675
if ctx.gadt.isNarrowing then
16761676
withoutMode(Mode.ImplicitsEnabled) {
16771677
ctxImplicits.uncachedEligible(wildProto)
16781678
}
16791679
else ctxImplicits.eligible(wildProto)
16801680
else implicitScope(wildProto).eligible
1681-
1682-
val preEligible =
1683-
prePreEligible.filter(candidate => !ignored.contains(candidate.implicitRef.underlyingRef.symbol))
1681+
if !ignored.isEmpty then
1682+
preEligible =
1683+
preEligible.filter(candidate => !ignored.contains(candidate.implicitRef.underlyingRef.symbol))
16841684
/** Does candidate `cand` come too late for it to be considered as an
16851685
* eligible candidate? This is the case if `cand` appears in the same
16861686
* scope as a given definition of the form `given ... = ...` that

Diff for: compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait QuotesAndSplices {
4545
report.warning("Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.", tree.srcPos)
4646
case _ =>
4747
}
48-
val quotes = inferImplicitArg(defn.QuotesClass.typeRef, tree.span, ignored = Set.empty)
48+
val quotes = inferImplicitArg(defn.QuotesClass.typeRef, tree.span)
4949

5050
if quotes.tpe.isInstanceOf[SearchFailureType] then
5151
report.error(missingArgMsg(quotes, defn.QuotesClass.typeRef, ""), ctx.source.atSpan(tree.span))

Diff for: compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
4545
case arg :: Nil =>
4646
instArg(arg) match
4747
case defn.ArrayOf(elemTp) =>
48-
val etag = typer.inferImplicitArg(defn.ClassTagClass.typeRef.appliedTo(elemTp), span, Set.empty)
48+
val etag = typer.inferImplicitArg(defn.ClassTagClass.typeRef.appliedTo(elemTp), span)
4949
if etag.tpe.isError then EmptyTree else etag.select(nme.wrap)
5050
case tp if hasStableErasure(tp) && !tp.isBottomTypeAfterErasure =>
5151
val sym = tp.typeSymbol
@@ -148,7 +148,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
148148

149149
/** Is there an `CanEqual[T, T]` instance, assuming -strictEquality? */
150150
def hasEq(tp: Type)(using Context): Boolean =
151-
val inst = typer.inferImplicitArg(defn.CanEqualClass.typeRef.appliedTo(tp, tp), span, ignored = Set.empty)
151+
val inst = typer.inferImplicitArg(defn.CanEqualClass.typeRef.appliedTo(tp, tp), span)
152152
!inst.isEmpty && !inst.tpe.isError
153153

154154
/** Can we assume the canEqualAny instance for `tp1`, `tp2`?

Diff for: compiler/src/dotty/tools/dotc/typer/Typer.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
11071107
case Decimal => defn.FromDigits_DecimalClass
11081108
case Floating => defn.FromDigits_FloatingClass
11091109
}
1110-
inferImplicit(fromDigitsCls.typeRef.appliedTo(target), EmptyTree, tree.span, ignored = Set.empty) match {
1110+
inferImplicit(fromDigitsCls.typeRef.appliedTo(target), EmptyTree, tree.span) match {
11111111
case SearchSuccess(arg, _, _, _) =>
11121112
val fromDigits = untpd.Select(untpd.TypedSplice(arg), nme.fromDigits).withSpan(tree.span)
11131113
val firstArg = Literal(Constant(digits))
@@ -1282,7 +1282,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
12821282
def withTag(tpe: Type): Option[Tree] = {
12831283
require(ctx.mode.is(Mode.Pattern))
12841284
withoutMode(Mode.Pattern)(
1285-
inferImplicit(tpe, EmptyTree, tree.tpt.span, ignored = Set.empty)
1285+
inferImplicit(tpe, EmptyTree, tree.tpt.span)
12861286
) match
12871287
case SearchSuccess(clsTag, _, _, _) =>
12881288
withMode(Mode.InTypeTest) {
@@ -4201,7 +4201,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
42014201
else formals1
42024202
implicitArgs(formals2, argIndex + 1, pt)
42034203

4204-
val arg = inferImplicitArg(formal, tree.span.endPos, ignored = Set.empty)
4204+
val arg = inferImplicitArg(formal, tree.span.endPos)
42054205
arg.tpe match
42064206
case failed: AmbiguousImplicits =>
42074207
val pt1 = pt.deepenProtoTrans

Diff for: compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
25272527
object Implicits extends ImplicitsModule:
25282528
def search(tpe: TypeRepr): ImplicitSearchResult =
25292529
import tpd.TreeOps
2530-
val implicitTree = ctx.typer.inferImplicitArg(tpe, Position.ofMacroExpansion.span, ignored = Set.empty)
2530+
val implicitTree = ctx.typer.inferImplicitArg(tpe, Position.ofMacroExpansion.span)
25312531
// Make sure that we do not have any uninstantiated type variables.
25322532
// See tests/pos-macros/i16636.
25332533
// See tests/pos-macros/exprSummonWithTypeVar with -Xcheck-macros.

Diff for: tests/run-macros/summonIgnoring-nonrecursive/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ object TC2 {
4747
println(s"TC2[_] generated in macro using:")
4848
tc.print()
4949
}
50-
}
50+
}

Diff for: tests/run-macros/summonIgnoring-nonrecursive/Test_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
@main def Test(): Unit = {
44
class C2
55
summon[TC[C2]].print()
6-
}
6+
}

Diff for: tests/run-macros/summonIgnoring/Test_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
}
1313
summon[TC[C2]].print()
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)