Skip to content

Revert "Fix #3348: use a new typeState in inferView" #3370

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ trait Implicits { self: Typer =>
assert(!ctx.isAfterTyper,
if (argument.isEmpty) i"missing implicit parameter of type $pt after typer"
else i"type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}")
val prevConstr = ctx.typerState.constraint
trace(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) {
assert(!pt.isInstanceOf[ExprType])
val isearch =
Expand Down Expand Up @@ -737,7 +736,6 @@ trait Implicits { self: Typer =>
}
else result
case _ =>
assert(prevConstr eq ctx.typerState.constraint)
result
}
}
Expand Down
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2224,11 +2224,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
if (isFullyDefined(wtp, force = ForceDegree.all) &&
ctx.typerState.constraint.ne(prevConstraint)) adapt(tree, pt)
else err.typeMismatch(tree, pt, failure)
if (ctx.mode.is(Mode.ImplicitsEnabled)) {
val nestedCtx = ctx.fresh.setNewTyperState()
inferView(tree, pt)(nestedCtx) match {
if (ctx.mode.is(Mode.ImplicitsEnabled))
inferView(tree, pt) match {
case SearchSuccess(inferred, _, _, _) =>
nestedCtx.typerState.commit()
adapt(inferred, pt)(ctx.retractMode(Mode.ImplicitsEnabled))
case failure: SearchFailure =>
if (pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits])
Expand All @@ -2238,7 +2236,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tree
else recover(failure)
}
}
else recover(NoImplicitMatches)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i3348.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Test {
import Test.test
"Hello".toto // error
"Hello".toto
}

object Test {
Expand Down