diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 19:44:55 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:01 +0200 |
commit | 68e73e854e04f7bea20a8c95637729bf6889e17d (patch) | |
tree | d05d50de6280e43199e65e1f2dcd97a2fb8f05ad /src | |
parent | 8e84fb013abeb613af4a3414b836f02140e2e866 (diff) | |
download | dotty-68e73e854e04f7bea20a8c95637729bf6889e17d.tar.gz dotty-68e73e854e04f7bea20a8c95637729bf6889e17d.tar.bz2 dotty-68e73e854e04f7bea20a8c95637729bf6889e17d.zip |
Restrict betaReduce to hk applications
Also, handle LazyRefs conservatively in isReferredTo
Without the change we risk losing RecTypes because
it looks like nobody refers to them. This was observed
for pos/i974.scala.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 1700a9c9c..4f482f460 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -501,7 +501,7 @@ class TypeApplications(val self: Type) extends AnyVal { false } - /** Dealias type if it can be done without forcing anything */ + /** Dealias type if it can be done without forcing the TypeRef's info */ def safeDealias(implicit ctx: Context): Type = self match { case self: TypeRef if self.denot.exists && self.symbol.isAliasType => self.info.bounds.hi.stripTypeVar.safeDealias @@ -509,6 +509,14 @@ class TypeApplications(val self: Type) extends AnyVal { self } + /** Dealias type if it can be done without forcing anything */ + def saferDealias(implicit ctx: Context): Type = self match { + case self: TypeRef if self.denot.exists && self.symbol.isAliasType && self.symbol.isCompleted => + self.info.bounds.hi.stripTypeVar.safeDealias + case _ => + self + } + /** Replace references to type parameters with references to hk arguments `this.$hk_i` * Care is needed not to cause cyclic reference errors, hence `SafeSubstMap`. */ diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index ab5c795e3..7a050c412 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2135,7 +2135,7 @@ object Types { } def betaReduce(implicit ctx: Context): Type = refinedInfo match { - case TypeAlias(alias) => + case TypeAlias(alias) if refinedName.isHkArgName => def instantiate(rt: RecType) = new TypeMap { def apply(t: Type) = t match { case TypeRef(RecThis(`rt`), `refinedName`) => alias @@ -2265,6 +2265,8 @@ object Types { tp match { case tp: TypeRef => apply(x, tp.prefix) case tp: RecThis => RecType.this eq tp.binder + case tp: LazyRef => true // Assume a reference to be safe. + // TODO: Check that all accumulators handle LazyRefs correctly case _ => foldOver(x, tp) } } |