Skip to content

Commit 340ec61

Browse files
committed
Merge pull request #37 from DarkDimius/assertions
Typos, better assertions, dead code
2 parents 356dd4b + 2b4e765 commit 340ec61

23 files changed

+30
-34
lines changed

src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,6 @@ object Trees {
787787

788788
def flatten[T >: Untyped](trees: List[Tree[T]]): List[Tree[T]] = {
789789
var buf: ListBuffer[Tree[T]] = null
790-
def add(tree: Tree[T]) = {
791-
assert(!tree.isInstanceOf[Thicket[_]])
792-
buf += tree
793-
}
794790
var xs = trees
795791
while (xs.nonEmpty) {
796792
xs.head match {

src/dotty/tools/dotc/core/Constants.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ object Constants {
8585

8686
def booleanValue: Boolean =
8787
if (tag == BooleanTag) value.asInstanceOf[Boolean]
88-
else throw new Error("value " + value + " is not a boolean");
88+
else throw new Error("value " + value + " is not a boolean")
8989

9090
def byteValue: Byte = tag match {
9191
case ByteTag => value.asInstanceOf[Byte]

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ object Contexts {
411411

412412
/** Allocate and return next free superclass id */
413413
private[core] def nextSuperId: Int = {
414-
lastSuperId += 1;
414+
lastSuperId += 1
415415
if (lastSuperId >= classOfId.length) {
416416
val tmp = new Array[ClassSymbol](classOfId.length * 2)
417417
classOfId.copyToArray(tmp)

src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ object Denotations {
466466
*/
467467
private def bringForward()(implicit ctx: Context): SingleDenotation = this match {
468468
case denot: SymDenotation if ctx.stillValid(denot) =>
469-
if (denot.exists) assert(ctx.runId > validFor.runId)
469+
if (denot.exists) assert(ctx.runId > validFor.runId, s"denotation $denot invalid in run ${ctx.runId}. ValidFor: $validFor")
470470
var d: SingleDenotation = denot
471471
do {
472472
d.validFor = Period(ctx.period.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId)
@@ -527,7 +527,7 @@ object Denotations {
527527
while (!(cur.validFor contains currentPeriod)) {
528528
cur = cur.nextInRun
529529
cnt += 1
530-
assert(cnt <= MaxPossiblePhaseId)
530+
assert(cnt <= MaxPossiblePhaseId, "seems to be a loop in Denotations")
531531
}
532532
}
533533
cur
@@ -704,7 +704,7 @@ object Denotations {
704704
}
705705

706706
case class DenotUnion(denots1: PreDenotation, denots2: PreDenotation) extends PreDenotation {
707-
assert(denots1.exists && denots2.exists)
707+
assert(denots1.exists && denots2.exists, s"Union of non-existing denotations ($denots1) and ($denots2)")
708708
def exists = true
709709
def first = denots1.first
710710
def toDenot(pre: Type)(implicit ctx: Context) =

src/dotty/tools/dotc/core/Flags.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ object Flags {
166166

167167
/** The conjunction of all flags in given flag set */
168168
def allOf(flagss: FlagSet*) = {
169-
assert(flagss forall (_.numFlags == 1))
169+
assert(flagss forall (_.numFlags == 1), "Flags.allOf doesn't support flag " + flagss.find(_.numFlags != 1))
170170
FlagConjunction(union(flagss: _*).bits)
171171
}
172172

src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ object NameOps {
198198
if (p >= 0)
199199
(name drop (p + TRAIT_SETTER_SEPARATOR.length)).asTermName.setterToGetter
200200
else {
201-
assert(name endsWith SETTER_SUFFIX, name)
201+
assert(name.endsWith(SETTER_SUFFIX), name + " is referenced as a setter but has wrong name format")
202202
name.take(name.length - SETTER_SUFFIX.length).asTermName
203203
}
204204
}

src/dotty/tools/dotc/core/Names.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ object Names {
251251
private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = {
252252
var i = 0
253253
while ((i < len) && (chrs(index + i) == cs(offset + i)))
254-
i += 1;
254+
i += 1
255255
i == len
256256
}
257257

src/dotty/tools/dotc/core/Scopes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ object Scopes {
231231
if (e1 == e)
232232
hashTable(index) = e.tail
233233
else {
234-
while (e1.tail != e) e1 = e1.tail;
234+
while (e1.tail != e) e1 = e1.tail
235235
e1.tail = e.tail
236236
}
237237
}
@@ -243,7 +243,7 @@ object Scopes {
243243
final def unlink(sym: Symbol)(implicit ctx: Context): Unit = {
244244
var e = lookupEntry(sym.name)
245245
while (e ne null) {
246-
if (e.sym == sym) unlink(e);
246+
if (e.sym == sym) unlink(e)
247247
e = lookupNextEntry(e)
248248
}
249249
}

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ object SymDenotations {
754754

755755
// ----- denotation fields and accessors ------------------------------
756756

757-
if (initFlags is (Module, butNot = Package)) assert(name.isModuleClassName)
757+
if (initFlags is (Module, butNot = Package)) assert(name.isModuleClassName, s"module naming inconsistency: $name")
758758

759759
/** The symbol asserted to have type ClassSymbol */
760760
def classSymbol: ClassSymbol = symbol.asInstanceOf[ClassSymbol]

src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SymbolLoaders {
2828
protected def enterNew(
2929
owner: Symbol, member: Symbol,
3030
completer: SymbolLoader, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = {
31-
assert(scope.lookup(member.name) == NoSymbol, owner.fullName + "." + member.name)
31+
assert(scope.lookup(member.name) == NoSymbol, s"${owner.fullName}.${member.name} already has a symbol")
3232
owner.asClass.enter(member, scope)
3333
member
3434
}
@@ -120,7 +120,7 @@ class SymbolLoaders {
120120
*/
121121
def binaryOnly(owner: Symbol, name: String)(implicit ctx: Context): Boolean =
122122
name == "package" &&
123-
(owner.fullName == "scala" || owner.fullName == "scala.reflect")
123+
(owner.fullName.toString == "scala" || owner.fullName.toString == "scala.reflect")
124124

125125
/** Initialize toplevel class and module symbols in `owner` from class path representation `classRep`
126126
*/

0 commit comments

Comments
 (0)