aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-06-24 15:29:04 +0200
committerMartin Odersky <odersky@gmail.com>2015-06-24 17:18:54 +0200
commitbb90c8457ab91e3c4cd707fa1a68e75e6dd96128 (patch)
tree87dfc63242533316d48a0658a50a769d8034e986
parent5395414a68bdcf682bbfc8de5d1c47e86fce708a (diff)
downloaddotty-bb90c8457ab91e3c4cd707fa1a68e75e6dd96128.tar.gz
dotty-bb90c8457ab91e3c4cd707fa1a68e75e6dd96128.tar.bz2
dotty-bb90c8457ab91e3c4cd707fa1a68e75e6dd96128.zip
setNewTyperState -> setExploreTyperState when computing shadoing implicits
Nothing will be committed here, so setExplore... is the right method to pick.
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 8a92eb726..f79288e74 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -421,6 +421,7 @@ 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
ctx.traceIndented(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) {
assert(!pt.isInstanceOf[ExprType])
val isearch =
@@ -435,6 +436,7 @@ trait Implicits { self: Typer =>
val deepPt = pt.deepenProto
if (deepPt ne pt) inferImplicit(deepPt, argument, pos) else result
case _ =>
+ assert(prevConstr eq ctx.typerState.constraint)
result
}
}
@@ -472,9 +474,11 @@ trait Implicits { self: Typer =>
/** Search a list of eligible implicit references */
def searchImplicits(eligible: List[TermRef], contextual: Boolean): SearchResult = {
+ val constr = ctx.typerState.constraint
/** Try to typecheck an implicit reference */
def typedImplicit(ref: TermRef)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(i"typed implicit $ref, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", implicits, show = true) {
+ assert(constr eq ctx.typerState.constraint)
var generated: Tree = tpd.ref(ref).withPos(pos)
if (!argument.isEmpty)
generated = typedUnadapted(
@@ -483,7 +487,7 @@ trait Implicits { self: Typer =>
val generated1 = adapt(generated, pt)
lazy val shadowing =
typed(untpd.Ident(ref.name) withPos pos.toSynthetic, funProto)
- (nestedContext.addMode(Mode.ImplicitShadowing).setNewTyperState)
+ (nestedContext.addMode(Mode.ImplicitShadowing).setExploreTyperState)
def refMatches(shadowing: Tree): Boolean =
ref.symbol == closureBody(shadowing).symbol || {
shadowing match {
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index a8e28b8c2..af6adb6a6 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1283,6 +1283,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case wtp: ExprType =>
adaptInterpolated(tree.withType(wtp.resultType), pt, original)
case wtp: ImplicitMethodType if constrainResult(wtp, pt) =>
+ val constr = ctx.typerState.constraint
def addImplicitArgs = {
def implicitArgError(msg: => String): Tree = {
ctx.error(msg, tree.pos.endPos)
@@ -1299,7 +1300,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
implicitArgError(d"no implicit argument of type $formal found for $where" + failure.postscript)
}
}
- if (args.exists(_.isEmpty)) tree
+ if (args.exists(_.isEmpty)) { assert(constr eq ctx.typerState.constraint); tree }
else adapt(tpd.Apply(tree, args), pt)
}
if ((pt eq WildcardType) || original.isEmpty) addImplicitArgs