@@ -346,7 +346,7 @@ object Implicits {
346
346
* @param level The level where the reference was found
347
347
* @param tstate The typer state to be committed if this alternative is chosen
348
348
*/
349
- case class SearchSuccess (tree : Tree , ref : TermRef , level : Int )(val tstate : TyperState ) extends SearchResult with Showable
349
+ case class SearchSuccess (tree : Tree , ref : TermRef , level : Int )(val tstate : TyperState , val gstate : GADTMap ) extends SearchResult with Showable
350
350
351
351
/** A failed search */
352
352
case class SearchFailure (tree : Tree ) extends SearchResult {
@@ -880,6 +880,7 @@ trait Implicits { self: Typer =>
880
880
result0 match {
881
881
case result : SearchSuccess =>
882
882
result.tstate.commit()
883
+ ctx.gadt.restore(result.gstate)
883
884
implicits.println(i " success: $result" )
884
885
implicits.println(i " committing ${result.tstate.constraint} yielding ${ctx.typerState.constraint} in ${ctx.typerState}" )
885
886
result
@@ -1004,7 +1005,7 @@ trait Implicits { self: Typer =>
1004
1005
val generated2 =
1005
1006
if (cand.isExtension) Applications .ExtMethodApply (generated1).withType(generated1.tpe)
1006
1007
else generated1
1007
- SearchSuccess (generated2, ref, cand.level)(ctx.typerState)
1008
+ SearchSuccess (generated2, ref, cand.level)(ctx.typerState, ctx.gadt )
1008
1009
}
1009
1010
}}
1010
1011
@@ -1016,7 +1017,8 @@ trait Implicits { self: Typer =>
1016
1017
SearchFailure (new DivergingImplicit (cand.ref, pt.widenExpr, argument))
1017
1018
else {
1018
1019
val history = ctx.searchHistory.nest(cand, pt)
1019
- val result = typedImplicit(cand, contextual)(nestedContext().setNewTyperState().setSearchHistory(history))
1020
+ val result =
1021
+ typedImplicit(cand, contextual)(nestedContext().setNewTyperState().setFreshGADTBounds.setSearchHistory(history))
1020
1022
result match {
1021
1023
case res : SearchSuccess =>
1022
1024
ctx.searchHistory.defineBynameImplicit(pt.widenExpr, res)
@@ -1118,7 +1120,9 @@ trait Implicits { self: Typer =>
1118
1120
result match {
1119
1121
case _ : SearchFailure =>
1120
1122
SearchSuccess (ref(defn.Not_value ), defn.Not_value .termRef, 0 )(
1121
- ctx.typerState.fresh().setCommittable(true ))
1123
+ ctx.typerState.fresh().setCommittable(true ),
1124
+ ctx.gadt
1125
+ )
1122
1126
case _ : SearchSuccess =>
1123
1127
NoMatchingImplicitsFailure
1124
1128
}
@@ -1188,7 +1192,7 @@ trait Implicits { self: Typer =>
1188
1192
// other candidates need to be considered.
1189
1193
ctx.searchHistory.recursiveRef(pt) match {
1190
1194
case ref : TermRef =>
1191
- SearchSuccess (tpd.ref(ref).withPos(pos.startPos), ref, 0 )(ctx.typerState)
1195
+ SearchSuccess (tpd.ref(ref).withPos(pos.startPos), ref, 0 )(ctx.typerState, ctx.gadt )
1192
1196
case _ =>
1193
1197
val eligible =
1194
1198
if (contextual) ctx.implicits.eligible(wildProto)
@@ -1428,7 +1432,7 @@ final class SearchRoot extends SearchHistory {
1428
1432
implicitDictionary.get(tpe) match {
1429
1433
case Some ((ref, _)) =>
1430
1434
implicitDictionary.put(tpe, (ref, result.tree))
1431
- SearchSuccess (tpd.ref(ref).withPos(result.tree.pos), result.ref, result.level)(result.tstate)
1435
+ SearchSuccess (tpd.ref(ref).withPos(result.tree.pos), result.ref, result.level)(result.tstate, result.gstate )
1432
1436
case None => result
1433
1437
}
1434
1438
}
@@ -1529,7 +1533,7 @@ final class SearchRoot extends SearchHistory {
1529
1533
1530
1534
val blk = Block (classDef :: inst :: Nil , res)
1531
1535
1532
- success.copy(tree = blk)(success.tstate)
1536
+ success.copy(tree = blk)(success.tstate, success.gstate )
1533
1537
}
1534
1538
}
1535
1539
}
0 commit comments