aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-07-18 09:24:43 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-07-18 22:33:56 +0100
commit6c263447cfaea86979b1e41d687e312204430a33 (patch)
treed56188a69a2bfa6c4aeaef0c8e7c4010a2ca5ded /src/dotty/tools/dotc/core/TypeApplications.scala
parent8375e3a1ea9b0c13efb3188c844fe2a0c180c11e (diff)
downloaddotty-6c263447cfaea86979b1e41d687e312204430a33.tar.gz
dotty-6c263447cfaea86979b1e41d687e312204430a33.tar.bz2
dotty-6c263447cfaea86979b1e41d687e312204430a33.zip
HK reduction: Remove special-case for typerefs
The special case: case stripped: TypeRef => stripped.symbol.is(BaseTypeArg) is wrong because you might still want to reduce applications involving TypeRefs which are not base class parameters, like in: class Foo[A] type Alias[X] = Foo[X] val x: Alias[Int] = ??? `Alias` is a TypeRef so before this commit `Alias[Int]` was never reduced to `Foo[Int]`. It should have been: case stripped: TypeRef if stripped.symbol.is(BaseTypeArg) => true But even this is incorrect: it assumes that we can always safely reduce HK applications involving base class parameters, this is not the case when the parameter kind is different from the rhs kind as illustrated by `i1181c.scala`. We fix this by simply dropping the special case.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 314233709..cb11d3fdc 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -470,18 +470,13 @@ class TypeApplications(val self: Type) extends AnyVal {
case dealiased: TypeLambda =>
def tryReduce =
if (!args.exists(_.isInstanceOf[TypeBounds])) {
- val followAlias = stripped match {
- case stripped: TypeRef =>
- stripped.symbol.is(BaseTypeArg)
- case _ =>
- Config.simplifyApplications && {
- dealiased.resType match {
- case AppliedType(tyconBody, _) =>
- variancesConform(typParams, tyconBody.typeParams)
- // Reducing is safe for type inference, as kind of type constructor does not change
- case _ => false
- }
- }
+ val followAlias = Config.simplifyApplications && {
+ dealiased.resType match {
+ case AppliedType(tyconBody, _) =>
+ variancesConform(typParams, tyconBody.typeParams)
+ // Reducing is safe for type inference, as kind of type constructor does not change
+ case _ => false
+ }
}
if ((dealiased eq stripped) || followAlias) dealiased.instantiate(args)
else HKApply(self, args)