Skip to content

Commit ee44db8

Browse files
committed
Fix early returns nested in trace
Found by enabling the tracing config.
1 parent bb2d28f commit ee44db8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,10 @@ class SpaceEngine(using Context) extends SpaceLogic {
489489
private def erase(tp: Type, inArray: Boolean = false, isValue: Boolean = false): Type = trace(i"$tp erased to", debug) {
490490

491491
tp match {
492-
case tp @ AppliedType(tycon, args) =>
493-
if tycon.typeSymbol.isPatternBound then return WildcardType
492+
case tp @ AppliedType(tycon, args) if tycon.typeSymbol.isPatternBound =>
493+
WildcardType
494494

495+
case tp @ AppliedType(tycon, args) =>
495496
val args2 =
496497
if (tycon.isRef(defn.ArrayClass)) args.map(arg => erase(arg, inArray = true, isValue = false))
497498
else args.map(arg => erase(arg, inArray = false, isValue = false))

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,11 +1002,10 @@ trait Implicits:
10021002
if (argument.isEmpty) i"missing implicit parameter of type $pt after typer at phase ${ctx.phase.phaseName}"
10031003
else i"type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}")
10041004

1005-
if pt.unusableForInference
1006-
|| !argument.isEmpty && argument.tpe.unusableForInference
1007-
then return NoMatchingImplicitsFailure
1005+
val usableForInference = !pt.unusableForInference
1006+
&& (argument.isEmpty || !argument.tpe.unusableForInference)
10081007

1009-
val result0 =
1008+
val result0 = if usableForInference then
10101009
// If we are searching implicits when resolving an import symbol, start the search
10111010
// in the first enclosing context that does not have the same scope and owner as the current
10121011
// context. Without that precaution, an eligible implicit in the current scope
@@ -1023,7 +1022,7 @@ trait Implicits:
10231022
catch case ce: CyclicReference =>
10241023
ce.inImplicitSearch = true
10251024
throw ce
1026-
end result0
1025+
else NoMatchingImplicitsFailure
10271026

10281027
val result =
10291028
result0 match {
@@ -1052,7 +1051,7 @@ trait Implicits:
10521051
result
10531052
}
10541053
else result
1055-
case NoMatchingImplicitsFailure =>
1054+
case NoMatchingImplicitsFailure if usableForInference =>
10561055
SearchFailure(new NoMatchingImplicits(pt, argument, ctx.typerState.constraint), span)
10571056
case _ =>
10581057
result0

0 commit comments

Comments
 (0)