Skip to content

Commit

Permalink
Preserve kind of relativeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Jan 5, 2021
1 parent 69b04d1 commit eadc357
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Types.scala
Expand Up @@ -2438,7 +2438,7 @@ trait Types


// interpret symbol's info in terms of the type's prefix and type args
protected def relativeInfo: Type = appliedType(sym.info.asSeenFrom(pre, sym.owner), argsOrDummies)
protected def relativeInfo: Type = appliedType(sym.info.asSeenFrom(pre, sym.owner), args)

// @M: propagate actual type params (args) to `tp`, by replacing
// formal type parameters with actual ones. If tp is higher kinded,
Expand Down
15 changes: 8 additions & 7 deletions src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
Expand Up @@ -345,17 +345,18 @@ private[internal] trait TypeMaps {
val tp1 = mapOver(tp)
if (variance.isInvariant) tp1
else tp1 match {
case TypeRef(_, sym, typeArgs) if tparams.contains(sym) && occurCount(sym) == 1 =>
case TypeRef(pre, sym, args) if tparams.contains(sym) && occurCount(sym) == 1 =>
val repl = if (variance.isPositive) dropSingletonType(tp1.upperBound) else tp1.lowerBound
def msg = {
val word = if (variance.isPositive) "upper" else "lower"
s"Widened lone occurrence of $tp1 inside existential to $word bound"
}

val widened = if (variance.isPositive) dropSingletonType(tp1.upperBound) else tp1.lowerBound
if (widened.typeSymbol.isBottomClass || anyContains.collect(widened)) tp1
else debuglogResult(msg)(appliedType(genPolyType(sym.typeParams, widened), typeArgs))
case other =>
other
if (!repl.typeSymbol.isBottomClass && ! anyContains.collect(repl))
debuglogResult(msg)(repl)
else
tp1
case _ =>
tp1
}
}
override def mapOver(tp: Type): Type = tp match {
Expand Down

0 comments on commit eadc357

Please sign in to comment.