Skip to content

Commit aaff621

Browse files
committed
Alternative fix
The original fix made run/hmap-covariant fail because a type variable representing a dependent result parameter was instantiated. Trying something else now.
1 parent 053cd23 commit aaff621

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
159159
case tp1 => tp1
160160
}
161161
case tp: TypeParamRef =>
162-
typerState.constraint.typeVarOfParam(tp) orElse tp
162+
if (tp.paramName.is(DepParamName)) {
163+
val bounds = ctx.typeComparer.bounds(tp)
164+
if (bounds.lo.isRef(defn.NothingClass)) bounds.hi else bounds.lo
165+
}
166+
else typerState.constraint.typeVarOfParam(tp) orElse tp
163167
case _: ThisType | _: BoundType | NoPrefix =>
164168
tp
165169
case tp: RefinedType =>
@@ -170,9 +174,6 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
170174
simplify(l, theMap) & simplify(r, theMap)
171175
case OrType(l, r) =>
172176
simplify(l, theMap) | simplify(r, theMap)
173-
case tp: TypeVar if tp.origin.paramName.is(DepParamName) =>
174-
val effectiveVariance = if (theMap == null) 1 else theMap.variance
175-
tp.instanceOpt orElse tp.instantiate(fromBelow = effectiveVariance != -1)
176177
case _ =>
177178
(if (theMap != null) theMap else new SimplifyMap).mapOver(tp)
178179
}

0 commit comments

Comments
 (0)