aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala33
-rw-r--r--src/dotty/tools/dotc/core/pickling/PickleBuffer.scala26
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala10
-rw-r--r--test/dotc/tests.scala1
5 files changed, 40 insertions, 32 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala b/src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala
index 60633370d..5de7ab0cc 100644
--- a/src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala
+++ b/src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala
@@ -83,6 +83,6 @@ class AbstractFileReader(val file: AbstractFile) {
/** skip next 'n' bytes
*/
- def skip(n: Int) { bp += n }
+ def skip(n: Int): Unit = { bp += n }
}
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 81bdc7809..f87d91597 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -56,7 +56,7 @@ class ClassfileParser(
|${Option(e.getMessage).getOrElse("")}""".stripMargin)
}
- private def parseHeader() {
+ private def parseHeader(): Unit = {
val magic = in.nextInt
if (magic != JAVA_MAGIC)
throw new IOException("class file '" + in.file + "' "
@@ -82,7 +82,7 @@ class ClassfileParser(
var sawPrivateConstructor = false
- def parseClass() {
+ def parseClass(): Unit = {
val jflags = in.nextChar
val isAnnotation = hasAnnotation(jflags)
val sflags = FlagTranslation.classFlags(jflags)
@@ -94,7 +94,7 @@ class ClassfileParser(
if (c != classRoot.symbol) mismatchError(c)
}
- addEnclosingTParams
+ addEnclosingTParams()
if (unpickleOrParseInnerClasses()) return
@@ -104,7 +104,14 @@ class ClassfileParser(
val superType = if (isAnnotation) { in.nextChar; defn.AnnotationClass.typeRef }
else pool.getSuperClass(in.nextChar).typeRef
val ifaceCount = in.nextChar
- var ifaces = for (i <- List.range(0, ifaceCount)) yield pool.getSuperClass(in.nextChar).typeRef
+ var ifaces = for (i <- (0 until ifaceCount).toList) yield pool.getSuperClass(in.nextChar).typeRef
+ // Dotty deviation: was
+ // var ifaces = for (i <- List.range(0 until ifaceCount)) ...
+ // This does not typecheck because the type parameter of List is now lower-bounded by Int | Char.
+ // Consequently, no best implicit for the "Integral" evidence parameter of "range"
+ // is found. If we treat constant subtyping specially, we might be able
+ // to do something there. But in any case, the until should be more efficient.
+
if (isAnnotation) ifaces = defn.ClassfileAnnotationClass.typeRef :: ifaces
superType :: ifaces
}
@@ -129,7 +136,7 @@ class ClassfileParser(
}
/** Add type parameters of enclosing classes */
- def addEnclosingTParams {
+ def addEnclosingTParams(): Unit = {
var sym = classRoot.owner
while (sym.isClass && !(sym is Flags.ModuleClass)) {
for (tparam <- sym.typeParams) {
@@ -213,7 +220,7 @@ class ClassfileParser(
private def sigToType(sig: TermName, owner: Symbol = null): Type = {
var index = 0
val end = sig.length
- def accept(ch: Char) {
+ def accept(ch: Char): Unit = {
assert(sig(index) == ch, (sig(index), ch))
index += 1
}
@@ -448,7 +455,7 @@ class ClassfileParser(
}
var newType = symtype
- def parseAttribute() {
+ def parseAttribute(): Unit = {
val attrName = pool.getName(in.nextChar).toTypeName
val attrLen = in.nextInt
val end = in.bp + attrLen
@@ -495,7 +502,7 @@ class ClassfileParser(
* Parse the "Exceptions" attribute which denotes the exceptions
* thrown by a method.
*/
- def parseExceptions(len: Int) {
+ def parseExceptions(len: Int): Unit = {
val nClasses = in.nextChar
for (n <- 0 until nClasses) {
// FIXME: this performs an equivalent of getExceptionTypes instead of getGenericExceptionTypes (SI-7065)
@@ -526,7 +533,7 @@ class ClassfileParser(
/** Enter own inner classes in the right scope. It needs the scopes to be set up,
* and implicitly current class' superclasses.
*/
- private def enterOwnInnerClasses() {
+ private def enterOwnInnerClasses(): Unit = {
def className(name: Name): Name = name.drop(name.lastIndexOf('.') + 1)
def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) = {
@@ -708,21 +715,21 @@ class ClassfileParser(
}
}
- def skipAttributes() {
+ def skipAttributes(): Unit = {
val attrCount = in.nextChar
for (i <- 0 until attrCount) {
in.skip(2); in.skip(in.nextInt)
}
}
- def skipMembers() {
+ def skipMembers(): Unit = {
val memberCount = in.nextChar
for (i <- 0 until memberCount) {
in.skip(6); skipAttributes()
}
}
- def skipSuperclasses() {
+ def skipSuperclasses(): Unit = {
in.skip(2) // superclass
val ifaces = in.nextChar
in.skip(2 * ifaces)
@@ -734,7 +741,7 @@ class ClassfileParser(
protected def getScope(flags: Int): MutableScope =
if (isStatic(flags)) staticScope else instanceScope
- private def setPrivateWithin(denot: SymDenotation, jflags: Int) {
+ private def setPrivateWithin(denot: SymDenotation, jflags: Int): Unit = {
if ((jflags & (JAVA_ACC_PRIVATE | JAVA_ACC_PUBLIC)) == 0)
denot.privateWithin = denot.enclosingPackage
}
diff --git a/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala b/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
index 48aa9317e..b44d7f292 100644
--- a/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
+++ b/src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
@@ -18,7 +18,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
var writeIndex = to
/** Double bytes array */
- private def dble() {
+ private def dble(): Unit = {
val bytes1 = new Array[Byte](bytes.length * 2)
Array.copy(bytes, 0, bytes1, 0, writeIndex)
bytes = bytes1
@@ -30,7 +30,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
// -- Basic output routines --------------------------------------------
/** Write a byte of data */
- def writeByte(b: Int) {
+ def writeByte(b: Int): Unit = {
if (writeIndex == bytes.length) dble()
bytes(writeIndex) = b.toByte
writeIndex += 1
@@ -39,7 +39,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
/** Write a natural number in big endian format, base 128.
* All but the last digits have bit 0x80 set.
*/
- def writeNat(x: Int) =
+ def writeNat(x: Int): Unit =
writeLongNat(x.toLong & 0x00000000FFFFFFFFL)
/**
@@ -49,8 +49,8 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* if the long value is in the range Int.MIN_VALUE to
* Int.MAX_VALUE.
*/
- def writeLongNat(x: Long) {
- def writeNatPrefix(x: Long) {
+ def writeLongNat(x: Long): Unit = {
+ def writeNatPrefix(x: Long): Unit = {
val y = x >>> 7
if (y != 0L) writeNatPrefix(y)
writeByte(((x & 0x7f) | 0x80).toInt)
@@ -66,8 +66,8 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* @param pos ...
* @param x ...
*/
- def patchNat(pos: Int, x: Int) {
- def patchNatPrefix(x: Int) {
+ def patchNat(pos: Int, x: Int): Unit = {
+ def patchNatPrefix(x: Int): Unit = {
writeByte(0)
Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1))
bytes(pos) = ((x & 0x7f) | 0x80).toByte
@@ -83,7 +83,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
*
* @param x The long number to be written.
*/
- def writeLong(x: Long) {
+ def writeLong(x: Long): Unit = {
val y = x >> 8
val z = x & 0xff
if (-y != (z >> 7)) writeLong(y)
@@ -208,8 +208,8 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
PARAM -> Param,
PACKAGE -> Package,
MACRO -> Macro,
- BYNAMEPARAM -> (Method, Covariant),
- LABEL -> (Label, Contravariant),
+ BYNAMEPARAM -> ((Method, Covariant)), // Dotty deviation: no auto-tupling
+ LABEL -> ((Label, Contravariant)), // Dotty deviation: no auto-tupling
ABSOVERRIDE -> AbsOverride,
LOCAL -> Local,
JAVA -> JavaDefined,
@@ -217,16 +217,16 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
STABLE -> Stable,
STATIC -> Static,
CASEACCESSOR -> CaseAccessor,
- DEFAULTPARAM -> (DefaultParameterized, Trait),
+ DEFAULTPARAM -> ((DefaultParameterized, Trait)), // Dotty deviation: no auto-tupling
BRIDGE -> Bridge,
ACCESSOR -> Accessor,
SUPERACCESSOR -> SuperAccessor,
PARAMACCESSOR -> ParamAccessor,
MODULEVAR -> Scala2ModuleVar,
LAZY -> Lazy,
- MIXEDIN -> (MixedIn, Scala2Existential),
+ MIXEDIN -> ((MixedIn, Scala2Existential)), // Dotty deviation: no auto-tupling
EXPANDEDNAME -> ExpandedName,
- IMPLCLASS -> (Scala2PreSuper, ImplClass),
+ IMPLCLASS -> ((Scala2PreSuper, ImplClass)), // Dotty deviation: no auto-tupling
SPECIALIZED -> Specialized,
DEFAULTINIT -> DefaultInit,
VBRIDGE -> VBridge,
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 279e287ea..1684b23f3 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -218,7 +218,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
if (f != null) f else moduleClassRoot.symbol.associatedFile
}
- private def checkVersion() {
+ private def checkVersion(): Unit = {
val major = readNat()
val minor = readNat()
if (major != MajorVersion || minor > MinorVersion)
@@ -734,7 +734,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
/** Read children and store them into the corresponding symbol.
*/
- protected def readChildren() {
+ protected def readChildren(): Unit = {
val tag = readByte()
assert(tag == CHILDREN)
val end = readNat() + readIndex
@@ -874,18 +874,18 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
var name: Name = null
/** Read a Symbol, Modifiers, and a Name */
- def setSymModsName() {
+ def setSymModsName(): Unit = {
symbol = readSymbolRef()
mods = readModifiersRef(symbol.isType)
name = readNameRef()
}
/** Read a Symbol and a Name */
- def setSymName() {
+ def setSymName(): Unit = {
symbol = readSymbolRef()
name = readNameRef()
}
/** Read a Symbol */
- def setSym() {
+ def setSym(): Unit = {
symbol = readSymbolRef()
}
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index fab5cab09..174931b7f 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -47,6 +47,7 @@ class tests extends CompilerTest {
@Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast")
@Test def dotc_config = compileDir(dotcDir + "tools/dotc/config")
@Test def dotc_core = compileDir(dotcDir + "tools/dotc/core")
+ @Test def dotc_core_pickling = compileDir(dotcDir + "tools/dotc/core/pickling")
// @Test def dotc_compilercommand = compileFile(dotcDir + "tools/dotc/config/", "CompilerCommand")