From 1034d4e420c2b0724945486f341c53a07e6a90e0 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 10 Apr 2013 10:09:06 +0200 Subject: Removing automatic legal prefix checking. It turned out this led to cycles in subtyping. We need to check for legal prefixes only for types that are declared or inferred in source. For the rest, we should assume that the type is OK. --- src/dotty/tools/dotc/core/Types.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 22ea23b52..7656835cf 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -901,10 +901,15 @@ object Types { lastDenotation.current } else { val d = loadDenot +/* need to do elsewhere as it leads to a cycle in subtyping here. if (d.exists && !d.symbol.isAliasType && !prefix.isLegalPrefix) { - val ex = new MalformedType(prefix, d) - if (ctx.checkPrefix) throw ex else ctx.log(ex.getMessage) + val ex = new MalformedType(prefix, d, prefix.memberNames(abstractTypeNameFilter)) + if (ctx.checkPrefix) { + ctx.printCreationTrace() + throw ex + } else ctx.log(ex.getMessage) } +*/ if (d.exists || ctx.phaseId == FirstPhaseId) d else // name has changed; try load in earlier phase and make current @@ -1710,8 +1715,12 @@ object Types { class TypeError(msg: String) extends Exception(msg) class FatalTypeError(msg: String) extends TypeError(msg) - class MalformedType(pre: Type, denot: Denotation) - extends FatalTypeError(s"malformed type: $pre is not a legal prefix for $denot") + + class MalformedType(pre: Type, denot: Denotation, absMembers: Set[Name]) + extends FatalTypeError( + s"""malformed type: $pre is not a legal prefix for $denot because it contains abstract type member${if (absMembers.size == 1) "" else "s"} ${absMembers.mkString(", ")}""" + .stripMargin) + class CyclicReference(val denot: SymDenotation) extends FatalTypeError(s"cyclic reference involving $denot") -- cgit v1.2.3