@@ -56,17 +56,18 @@ class TreeChecker extends Phase with SymTransformer {
56
56
57
57
def isValidJVMMethodName (name : Name ) = name.toString.forall(isValidJVMMethodChar)
58
58
59
- def printError (str : String )(implicit ctx : Context ) = {
60
- ctx.echo(Console .RED + " [error] " + Console .WHITE + str)
61
- }
62
-
63
59
val NoSuperClass = Trait | Package
64
60
65
61
def testDuplicate (sym : Symbol , registry : mutable.Map [String , Symbol ], typ : String )(implicit ctx : Context ) = {
66
62
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
+ }
70
71
}
71
72
72
73
def checkCompanion (symd : SymDenotation )(implicit ctx : Context ): Unit = {
@@ -85,14 +86,13 @@ class TreeChecker extends Phase with SymTransformer {
85
86
if (sym.isClass && ! sym.isAbsent) {
86
87
val validSuperclass = sym.isPrimitiveValueClass || defn.syntheticCoreClasses.contains(sym) ||
87
88
(sym eq defn.ObjectClass ) || (sym is NoSuperClass ) || (sym.asClass.superClass.exists)
88
- if (! validSuperclass)
89
- printError(s " $sym has no superclass set " )
90
89
90
+ assert(validSuperclass, i " $sym has no superclass set " )
91
91
testDuplicate(sym, seenClasses, " class" )
92
92
}
93
93
94
94
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 " )
96
96
97
97
checkCompanion(symd)
98
98
0 commit comments