Skip to content

Fix early returns nested in trace #16753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 5 additions & 6 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1023,7 +1022,7 @@ trait Implicits:
catch case ce: CyclicReference =>
ce.inImplicitSearch = true
throw ce
end result0
else NoMatchingImplicitsFailure

val result =
result0 match {
Expand Down Expand Up @@ -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
Expand Down