Skip to content
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
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2224,9 +2224,11 @@ 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))
inferView(tree, pt) match {
if (ctx.mode.is(Mode.ImplicitsEnabled)) {
val nestedCtx = ctx.fresh.setNewTyperState()
inferView(tree, pt)(nestedCtx) 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 @@ -2236,6 +2238,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tree
else recover(failure)
}
}
else recover(NoImplicitMatches)
}

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

object Test {
def test = {
implicitly[collection.generic.CanBuildFrom[List[Int], Int, List[Int]]]
}
}