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 {
81
81
if (depVars.nonEmpty) instantiateSelected(tp, depVars.toList)
82
82
}
83
83
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.
86
87
*/
87
88
def couldInstantiateTypeVar (tp : Type )(using Context ): Boolean = tp.dealias match
88
89
case tvar : TypeVar
@@ -91,6 +92,14 @@ object Inferencing {
91
92
&& tvar.hasLowerBound =>
92
93
tvar.instantiate(fromBelow = true )
93
94
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)
94
103
case _ =>
95
104
false
96
105
You can’t perform that action at this time.
0 commit comments