File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,9 @@ object Inferencing {
8181 if (depVars.nonEmpty) instantiateSelected(tp, depVars.toList)
8282 }
8383
84- /** If `tp` is type variable with a lower bound in the current constraint,
85- * instantiate it from below.
84+ /** If `tp` is top-level type variable with a lower bound in the current constraint,
85+ * instantiate it from below. We also look for TypeVars whereever their instantiation
86+ * could uncover new type members.
8687 */
8788 def couldInstantiateTypeVar (tp : Type )(using Context ): Boolean = tp.dealias match
8889 case tvar : TypeVar
@@ -91,6 +92,14 @@ object Inferencing {
9192 && tvar.hasLowerBound =>
9293 tvar.instantiate(fromBelow = true )
9394 true
95+ case AppliedType (tycon, _) =>
96+ couldInstantiateTypeVar(tycon)
97+ case RefinedType (parent, _, _) =>
98+ couldInstantiateTypeVar(parent)
99+ case tp : AndOrType =>
100+ couldInstantiateTypeVar(tp.tp1) || couldInstantiateTypeVar(tp.tp2)
101+ case AnnotatedType (tp, _) =>
102+ couldInstantiateTypeVar(tp)
94103 case _ =>
95104 false
96105
You can’t perform that action at this time.
0 commit comments