File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,19 @@ 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.
86
+ */
87
+ def couldInstantiateTypeVar (tp : Type )(using Context ): Boolean = tp.dealias match
88
+ case tvar : TypeVar
89
+ if ! tvar.isInstantiated
90
+ && ctx.typerState.constraint.contains(tvar)
91
+ && tvar.hasLowerBound =>
92
+ tvar.instantiate(fromBelow = true )
93
+ true
94
+ case _ =>
95
+ false
96
+
84
97
/** The accumulator which forces type variables using the policy encoded in `force`
85
98
* and returns whether the type is fully defined. The direction in which
86
99
* a type variable is instantiated is determined as follows:
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import config.Printers.typr
12
12
import ast .Trees ._
13
13
import NameOps ._
14
14
import ProtoTypes ._
15
- import Inferencing .isFullyDefined
15
+ import Inferencing .couldInstantiateTypeVar
16
16
import collection .mutable
17
17
import reporting ._
18
18
import Checking .{checkNoPrivateLeaks , checkNoWildcard }
@@ -160,7 +160,7 @@ trait TypeAssigner {
160
160
TryDynamicCallType
161
161
else if (qualType.isErroneous || name.toTermName == nme.ERROR )
162
162
UnspecifiedErrorType
163
- else if ! isFullyDefined (qualType, ForceDegree .none) && isFullyDefined(qualType, ForceDegree .failBottom ) then
163
+ else if couldInstantiateTypeVar (qualType) then
164
164
// try again with more defined qualifier type
165
165
selectionType(tree, qual1)
166
166
else if (name == nme.CONSTRUCTOR )
You can’t perform that action at this time.
0 commit comments