From ee44db864654d85bedbb380aa9ee62d74483a59e Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 23 Jan 2023 11:47:29 +0000 Subject: [PATCH] Fix early returns nested in trace Found by enabling the tracing config. --- .../src/dotty/tools/dotc/transform/patmat/Space.scala | 5 +++-- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 90310a385d0c..f4c4863d073d 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -489,9 +489,10 @@ class SpaceEngine(using Context) extends SpaceLogic { private def erase(tp: Type, inArray: Boolean = false, isValue: Boolean = false): Type = trace(i"$tp erased to", debug) { tp match { - case tp @ AppliedType(tycon, args) => - if tycon.typeSymbol.isPatternBound then return WildcardType + case tp @ AppliedType(tycon, args) if tycon.typeSymbol.isPatternBound => + WildcardType + case tp @ AppliedType(tycon, args) => val args2 = if (tycon.isRef(defn.ArrayClass)) args.map(arg => erase(arg, inArray = true, isValue = false)) else args.map(arg => erase(arg, inArray = false, isValue = false)) diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 3e0e7dd5879d..c04f9b990bc7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -1002,11 +1002,10 @@ trait Implicits: if (argument.isEmpty) i"missing implicit parameter of type $pt after typer at phase ${ctx.phase.phaseName}" else i"type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}") - if pt.unusableForInference - || !argument.isEmpty && argument.tpe.unusableForInference - then return NoMatchingImplicitsFailure + val usableForInference = !pt.unusableForInference + && (argument.isEmpty || !argument.tpe.unusableForInference) - val result0 = + val result0 = if usableForInference then // If we are searching implicits when resolving an import symbol, start the search // in the first enclosing context that does not have the same scope and owner as the current // context. Without that precaution, an eligible implicit in the current scope @@ -1023,7 +1022,7 @@ trait Implicits: catch case ce: CyclicReference => ce.inImplicitSearch = true throw ce - end result0 + else NoMatchingImplicitsFailure val result = result0 match { @@ -1052,7 +1051,7 @@ trait Implicits: result } else result - case NoMatchingImplicitsFailure => + case NoMatchingImplicitsFailure if usableForInference => SearchFailure(new NoMatchingImplicits(pt, argument, ctx.typerState.constraint), span) case _ => result0