From 1b97e9821de77a233b78e2ad2e7a402d083f34b8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 14 May 2009 16:03:45 +0000 Subject: Obeyed comment attached to checkMalformedSwitch... Obeyed comment attached to checkMalformedSwitch: "todo: it's now always false. Remove all code that depends on this switch." --- src/compiler/scala/tools/nsc/symtab/Types.scala | 27 +++++----------------- .../scala/tools/nsc/typechecker/Infer.scala | 2 +- 2 files changed, 7 insertions(+), 22 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index f66cc96e38..1f33b1b8a7 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -75,7 +75,6 @@ trait Types { var subtypeMillis = 0l private var explainSwitch = false - private var checkMalformedSwitch = false // todo: it's now always false. Remove all code that depends on this switch. private final val LogPendingSubTypesThreshold = 50 private final val LogPendingBaseTypesThreshold = 50 @@ -680,8 +679,6 @@ trait Types { var excluded = excludedFlags | DEFERRED var self: Type = null var continue = true - var savedCheckMalformedSwitch = checkMalformedSwitch - checkMalformedSwitch = false while (continue) { continue = false val bcs0 = baseClasses @@ -700,7 +697,6 @@ trait Types { sym.getFlag(PRIVATE | LOCAL) != (PRIVATE | LOCAL) || (bcs0.head.hasTransOwner(bcs.head)))) { if (name.isTypeName || stableOnly && sym.isStable) { - checkMalformedSwitch = savedCheckMalformedSwitch if (util.Statistics.enabled) findMemberMillis = findMemberMillis + currentTime - startTime return sym @@ -742,7 +738,6 @@ trait Types { } // while (!bcs.isEmpty) excluded = excludedFlags } // while (continue) - checkMalformedSwitch = savedCheckMalformedSwitch if (util.Statistics.enabled) findMemberMillis = findMemberMillis + currentTime - startTime if (members eq null) { @@ -1374,7 +1369,7 @@ trait Types { * @param args ... */ case class TypeRef(pre: Type, sym: Symbol, args: List[Type]) extends Type { -// assert(!checkMalformedSwitch || !sym.isAbstractType || pre.isStable || pre.isError) +// assert(!sym.isAbstractType || pre.isStable || pre.isError) // assert(!pre.isInstanceOf[ClassInfoType], this) // assert(!(sym hasFlag (PARAM | EXISTENTIAL)) || pre == NoPrefix, this) // assert(args.isEmpty || !sym.info.typeParams.isEmpty, this) @@ -2013,12 +2008,9 @@ A type's typeSymbol should never be inspected directly. var sym1 = rebind(pre, sym) val pre1 = removeSuper(pre, sym1) if (pre1 ne pre) sym1 = rebind(pre1, sym1) - if (checkMalformedSwitch && !pre1.isStable && !pre1.isError) - throw new MalformedType(pre, sym.nameString) - else { - class UniqueSingleType extends SingleType(pre1, sym1) with UniqueType - unique(new UniqueSingleType) - } + + class UniqueSingleType extends SingleType(pre1, sym1) with UniqueType + unique(new UniqueSingleType) } } @@ -2118,10 +2110,8 @@ A type's typeSymbol should never be inspected directly. if (pre1 ne pre) { if (sym1.isAbstractType) sym1 = rebind(pre1, sym1) typeRef(pre1, sym1, args) - } else if (checkMalformedSwitch && !pre.isStable && !pre.isError && - (sym1.isAbstractType /* || !pre.widen.typeSymbol.isStableClass*/)) { - throw new MalformedType(pre, sym1.nameString) - } else if (sym1.isClass && pre.isInstanceOf[CompoundType]) { + } + else if (sym1.isClass && pre.isInstanceOf[CompoundType]) { // sharpen prefix so that it is maximal and still contains the class. var p = pre.parents.reverse while (!p.isEmpty && p.head.member(sym1.name) != sym1) p = p.tail @@ -4466,11 +4456,6 @@ A type's typeSymbol should never be inspected directly. try { explainSwitch = true; op } finally { explainSwitch = s } } - def withoutMalformedChecks[T](op: => T): T = { - val s = checkMalformedSwitch - try { checkMalformedSwitch = false; op } finally { checkMalformedSwitch = s } - } - def objToAny(tp: Type): Type = if (!phase.erasedTypes && tp.typeSymbol == ObjectClass) AnyClass.tpe else tp diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 7169ee3094..6f1bd8a5d2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -374,7 +374,7 @@ trait Infer { case ex: MalformedType => if (settings.debug.value) ex.printStackTrace val sym2 = underlying(sym1) - val itype = withoutMalformedChecks(pre.memberType(sym2)) + val itype = pre.memberType(sym2) accessError("\n because its instance type "+itype+ (if ("malformed type: "+itype.toString==ex.msg) " is malformed" else " contains a "+ex.msg)) -- cgit v1.2.3