diff options
author | Martin Odersky <odersky@gmail.com> | 2013-04-10 10:09:06 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-04-10 10:09:06 +0200 |
commit | 1034d4e420c2b0724945486f341c53a07e6a90e0 (patch) | |
tree | 0d06fb6ab5591e8c56053c737184130bacf2641d /src/dotty/tools/dotc/core/Types.scala | |
parent | ac8b319ed4738b2200350adb3943eb558157e1b7 (diff) | |
download | dotty-1034d4e420c2b0724945486f341c53a07e6a90e0.tar.gz dotty-1034d4e420c2b0724945486f341c53a07e6a90e0.tar.bz2 dotty-1034d4e420c2b0724945486f341c53a07e6a90e0.zip |
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 17 |
1 files changed, 13 insertions, 4 deletions
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") |