diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Applications.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Implicits.scala | 1 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 | ||||
-rw-r--r-- | tests/neg/i2030.scala | 5 | ||||
-rw-r--r-- | tests/run/builder.check | 2 | ||||
-rw-r--r-- | tests/run/builder.scala | 12 |
6 files changed, 14 insertions, 10 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index e9df12b42..222717e7e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1384,7 +1384,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic => else WildcardType) val commonFormal = defn.FunctionOf(commonParamTypes, WildcardType) overload.println(i"pretype arg $arg with expected type $commonFormal") - pt.typedArg(arg, commonFormal) + pt.typedArg(arg, commonFormal)(ctx.addMode(Mode.ImplicitsEnabled)) } } } diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index d5afae90c..759cc62e9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -496,6 +496,7 @@ trait Implicits { self: Typer => || (to isRef defn.UnitClass) || (from.tpe isRef defn.NothingClass) || (from.tpe isRef defn.NullClass) + || !(ctx.mode is Mode.ImplicitsEnabled) || (from.tpe eq NoPrefix)) NoImplicitMatches else try inferImplicit(to.stripTypeVar.widenExpr, from, from.pos) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 33e320ce5..57e3c1b88 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2023,7 +2023,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit // try an implicit conversion inferView(tree, pt) match { case SearchSuccess(inferred, _, _, _) => - adapt(inferred, pt) + adapt(inferred, pt)(ctx.retractMode(Mode.ImplicitsEnabled)) case failure: SearchFailure => if (pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits]) tree else err.typeMismatch(tree, pt, failure) diff --git a/tests/neg/i2030.scala b/tests/neg/i2030.scala new file mode 100644 index 000000000..2d049f4e6 --- /dev/null +++ b/tests/neg/i2030.scala @@ -0,0 +1,5 @@ +// This used to take ~12s, the check should be that +// it runs in reasonable time (i.e. instantaneous). +object a { + val x: String | Int = 'a // error +} diff --git a/tests/run/builder.check b/tests/run/builder.check index 48f7d9253..04048dfcc 100644 --- a/tests/run/builder.check +++ b/tests/run/builder.check @@ -1 +1 @@ -Table(Row(Cell(A1), Cell(B1)), Row(Cell(A2), Cell(B2))) +Table(Row(Cell(top left), Cell(top right)), Row(Cell(botttom left), Cell(bottom right))) diff --git a/tests/run/builder.scala b/tests/run/builder.scala index 532a95071..d09e9f2c8 100644 --- a/tests/run/builder.scala +++ b/tests/run/builder.scala @@ -12,9 +12,7 @@ class Row { override def toString = cells.mkString("Row(", ", ", ")") } -class Cell(elem: String) { - override def toString = s"Cell($elem)" -} +case class Cell(elem: String) object Test { @@ -36,12 +34,12 @@ object Test { val data = table { row { - cell("A1") - cell("B1") + cell("top left") + cell("top right") } row { - cell("A2") - cell("B2") + cell("botttom left") + cell("bottom right") } } |