Skip to content

Typos, better assertions, dead code #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,6 @@ object Trees {

def flatten[T >: Untyped](trees: List[Tree[T]]): List[Tree[T]] = {
var buf: ListBuffer[Tree[T]] = null
def add(tree: Tree[T]) = {
assert(!tree.isInstanceOf[Thicket[_]])
buf += tree
}
var xs = trees
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dead code

while (xs.nonEmpty) {
xs.head match {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object Constants {

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

def byteValue: Byte = tag match {
case ByteTag => value.asInstanceOf[Byte]
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ object Contexts {

/** Allocate and return next free superclass id */
private[core] def nextSuperId: Int = {
lastSuperId += 1;
lastSuperId += 1
if (lastSuperId >= classOfId.length) {
val tmp = new Array[ClassSymbol](classOfId.length * 2)
classOfId.copyToArray(tmp)
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ object Denotations {
*/
private def bringForward()(implicit ctx: Context): SingleDenotation = this match {
case denot: SymDenotation if ctx.stillValid(denot) =>
if (denot.exists) assert(ctx.runId > validFor.runId)
if (denot.exists) assert(ctx.runId > validFor.runId, s"denotation $denot invalid in run ${ctx.runId}. ValidFor: $validFor")
var d: SingleDenotation = denot
do {
d.validFor = Period(ctx.period.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId)
Expand Down Expand Up @@ -527,7 +527,7 @@ object Denotations {
while (!(cur.validFor contains currentPeriod)) {
cur = cur.nextInRun
cnt += 1
assert(cnt <= MaxPossiblePhaseId)
assert(cnt <= MaxPossiblePhaseId, "seems to be a loop in Denotations")
}
}
cur
Expand Down Expand Up @@ -704,7 +704,7 @@ object Denotations {
}

case class DenotUnion(denots1: PreDenotation, denots2: PreDenotation) extends PreDenotation {
assert(denots1.exists && denots2.exists)
assert(denots1.exists && denots2.exists, s"Union of non-existing denotations ($denots1) and ($denots2)")
def exists = true
def first = denots1.first
def toDenot(pre: Type)(implicit ctx: Context) =
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ object Flags {

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

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ object NameOps {
if (p >= 0)
(name drop (p + TRAIT_SETTER_SEPARATOR.length)).asTermName.setterToGetter
else {
assert(name endsWith SETTER_SUFFIX, name)
assert(name.endsWith(SETTER_SUFFIX), name + " is referenced as a setter but has wrong name format")
name.take(name.length - SETTER_SUFFIX.length).asTermName
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ object Names {
private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = {
var i = 0
while ((i < len) && (chrs(index + i) == cs(offset + i)))
i += 1;
i += 1
i == len
}

Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/Scopes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ object Scopes {
if (e1 == e)
hashTable(index) = e.tail
else {
while (e1.tail != e) e1 = e1.tail;
while (e1.tail != e) e1 = e1.tail
e1.tail = e.tail
}
}
Expand All @@ -243,7 +243,7 @@ object Scopes {
final def unlink(sym: Symbol)(implicit ctx: Context): Unit = {
var e = lookupEntry(sym.name)
while (e ne null) {
if (e.sym == sym) unlink(e);
if (e.sym == sym) unlink(e)
e = lookupNextEntry(e)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ object SymDenotations {

// ----- denotation fields and accessors ------------------------------

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

/** The symbol asserted to have type ClassSymbol */
def classSymbol: ClassSymbol = symbol.asInstanceOf[ClassSymbol]
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/SymbolLoaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SymbolLoaders {
protected def enterNew(
owner: Symbol, member: Symbol,
completer: SymbolLoader, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = {
assert(scope.lookup(member.name) == NoSymbol, owner.fullName + "." + member.name)
assert(scope.lookup(member.name) == NoSymbol, s"${owner.fullName}.${member.name} already has a symbol")
owner.asClass.enter(member, scope)
member
}
Expand Down Expand Up @@ -120,7 +120,7 @@ class SymbolLoaders {
*/
def binaryOnly(owner: Symbol, name: String)(implicit ctx: Context): Boolean =
name == "package" &&
(owner.fullName == "scala" || owner.fullName == "scala.reflect")
(owner.fullName.toString == "scala" || owner.fullName.toString == "scala.reflect")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner.fullName == "scala" is always false, as Name checks for reference equality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


/** Initialize toplevel class and module symbols in `owner` from class path representation `classRep`
*/
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ object Symbols {
final def isType(implicit ctx: Context): Boolean = denot.isType
final def isClass: Boolean = isInstanceOf[ClassSymbol]

final def asTerm(implicit ctx: Context): TermSymbol = { assert(isTerm); asInstanceOf[TermSymbol] }
final def asType(implicit ctx: Context): TypeSymbol = { assert(isType); asInstanceOf[TypeSymbol] }
final def asTerm(implicit ctx: Context): TermSymbol = { assert(isTerm, s"asTerm called on not-a-Term $this" ); asInstanceOf[TermSymbol] }
final def asType(implicit ctx: Context): TypeSymbol = { assert(isType, s"isType called on not-a-Type $this"); asInstanceOf[TypeSymbol] }
final def asClass: ClassSymbol = asInstanceOf[ClassSymbol]

/** A unique, densely packed integer tag for each class symbol, -1
Expand All @@ -367,7 +367,7 @@ object Symbols {

/** This symbol entered into owner's scope (owner must be a class). */
final def entered(implicit ctx: Context): this.type = {
assert(this.owner.isClass) // !!! DEBUG
assert(this.owner.isClass, s"symbol ($this) entered the scope of non-class owner ${this.owner}") // !!! DEBUG
this.owner.asClass.enter(this)
if (this is Module) this.owner.asClass.enter(this.moduleClass)
this
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TyperState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TyperState(val reporter: Reporter) extends DotClass with Showable {
}

/** A fresh typer state with the same constraint as this one.
* @param isCommittable The constraint can be committed to an exclosing context.
* @param isCommittable The constraint can be committed to an enclosing context.
*/
def fresh(isCommittable: Boolean): TyperState = this

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ object Types {
val prefix: Type
val name: Name

assert(prefix.isValueType || (prefix eq NoPrefix))
assert(prefix.isValueType || (prefix eq NoPrefix), s"invalid prefix $prefix")

private[this] var lastDenotation: Denotation = _
private[this] var lastSymbol: Symbol = _
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
do {
b = readByte()
x = (x << 7) + (b & 0x7f)
} while ((b & 0x80) != 0L);
} while ((b & 0x80) != 0L)
x
}

Expand Down Expand Up @@ -158,7 +158,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* @return ...
*/
def until[T](end: Int, op: () => T): List[T] =
if (readIndex == end) List() else op() :: until(end, op);
if (readIndex == end) List() else op() :: until(end, op)

/** Perform operation <code>op</code> the number of
* times specified. Concatenate the results into a list.
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class PlainPrinter(_ctx: Context) extends Printer {
ctx.toTextRecursions -= 1
}
else {
recursionLimitExceeeded()
recursionLimitExceeded()
"..."
}

protected def recursionLimitExceeeded() = {
protected def recursionLimitExceeded() = {
ctx.warning("Exceeded recursion depth attempting to print type.")
(new Throwable).printStackTrace
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.annotation.switch

class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {

override protected def recursionLimitExceeeded() = {}
override protected def recursionLimitExceeded() = {}

protected val PrintableFlags = (ModifierFlags | Label | Module).toCommonFlags

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ trait Applications extends Compatibility { self: Typer =>
else if (cx.scope != cx.outer.scope &&
cx.denotNamed(methRef.name).hasAltWith(_.symbol == meth)) {
val denot = cx.denotNamed(getterName)
assert(denot.exists)
assert(denot.exists, s"non-existent getter denotation ($denot) for getter($getterName)")
cx.owner.thisType.select(getterName, denot)
} else findDefault(cx.outer)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/Attachment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ object Attachment {
private[Attachment] var next: Link[_] = null

final def pushAttachment[V](key: Key[V], value: V): Unit = {
assert(!getAttachment(key).isDefined)
assert(!getAttachment(key).isDefined, s"duplicate attachment for key $key")
next = new Link(key, value, next)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/HashSet.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.dotc.util

/** A hash set that allows some priviliged protected access to its internals
/** A hash set that allows some privileged protected access to its internals
*/
class HashSet[T >: Null <: AnyRef](initialCapacity: Int, loadFactor: Float = 0.25f) extends Set[T] with scala.collection.generic.Clearable {
private var used: Int = _
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/NameTransformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ object NameTransformer {
def decode(name0: String): String = {
//System.out.println("decode: " + name);//DEBUG
val name = if (name0.endsWith("<init>")) name0.substring(0, name0.length() - ("<init>").length()) + "this"
else name0;
else name0
var buf: StringBuilder = null
val len = name.length()
var i = 0
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/Positions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Positions {

/** A position indicates a range between a start offset and an end offset.
* Positions can be synthetic or source-derived. A source-derived position
* has in addition a pointlies somewhere between start and end. The point
* has in addition a point lies somewhere between start and end. The point
* is roughly where the ^ would go if an error was diagnosed at that position.
* All quantities are encoded opaquely in a Long.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/ShowPickled.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ object ShowPickled {
case SYMANNOT =>
printSymbolRef(); printTypeRef(); buf.until(end, printAnnotArgRef)
case ANNOTATEDtpe =>
printTypeRef(); buf.until(end, printAnnotInfoRef);
printTypeRef(); buf.until(end, printAnnotInfoRef)
case ANNOTINFO =>
printTypeRef(); buf.until(end, printAnnotArgRef)
case ANNOTARGARRAY =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/privates.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
trait T {
private def foo = 0;
private def foo = 0
private[this] def bar = 0

}
Expand Down