diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-02 21:05:08 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:00 +0200 |
commit | e61b80ae4db8d2fdd7ed43a834f0de86d1edda15 (patch) | |
tree | 54942220a14acc444c6adc0d738a1d763b233642 /src/dotty | |
parent | e56bd1fe7a5d2a3821e8c44f0ce35b75be8d7d2b (diff) | |
download | dotty-e61b80ae4db8d2fdd7ed43a834f0de86d1edda15.tar.gz dotty-e61b80ae4db8d2fdd7ed43a834f0de86d1edda15.tar.bz2 dotty-e61b80ae4db8d2fdd7ed43a834f0de86d1edda15.zip |
Refinement of cycle avoidance
The previous fix caused 4 tests to fail under the old hk scheme.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 25 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 8fefdf7a7..124199678 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -92,6 +92,11 @@ trait SymDenotations { this: Context => explain("denotation is not a SymDenotation") } } + + /** An anonymous type denotation with an info `>: Nothing <: Any`. Used to + * avoid stackoverflows when computing members of TypeRefs + */ + lazy val anyTypeDenot = new JointRefDenotation(NoSymbol, TypeBounds.empty, Period.allInRun(ctx.runId)) } object SymDenotations { diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 78003d972..e4132bf4d 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1575,9 +1575,19 @@ object Types { } } - protected def asMemberOf(prefix: Type)(implicit ctx: Context) = - if (name.isShadowedName) prefix.nonPrivateMember(name.revertShadowed) - else prefix.member(name) + protected def asMemberOf(prefix: Type)(implicit ctx: Context): Denotation = { + // we might now get cycles over members that are in a refinement but that lack + // a symbol. Without the following precaution i974.scala stackoverflows when compiled + // with new hk scheme. + val saved = lastDenotation + if (name.isTypeName && lastDenotation != null && (lastDenotation.symbol ne NoSymbol)) + lastDenotation = ctx.anyTypeDenot + try + if (name.isShadowedName) prefix.nonPrivateMember(name.revertShadowed) + else prefix.member(name) + finally + if (lastDenotation eq ctx.anyTypeDenot) lastDenotation = saved + } /** (1) Reduce a type-ref `W # X` or `W { ... } # U`, where `W` is a wildcard type * to an (unbounded) wildcard type. @@ -2091,6 +2101,15 @@ object Types { throw new AssertionError(s"bad instantiation: $this") def checkInst(implicit ctx: Context): this.type = { + if (false && Config.newHK && refinedName.isHkArgName && refinedInfo.isInstanceOf[TypeAlias]) { + parent.stripTypeVar match { + case TypeApplications.TypeLambda(_, _) => + println(i"fshy: $this") + println(s"fshy: $this") + new Error().printStackTrace() + case _ => + } + } if (refinedName == tpnme.hkApplyOBS) parent.stripTypeVar match { case RefinedType(_, name, _) if name.isHkArgName => // ok |