File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import Flags._
10
10
import config .Config
11
11
import config .Printers .typr
12
12
import reporting .trace
13
+ import typer .ProtoTypes .newTypeVar
13
14
import StdNames .tpnme
14
15
15
16
/** Methods for adding constraints and solving them.
@@ -102,10 +103,12 @@ trait ConstraintHandling {
102
103
val dropWildcards = new ApproximatingTypeMap :
103
104
if ! isUpper then variance = - 1
104
105
def apply (t : Type ): Type = t match
105
- case t : WildcardType if ! allowWildcards =>
106
- t.optBounds match
107
- case TypeBounds (lo, hi) => range(lo, hi)
108
- case _ => range(defn.NothingType , defn.AnyType )
106
+ case t : WildcardType =>
107
+ if ! allowWildcards || ctx.mode.is(Mode .TypevarsMissContext ) then
108
+ val bounds = t.effectiveBounds
109
+ range(bounds.lo, bounds.hi)
110
+ else
111
+ newTypeVar(t.effectiveBounds)
109
112
case _ =>
110
113
mapOver(t)
111
114
// Narrow one of the bounds of type parameter `param`
Original file line number Diff line number Diff line change @@ -5051,6 +5051,11 @@ object Types {
5051
5051
5052
5052
/** Wildcard type, possibly with bounds */
5053
5053
abstract case class WildcardType (optBounds : Type ) extends CachedGroundType with TermType {
5054
+
5055
+ def effectiveBounds (using Context ): TypeBounds = optBounds match
5056
+ case bounds : TypeBounds => bounds
5057
+ case _ => TypeBounds .empty
5058
+
5054
5059
def derivedWildcardType (optBounds : Type )(using Context ): WildcardType =
5055
5060
if (optBounds eq this .optBounds) this
5056
5061
else if (! optBounds.exists) WildcardType
You can’t perform that action at this time.
0 commit comments