aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/TypeApplications.scala18
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
index 23c3f96cc..82051b66c 100644
--- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -11,6 +11,7 @@ import util.Stats._
import util.common._
import Names._
import NameOps._
+import NameKinds._
import Flags._
import StdNames.tpnme
import util.Positions.Position
@@ -391,9 +392,12 @@ class TypeApplications(val self: Type) extends AnyVal {
if (!args.exists(_.isInstanceOf[TypeBounds])) {
val followAlias = Config.simplifyApplications && {
dealiased.resType match {
- case AppliedType(tyconBody, _) =>
- sameLength(dealiased.typeParams, tyconBody.typeParams)
- // Reducing is safe for type inference, as kind arity of type constructor does not change
+ case AppliedType(tyconBody, dealiasedArgs) =>
+ // Reduction should not affect type inference when it's
+ // just eta-reduction (ignoring variance annotations).
+ // See i2201*.scala for examples where more aggressive
+ // reduction would break type inference.
+ dealiased.paramRefs == dealiasedArgs
case _ => false
}
}
@@ -461,11 +465,6 @@ class TypeApplications(val self: Type) extends AnyVal {
self
case _ =>
val v = tparam.paramVariance
- /* Not neeeded.
- if (v > 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.upper(self)
- else if (v < 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.lower(self)
- else
- */
TypeAlias(self, v)
}
@@ -507,13 +506,14 @@ class TypeApplications(val self: Type) extends AnyVal {
*/
final def baseTypeWithArgs(base: Symbol)(implicit ctx: Context): Type = ctx.traceIndented(s"btwa ${self.show} wrt $base", core, show = true) {
def default = self.baseTypeRef(base).appliedTo(baseArgInfos(base))
+ def isExpandedTypeParam(sym: Symbol) = sym.is(TypeParam) && sym.name.is(ExpandedName)
self match {
case tp: TypeRef =>
tp.info match {
case TypeBounds(_, hi) => hi.baseTypeWithArgs(base)
case _ => default
}
- case tp @ RefinedType(parent, name, _) if !tp.member(name).symbol.is(ExpandedTypeParam) =>
+ case tp @ RefinedType(parent, name, _) if !isExpandedTypeParam(tp.member(name).symbol) =>
tp.wrapIfMember(parent.baseTypeWithArgs(base))
case tp: TermRef =>
tp.underlying.baseTypeWithArgs(base)