diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 20:12:25 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:04 +0200 |
commit | 1e48758ad5c100a7dd4d1a5b846ef5ff37e37721 (patch) | |
tree | fd5e516a574cd392002995f9ea17e2ee9d4ed801 /src/dotty/tools/dotc/core/TypeApplications.scala | |
parent | 65c26bacbba91850922cfffabfbc6847102bc489 (diff) | |
download | dotty-1e48758ad5c100a7dd4d1a5b846ef5ff37e37721.tar.gz dotty-1e48758ad5c100a7dd4d1a5b846ef5ff37e37721.tar.bz2 dotty-1e48758ad5c100a7dd4d1a5b846ef5ff37e37721.zip |
Refactor handling of unpickled type params
Under the new hk scheme we discovered that type parameters
are sometimes unpickled in the wrong order. The fault was always
present but the previous hk schemes were somehow lenient
enough in their subtyping rules to not discover the problem.
E.g., when reading Coder.scala, dotc believed that parameter
`A` of `TraversableOnce#BufferedCanBuildFrom` is higher-kinded
and parameter `CC` is first-order where the opposite is true.
This commit hardens the way we read type parameters in order
to make this swap impossible by design.
- Revert auto-healing in derivedAppliedType
The healing hid a real error about order of type parameters
in Scala2 unpickling which was fixed in the previous commits.
The healing caused Map.scala to fail because it is possible
that type parameters are mis-prediced to be Nil in an F-bounded
context.
- Smallish fixes to type applications
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 94e09eaf0..274fc8ff8 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -4,7 +4,7 @@ package core import Types._ import Contexts._ import Symbols._ -import SymDenotations.TypeParamsCompleter +import SymDenotations.{LazyType, TypeParamsCompleter} import Decorators._ import util.Stats._ import util.common._ @@ -191,7 +191,8 @@ object TypeApplications { else { def bounds(tparam: MemberBinding) = tparam match { case tparam: Symbol => tparam.infoOrCompleter - case tparam: RefinedType => tparam.memberBounds + case tparam: RefinedType if !Config.newHK => tparam.memberBounds + case tparam: LambdaParam => tparam.memberBounds } args.zipWithConserve(tparams)((arg, tparam) => arg.etaExpandIfHK(bounds(tparam))) } @@ -380,7 +381,7 @@ class TypeApplications(val self: Type) extends AnyVal { case self: WildcardType => self.optBounds.knownHK case self: PolyParam => self.underlying.knownHK case self: TypeProxy => self.underlying.knownHK - case NoType => 0 + case NoType | _: LazyType => 0 case _ => -1 } @@ -742,7 +743,7 @@ class TypeApplications(val self: Type) extends AnyVal { self.derivedTypeBounds(self.lo, self.hi.appliedTo(args)) case self: LazyRef => LazyRef(() => self.ref.appliedTo(args, typParams)) - case _ if typParams.nonEmpty && typParams.head.isInstanceOf[LambdaParam] => + case _ if typParams.isEmpty || typParams.head.isInstanceOf[LambdaParam] => HKApply(self, args) case _ => matchParams(self, typParams, args) match { |