File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,16 @@ object Inferencing {
149149 tp match {
150150 case param : TypeParamRef =>
151151 val constraint = ctx.typerState.constraint
152- if (constraint.contains(param) &&
153- (ctx.typerComparer.fullUpperBound(param) frozen_<:< ctx.typecomparer.fullLowerBound(param))) {
154- typr.println(i " replace singleton $param := ${ctx.typeComparer.fullLowerBound(param)}" )
155- ctx.typerState.constraint = constraint.replace(param,
156- ctx.typeComparer.approximation(param, fromBelow = true ))
152+ constraint.entry(param) match {
153+ case TypeBounds (lo, hi)
154+ if constraint.lower(param).isEmpty && constraint.upper(param).isEmpty &&
155+ (hi frozen_<:< lo) =>
156+ // if lower or upper is nonEmpty, the full bounds can't be equal, since
157+ // common type params in lower and upper are eliminated through unification
158+ val inst = ctx.typeComparer.approximation(param, fromBelow = true )
159+ typr.println(i " replace singleton $param := $inst" )
160+ ctx.typerState.constraint = constraint.replace(param, inst)
161+ case _ =>
157162 }
158163 case _ =>
159164 }
You can’t perform that action at this time.
0 commit comments