aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-29 20:12:25 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:04 +0200
commit1e48758ad5c100a7dd4d1a5b846ef5ff37e37721 (patch)
treefd5e516a574cd392002995f9ea17e2ee9d4ed801 /src/dotty/tools/dotc/core/Types.scala
parent65c26bacbba91850922cfffabfbc6847102bc489 (diff)
downloaddotty-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/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index c23050c19..593dcb967 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1436,6 +1436,9 @@ object Types {
else computeDenot
}
+ /** Hook for adding debug check code when denotations are assigned */
+ final def checkDenot()(implicit ctx: Context) = {}
+
/** A second fallback to recompute the denotation if necessary */
private def computeDenot(implicit ctx: Context): Denotation = {
val savedEphemeral = ctx.typerState.ephemeral
@@ -1471,6 +1474,7 @@ object Types {
// Don't use setDenot here; double binding checks can give spurious failures after erasure
lastDenotation = d
+ checkDenot()
lastSymbol = d.symbol
checkedPeriod = ctx.period
}
@@ -1542,6 +1546,7 @@ object Types {
// additional checks that intercept `denot` can be added here
lastDenotation = denot
+ checkDenot()
lastSymbol = denot.symbol
checkedPeriod = Nowhere
}
@@ -3462,8 +3467,7 @@ object Types {
protected def derivedSuperType(tp: SuperType, thistp: Type, supertp: Type): Type =
tp.derivedSuperType(thistp, supertp)
protected def derivedAppliedType(tp: HKApply, tycon: Type, args: List[Type]): Type =
- if (tycon.typeParams.isEmpty) tycon
- else tp.derivedAppliedType(tycon, args)
+ tp.derivedAppliedType(tycon, args)
protected def derivedAndOrType(tp: AndOrType, tp1: Type, tp2: Type): Type =
tp.derivedAndOrType(tp1, tp2)
protected def derivedAnnotatedType(tp: AnnotatedType, underlying: Type, annot: Annotation): Type =