diff options
author | odersky <odersky@gmail.com> | 2016-07-19 17:58:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-19 17:58:11 +0200 |
commit | 2193100a4617033d75f0b924a5347a02d5e8481d (patch) | |
tree | a97f77c04e75f0740a27215fd2f4a9cb1d8aaf83 | |
parent | 5d6c1020e0dd24c10e2a5827f5b7a89bfa925e09 (diff) | |
parent | 6c263447cfaea86979b1e41d687e312204430a33 (diff) | |
download | dotty-2193100a4617033d75f0b924a5347a02d5e8481d.tar.gz dotty-2193100a4617033d75f0b924a5347a02d5e8481d.tar.bz2 dotty-2193100a4617033d75f0b924a5347a02d5e8481d.zip |
Merge pull request #1400 from dotty-staging/fix/hk-reduce-typerefs
HK reduction: Remove special-case for typerefs
-rw-r--r-- | src/dotty/tools/dotc/config/Config.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 19 | ||||
-rw-r--r-- | tests/pos/i1181b.scala | 11 | ||||
-rw-r--r-- | tests/pos/i1181c.scala | 11 |
4 files changed, 31 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala index a50945108..0949d7fee 100644 --- a/src/dotty/tools/dotc/config/Config.scala +++ b/src/dotty/tools/dotc/config/Config.scala @@ -98,9 +98,8 @@ object Config { final val splitProjections = false /** If this flag is on, always rewrite an application `S[Ts]` where `S` is an alias for - * `[Xs] -> U` to `[Xs := Ts]U`. If this flag is off, the rewriting is only done if `S` is a - * reference to an instantiated parameter. Turning this flag on was observed to - * give a ~6% speedup on the JUnit test suite. + * `[Xs] -> U` to `[Xs := Ts]U`. + * Turning this flag on was observed to give a ~6% speedup on the JUnit test suite. */ final val simplifyApplications = true 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) diff --git a/tests/pos/i1181b.scala b/tests/pos/i1181b.scala new file mode 100644 index 000000000..7694aed0b --- /dev/null +++ b/tests/pos/i1181b.scala @@ -0,0 +1,11 @@ +class Foo[A] + +object Test { + def foo[M[_,_]](x: M[Int,Int]) = x + + type Alias[X,Y] = Foo[X] + val x: Alias[Int,Int] = new Foo[Int] + + foo[Alias](x) // ok + foo(x) +} diff --git a/tests/pos/i1181c.scala b/tests/pos/i1181c.scala new file mode 100644 index 000000000..940629259 --- /dev/null +++ b/tests/pos/i1181c.scala @@ -0,0 +1,11 @@ +class Foo[A] + +trait Bar[DD[_,_]] { + val x: DD[Int, Int] +} + +trait Baz extends Bar[[X,Y] -> Foo[X]] { + def foo[M[_,_]](x: M[Int, Int]) = x + + foo(x) +} |