Skip to content

Commit 14187e2

Browse files
authored
Merge pull request #3763 from dotty-staging/ycheck
Make Ycheck stricter
2 parents 97a3290 + 814d61e commit 14187e2

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,12 @@ 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-
assert(false, s"$typ defined twice $sym ${sym.id} ${registry(name).id}")
63+
val isDuplicate = this.flatClasses && registry.contains(name)
64+
assert(!isDuplicate, s"$typ defined twice $sym ${sym.id} ${registry(name).id}")
6965
registry(name) = sym
7066
}
7167

@@ -85,14 +81,13 @@ class TreeChecker extends Phase with SymTransformer {
8581
if (sym.isClass && !sym.isAbsent) {
8682
val validSuperclass = sym.isPrimitiveValueClass || defn.syntheticCoreClasses.contains(sym) ||
8783
(sym eq defn.ObjectClass) || (sym is NoSuperClass) || (sym.asClass.superClass.exists)
88-
if (!validSuperclass)
89-
printError(s"$sym has no superclass set")
9084

85+
assert(validSuperclass, i"$sym has no superclass set")
9186
testDuplicate(sym, seenClasses, "class")
9287
}
9388

94-
if (sym.is(Method) && sym.is(Deferred) && sym.is(Private))
95-
assert(false, s"$sym is both Deferred and Private")
89+
val isDeferredAndPrivate = sym.is(Method) && sym.is(Deferred) && sym.is(Private)
90+
assert(!isDeferredAndPrivate, i"$sym is both Deferred and Private")
9691

9792
checkCompanion(symd)
9893

0 commit comments

Comments
 (0)