@@ -76,8 +76,6 @@ class TyperState(r: Reporter) extends DotClass with Showable {
7676 /** Can this state be transitively committed until the top-level? */
7777 def isGlobalCommittable : Boolean = false
7878
79- def tryWithFallback [T ](op : => T )(fallback : => T )(implicit ctx : Context ): T = unsupported(" tryWithFallBack" )
80-
8179 override def toText (printer : Printer ): Text = " ImmutableTyperState"
8280
8381 /** A string showing the hashes of all nested mutable typerstates */
@@ -170,45 +168,6 @@ extends TyperState(r) {
170168 constraint = constraint.remove(poly)
171169 }
172170
173- /** Try operation `op`; if it produces errors, execute `fallback` with constraint and
174- * reporter as they were before `op` was executed. This is similar to `typer/tryEither`,
175- * but with one important difference: Any type variable instantiations produced by `op`
176- * are persisted even if `op` fails. This is normally not what one wants and therefore
177- * it is recommended to use
178- *
179- * tryEither { implicit ctx => op } { (_, _) => fallBack }
180- *
181- * instead of
182- *
183- * ctx.tryWithFallback(op)(fallBack)
184- *
185- * `tryWithFallback` is only used when an implicit parameter search fails
186- * and the whole expression is subsequently retype-checked with a Wildcard
187- * expected type (so as to allow an implicit conversion on the result and
188- * avoid over-constraining the implicit parameter search). In this case,
189- * the only type variables that might be falsely instantiated by `op` but
190- * not by `fallBack` are type variables in the typed expression itself, and
191- * these will be thrown away and new ones will be created on re-typing.
192- * So `tryWithFallback` is safe. It is also necessary because without it
193- * we do not propagate enough instantiation information into the implicit search
194- * and this might lead to a missing parameter type error. This is exhibited
195- * at several places in the test suite (for instance in `pos_typers`).
196- * Overall, this is rather ugly, but despite trying for 2 days I have not
197- * found a better solution.
198- */
199- override def tryWithFallback [T ](op : => T )(fallback : => T )(implicit ctx : Context ): T = {
200- val storeReporter = new StoreReporter (myReporter)
201- val savedReporter = myReporter
202- myReporter = storeReporter
203- val savedConstraint = myConstraint
204- val result = try op finally myReporter = savedReporter
205- if (! storeReporter.hasErrors) result
206- else {
207- myConstraint = savedConstraint
208- fallback
209- }
210- }
211-
212171 override def toText (printer : Printer ): Text = constraint.toText(printer)
213172
214173 override def hashesStr : String = hashCode.toString + " -> " + previous.hashesStr
0 commit comments