diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 19:48:40 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:01 +0200 |
commit | 31af865656ecc352c39ce919981e9b50d42a3237 (patch) | |
tree | 5c1f85e80e9e21f49a6c755a6c2415855212fa92 /src/dotty | |
parent | 0a5f8394a4a226bd3dcf9c966495e653a25ed7d2 (diff) | |
download | dotty-31af865656ecc352c39ce919981e9b50d42a3237.tar.gz dotty-31af865656ecc352c39ce919981e9b50d42a3237.tar.bz2 dotty-31af865656ecc352c39ce919981e9b50d42a3237.zip |
Fix condition for lambda abstracting in Namer
The previous condition could make a (derived) type a * type
for a little while even though it had type parameters. This
loophole caused collection/generic/MapFactory.scala and with
it compile-stdlib to fail.
Refinement for knownHK for PolyParams
pos test t2082.scala shows that knownHK can be constructed before
the binder PolyType of a PolyParam is initialized.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index fc8876d09..c0728a8fb 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -494,7 +494,9 @@ class TypeApplications(val self: Type) extends AnyVal { case self: SingletonType => -1 case self: TypeVar => self.origin.knownHK case self: WildcardType => self.optBounds.knownHK + case self: PolyParam => self.underlying.knownHK case self: TypeProxy => self.underlying.knownHK + case NoType => 0 case _ => -1 } @@ -666,13 +668,7 @@ class TypeApplications(val self: Type) extends AnyVal { instTop(tp.ref) case tp => inst.tyconIsHK = tp.isHK - val res = inst(tp) - tp match { - case tp: WildcardType => - println(s"inst $tp --> $res") - case _ => - } - res + inst(tp) } def isLazy(tp: Type): Boolean = tp.strictDealias match { diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 986a9c292..d3e97b492 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2765,7 +2765,11 @@ object Types { def paramName = binder.paramNames(paramNum) - override def underlying(implicit ctx: Context): Type = binder.paramBounds(paramNum) + override def underlying(implicit ctx: Context): Type = { + val bounds = binder.paramBounds + if (bounds == null) NoType // this can happen if the PolyType is not initialized yet + else bounds(paramNum) + } // no customized hashCode/equals needed because cycle is broken in PolyType override def toString = s"PolyParam($paramName)" diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 7982f288d..bc8f8e281 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -935,7 +935,7 @@ class Namer { typer: Typer => //val toParameterize = tparamSyms.nonEmpty && !isDerived //val needsLambda = sym.allOverriddenSymbols.exists(_ is HigherKinded) && !isDerived def abstracted(tp: Type): Type = - if (tparamSyms.nonEmpty && !isDerived) tp.LambdaAbstract(tparamSyms) + if (tparamSyms.nonEmpty && !tp.isHK) tp.LambdaAbstract(tparamSyms) //else if (toParameterize) tp.parameterizeWith(tparamSyms) else tp |