aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala5
-rw-r--r--src/dotty/tools/dotc/core/Types.scala25
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