@@ -167,33 +167,36 @@ object Inferencing {
167167
168168 private var toMaximize : List [TypeVar ] = Nil
169169
170- def apply (x : Boolean , tp : Type ): Boolean = tp.dealias match {
171- case _ : WildcardType | _ : ProtoType =>
172- false
173- case tvar : TypeVar if ! tvar.isInstantiated =>
174- force.appliesTo(tvar)
175- && ctx.typerState.constraint.contains(tvar)
176- && {
177- val direction = instDirection(tvar.origin)
178- if minimizeSelected then
179- if direction <= 0 && tvar.hasNonWildcardLowerBound then
170+ def apply (x : Boolean , tp : Type ): Boolean =
171+ try tp.dealias match
172+ case _ : WildcardType | _ : ProtoType =>
173+ false
174+ case tvar : TypeVar if ! tvar.isInstantiated =>
175+ force.appliesTo(tvar)
176+ && ctx.typerState.constraint.contains(tvar)
177+ && {
178+ val direction = instDirection(tvar.origin)
179+ if minimizeSelected then
180+ if direction <= 0 && tvar.hasNonWildcardLowerBound then
181+ instantiate(tvar, fromBelow = true )
182+ else if direction >= 0 && tvar.hasNonWildcardUpperBound then
183+ instantiate(tvar, fromBelow = false )
184+ // else hold off instantiating unbounded unconstrained variable
185+ else if direction != 0 then
186+ instantiate(tvar, fromBelow = direction < 0 )
187+ else if variance >= 0 && (force.ifBottom == IfBottom .ok || tvar.hasLowerBound) then
180188 instantiate(tvar, fromBelow = true )
181- else if direction >= 0 && tvar.hasNonWildcardUpperBound then
182- instantiate(tvar, fromBelow = false )
183- // else hold off instantiating unbounded unconstrained variable
184- else if direction != 0 then
185- instantiate(tvar, fromBelow = direction < 0 )
186- else if variance >= 0 && (force.ifBottom == IfBottom .ok || tvar.hasLowerBound) then
187- instantiate(tvar, fromBelow = true )
188- else if variance >= 0 && force.ifBottom == IfBottom .fail then
189- return false
190- else
191- toMaximize = tvar :: toMaximize
192- foldOver(x, tvar)
193- }
194- case tp =>
195- foldOver(x, tp)
196- }
189+ else if variance >= 0 && force.ifBottom == IfBottom .fail then
190+ return false
191+ else
192+ toMaximize = tvar :: toMaximize
193+ foldOver(x, tvar)
194+ }
195+ case tp =>
196+ foldOver(x, tp)
197+ catch case ex : Throwable =>
198+ handleRecursive(" traverse " , s " ${tp.show}" , ex)
199+
197200
198201 def process (tp : Type ): Boolean =
199202 // Maximize type vars in the order they were visited before */
0 commit comments