@@ -56,17 +56,18 @@ class TreeChecker extends Phase with SymTransformer {
5656
5757 def isValidJVMMethodName (name : Name ) = name.toString.forall(isValidJVMMethodChar)
5858
59- def printError (str : String )(implicit ctx : Context ) = {
60- ctx.echo(Console .RED + " [error] " + Console .WHITE + str)
61- }
62-
6359 val NoSuperClass = Trait | Package
6460
6561 def testDuplicate (sym : Symbol , registry : mutable.Map [String , Symbol ], typ : String )(implicit ctx : Context ) = {
6662 val name = sym.fullName.mangledString
67- if (this .flatClasses && registry.contains(name))
68- printError(s " $typ defined twice $sym ${sym.id} ${registry(name).id}" )
69- registry(name) = sym
63+ if (this .flatClasses) {
64+ registry.get(name) match {
65+ case Some (prev) =>
66+ assert(sym eq prev, i " $typ defined twice $sym ${sym.id} ${prev.id}" )
67+ case _ =>
68+ registry(name) = sym
69+ }
70+ }
7071 }
7172
7273 def checkCompanion (symd : SymDenotation )(implicit ctx : Context ): Unit = {
@@ -85,14 +86,13 @@ class TreeChecker extends Phase with SymTransformer {
8586 if (sym.isClass && ! sym.isAbsent) {
8687 val validSuperclass = sym.isPrimitiveValueClass || defn.syntheticCoreClasses.contains(sym) ||
8788 (sym eq defn.ObjectClass ) || (sym is NoSuperClass ) || (sym.asClass.superClass.exists)
88- if (! validSuperclass)
89- printError(s " $sym has no superclass set " )
9089
90+ assert(validSuperclass, i " $sym has no superclass set " )
9191 testDuplicate(sym, seenClasses, " class" )
9292 }
9393
9494 if (sym.is(Method ) && sym.is(Deferred ) && sym.is(Private ))
95- assert(false , s " $sym is both Deferred and Private " )
95+ assert(false , i " $sym is both Deferred and Private " )
9696
9797 checkCompanion(symd)
9898
0 commit comments