Skip to content

Commit 717f690

Browse files
committed
More modifier lock down in pickling._
1 parent 74aa068 commit 717f690

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import io.AbstractFile
1414
* @author Philippe Altherr
1515
* @version 1.0, 23/03/2004
1616
*/
17-
class AbstractFileReader(val file: AbstractFile) {
17+
final class AbstractFileReader(val file: AbstractFile) {
1818

1919
/** the buffer containing the file
2020
*/

src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ object ClassfileConstants {
324324
final val impdep1 = 0xfe
325325
final val impdep2 = 0xff
326326

327-
abstract class FlagTranslation {
327+
sealed abstract class FlagTranslation {
328328
import Flags._
329329

330330
private var isAnnotation = false
@@ -360,16 +360,16 @@ object ClassfileConstants {
360360
res
361361
}
362362

363-
def classFlags(jflags: Int): FlagSet = {
363+
final def classFlags(jflags: Int): FlagSet = {
364364
initFields(jflags)
365365
isClass = true
366366
translateFlags(jflags, EmptyFlags)
367367
}
368-
def fieldFlags(jflags: Int): FlagSet = {
368+
final def fieldFlags(jflags: Int): FlagSet = {
369369
initFields(jflags)
370370
translateFlags(jflags, if ((jflags & JAVA_ACC_FINAL) == 0) Mutable else EmptyFlags)
371371
}
372-
def methodFlags(jflags: Int): FlagSet = {
372+
final def methodFlags(jflags: Int): FlagSet = {
373373
initFields(jflags)
374374
translateFlags(jflags, if ((jflags & JAVA_ACC_BRIDGE) != 0) Bridge else EmptyFlags)
375375
}

src/dotty/tools/dotc/core/pickling/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.collection.mutable.{ ListBuffer, ArrayBuffer }
1313
import scala.annotation.switch
1414
import io.AbstractFile
1515

16-
class ClassfileParser(
16+
final class ClassfileParser(
1717
classfile: AbstractFile,
1818
classRoot: LazyClassDenotation,
1919
moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext) {

src/dotty/tools/dotc/core/pickling/PickleBuffer.scala

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Flags._
1111
* @param from The first index where defined data are found
1212
* @param to The first index where new data can be written
1313
*/
14-
class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
14+
abstract class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
1515

1616
var bytes = data
1717
var readIndex = from
@@ -24,13 +24,13 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
2424
bytes = bytes1
2525
}
2626

27-
def ensureCapacity(capacity: Int) =
27+
final def ensureCapacity(capacity: Int) =
2828
while (bytes.length < writeIndex + capacity) dble()
2929

3030
// -- Basic output routines --------------------------------------------
3131

3232
/** Write a byte of data */
33-
def writeByte(b: Int) {
33+
final def writeByte(b: Int) {
3434
if (writeIndex == bytes.length) dble()
3535
bytes(writeIndex) = b.toByte
3636
writeIndex += 1
@@ -39,7 +39,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
3939
/** Write a natural number in big endian format, base 128.
4040
* All but the last digits have bit 0x80 set.
4141
*/
42-
def writeNat(x: Int) =
42+
final def writeNat(x: Int) =
4343
writeLongNat(x.toLong & 0x00000000FFFFFFFFL)
4444

4545
/**
@@ -49,7 +49,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
4949
* if the long value is in the range Int.MIN_VALUE to
5050
* Int.MAX_VALUE.
5151
*/
52-
def writeLongNat(x: Long) {
52+
final def writeLongNat(x: Long) {
5353
def writeNatPrefix(x: Long) {
5454
val y = x >>> 7
5555
if (y != 0L) writeNatPrefix(y)
@@ -66,7 +66,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
6666
* @param pos ...
6767
* @param x ...
6868
*/
69-
def patchNat(pos: Int, x: Int) {
69+
final def patchNat(pos: Int, x: Int) {
7070
def patchNatPrefix(x: Int) {
7171
writeByte(0)
7272
Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1))
@@ -83,7 +83,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
8383
*
8484
* @param x The long number to be written.
8585
*/
86-
def writeLong(x: Long) {
86+
final def writeLong(x: Long) {
8787
val y = x >> 8
8888
val z = x & 0xff
8989
if (-y != (z >> 7)) writeLong(y)
@@ -93,18 +93,18 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
9393
// -- Basic input routines --------------------------------------------
9494

9595
/** Peek at the current byte without moving the read index */
96-
def peekByte(): Int = bytes(readIndex)
96+
final def peekByte(): Int = bytes(readIndex)
9797

9898
/** Read a byte */
99-
def readByte(): Int = {
99+
final def readByte(): Int = {
100100
val x = bytes(readIndex); readIndex += 1; x
101101
}
102102

103103
/** Read a natural number in big endian format, base 128.
104104
* All but the last digits have bit 0x80 set.*/
105-
def readNat(): Int = readLongNat().toInt
105+
final def readNat(): Int = readLongNat().toInt
106106

107-
def readLongNat(): Long = {
107+
final def readLongNat(): Long = {
108108
var b = 0L
109109
var x = 0L
110110
do {
@@ -115,7 +115,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
115115
}
116116

117117
/** Read a long number in signed big endian format, base 256. */
118-
def readLong(len: Int): Long = {
118+
final def readLong(len: Int): Long = {
119119
var x = 0L
120120
var i = 0
121121
while (i < len) {
@@ -129,8 +129,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
129129
/** Returns the buffer as a sequence of (Int, Array[Byte]) representing
130130
* (tag, data) of the individual entries. Saves and restores buffer state.
131131
*/
132-
133-
def toIndexedSeq: IndexedSeq[(Int, Array[Byte])] = {
132+
final def toIndexedSeq: IndexedSeq[(Int, Array[Byte])] = {
134133
val saved = readIndex
135134
readIndex = 0
136135
readNat() ; readNat() // discarding version
@@ -157,14 +156,14 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
157156
* @param op ...
158157
* @return ...
159158
*/
160-
def until[T](end: Int, op: () => T): List[T] =
159+
final def until[T](end: Int, op: () => T): List[T] =
161160
if (readIndex == end) List() else op() :: until(end, op);
162161

163162
/** Perform operation <code>op</code> the number of
164163
* times specified. Concatenate the results into a list.
165164
*/
166-
def times[T](n: Int, op: ()=>T): List[T] =
165+
final def times[T](n: Int, op: ()=>T): List[T] =
167166
if (n == 0) List() else op() :: times(n-1, op)
168167

169-
def unpickleScalaFlags(sflags: Long): FlagSet = ???
168+
final def unpickleScalaFlags(sflags: Long): FlagSet = ???
170169
}

src/dotty/tools/dotc/core/pickling/UnPickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object UnPickler {
6767
* @param moduleroot the top-level module class which is unpickled, or NoSymbol if inapplicable
6868
* @param filename filename associated with bytearray, only used for error messages
6969
*/
70-
class UnPickler(bytes: Array[Byte], classRoot: LazyClassDenotation, moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext)
70+
final class UnPickler(bytes: Array[Byte], classRoot: LazyClassDenotation, moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext)
7171
extends PickleBuffer(bytes, 0, -1) {
7272

7373
import UnPickler._

0 commit comments

Comments
 (0)