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._
1010import config .Config
1111import config .Printers .typr
1212import reporting .trace
13+ import typer .ProtoTypes .newTypeVar
1314import StdNames .tpnme
1415
1516/** Methods for adding constraints and solving them.
@@ -102,10 +103,12 @@ trait ConstraintHandling {
102103 val dropWildcards = new ApproximatingTypeMap :
103104 if ! isUpper then variance = - 1
104105 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)
109112 case _ =>
110113 mapOver(t)
111114 // Narrow one of the bounds of type parameter `param`
Original file line number Diff line number Diff line change @@ -5053,6 +5053,11 @@ object Types {
50535053
50545054 /** Wildcard type, possibly with bounds */
50555055 abstract case class WildcardType (optBounds : Type ) extends CachedGroundType with TermType {
5056+
5057+ def effectiveBounds (using Context ): TypeBounds = optBounds match
5058+ case bounds : TypeBounds => bounds
5059+ case _ => TypeBounds .empty
5060+
50565061 def derivedWildcardType (optBounds : Type )(using Context ): WildcardType =
50575062 if (optBounds eq this .optBounds) this
50585063 else if (! optBounds.exists) WildcardType
You can’t perform that action at this time.
0 commit comments