aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-19 12:41:32 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:07:27 +0200
commitb12edd1959450f5473cef095821b86400b959e8d (patch)
tree7456a3fadb3ec3ddc048359e6e44b017b53dcc8c /src/dotty/tools/dotc/core/TypeApplications.scala
parente2aa258c3781fa9ee62fa47dd3b1206b09588c17 (diff)
downloaddotty-b12edd1959450f5473cef095821b86400b959e8d.tar.gz
dotty-b12edd1959450f5473cef095821b86400b959e8d.tar.bz2
dotty-b12edd1959450f5473cef095821b86400b959e8d.zip
Allow to use safe substitution in LambdaAbstract
Needed to avoid cycles involving F-boundes hk-types when reading Scala2 collection classes with new hk-scheme.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 893bedeba..a40047c39 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -511,14 +511,22 @@ class TypeApplications(val self: Type) extends AnyVal {
* `this.Arg$i`.
*
* TypeBounds are lambda abstracting by lambda abstracting their upper bound.
+ *
+ * @param cycleParanoid If `true` don't force denotation of a TypeRef unless
+ * its name matches one of `boundSyms`. Needed to avoid cycles
+ * involving F-boundes hk-types when reading Scala2 collection classes
+ * with new hk-scheme.
*/
- def LambdaAbstract(boundSyms: List[Symbol])(implicit ctx: Context): Type = {
+ def LambdaAbstract(boundSyms: List[Symbol], cycleParanoid: Boolean = false)(implicit ctx: Context): Type = {
def expand(tp: Type) = {
val lambda = defn.lambdaTrait(boundSyms.map(_.variance))
val substitutedRHS = (rt: RefinedType) => {
val argRefs = boundSyms.indices.toList.map(i =>
RefinedThis(rt).select(tpnme.lambdaArgName(i)))
- tp.subst(boundSyms, argRefs).bounds.withVariance(1)
+ val substituted =
+ if (cycleParanoid) new ctx.SafeSubstMap(boundSyms, argRefs).apply(tp)
+ else tp.subst(boundSyms, argRefs)
+ substituted.bounds.withVariance(1)
}
val res = RefinedType(lambda.typeRef, tpnme.Apply, substitutedRHS)
//println(i"lambda abstract $self wrt $boundSyms%, % --> $res")