Skip to content

Commit f2de2c4

Browse files
committed
SI-7624 Fix -feature warnings in scala/tools/scalap
... and move scalap.scala.tools.scalap.scalax.rules to scalap.scala.tools.scalap.rules now that all the Monad/Functor/ Applicatve/... stuff has been removed.
1 parent 6056f7e commit f2de2c4

25 files changed

+98
-174
lines changed

src/partest/scala/tools/partest/nest/Runner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.tools.nsc.{ Settings, CompilerCommand, Global }
2020
import scala.tools.nsc.reporters.ConsoleReporter
2121
import scala.tools.nsc.util.{ Exceptional, ScalaClassLoader, stackTraceString }
2222
import scala.tools.scalap.Main.decompileScala
23-
import scala.tools.scalap.scalax.rules.scalasig.ByteCode
23+
import scala.tools.scalap.scalasig.ByteCode
2424
import scala.util.{ Try, Success, Failure }
2525
import ClassPath.{ join, split }
2626
import PartestDefaults.{ javaCmd, javacCmd }

src/scalap/scala/tools/scalap/Arguments.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
**
66
*/
77

8-
98
package scala.tools.scalap
109

1110
import scala.collection.mutable

src/scalap/scala/tools/scalap/ByteArrayReader.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
**
66
*/
77

8-
9-
package scala
10-
package tools.scalap
11-
8+
package scala.tools.scalap
129

1310
class ByteArrayReader(content: Array[Byte]) {
1411

@@ -104,9 +101,6 @@ class ByteArrayReader(content: Array[Byte]) {
104101
def getDouble(bp: Int): Double = java.lang.Double.longBitsToDouble(getLong(bp))
105102

106103
/** skip next 'n' bytes
107-
*/
108-
def skip(n: Int) {
109-
bp += n
110-
}
111-
104+
*/
105+
def skip(n: Int): Unit = bp += n
112106
}

src/scalap/scala/tools/scalap/Classfile.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
**
66
*/
77

8-
98
package scala.tools.scalap
109

11-
1210
class Classfile(in: ByteArrayReader) {
1311
import Classfiles._
1412

src/scalap/scala/tools/scalap/Classfiles.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
**
66
*/
77

8-
98
package scala.tools.scalap
109

11-
1210
object Classfiles {
1311
final val JAVA_MAGIC = 0xCAFEBABE
1412
final val JAVA_MAJOR_VERSION = 45

src/scalap/scala/tools/scalap/CodeWriter.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66
*/
77

88

9-
package scala
10-
package tools.scalap
9+
package scala.tools.scalap
1110

12-
import java.io._
13-
14-
15-
class CodeWriter(writer: Writer) {
11+
class CodeWriter(writer: java.io.Writer) {
1612

1713
private val nl = scala.compat.Platform.EOL
1814
private var step = " "

src/scalap/scala/tools/scalap/Decode.scala

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
**
66
*/
77

8-
// $Id$
9-
108
package scala.tools.scalap
119

12-
import scala.tools.scalap.scalax.rules.scalasig._
13-
import scala.tools.nsc.util.ScalaClassLoader
14-
import scala.tools.nsc.util.ScalaClassLoader.appLoader
10+
import scala.tools.scalap.scalasig._
11+
12+
import scala.reflect.internal.util.ScalaClassLoader
1513
import scala.reflect.internal.pickling.ByteCodecs
1614

1715
import ClassFileParser.{ ConstValueIndex, Annotation }
18-
import Main.{ SCALA_SIG, SCALA_SIG_ANNOTATION, BYTES_VALUE }
1916

2017
/** Temporary decoder. This would be better off in the scala.tools.nsc
2118
* but right now the compiler won't acknowledge scala.tools.scalap
@@ -31,25 +28,24 @@ object Decode {
3128
/** Return the classfile bytes representing the scala sig classfile attribute.
3229
* This has been obsoleted by the switch to annotations.
3330
*/
34-
def scalaSigBytes(name: String): Option[Array[Byte]] = scalaSigBytes(name, appLoader)
31+
def scalaSigBytes(name: String): Option[Array[Byte]] = scalaSigBytes(name, ScalaClassLoader.appLoader)
3532
def scalaSigBytes(name: String, classLoader: ScalaClassLoader): Option[Array[Byte]] = {
3633
val bytes = classLoader.classBytes(name)
3734
val reader = new ByteArrayReader(bytes)
3835
val cf = new Classfile(reader)
3936
cf.scalaSigAttribute map (_.data)
4037
}
4138

42-
/** Return the bytes representing the annotation
43-
*/
44-
def scalaSigAnnotationBytes(name: String): Option[Array[Byte]] = scalaSigAnnotationBytes(name, appLoader)
39+
/** Return the bytes representing the annotation. */
40+
def scalaSigAnnotationBytes(name: String): Option[Array[Byte]] = scalaSigAnnotationBytes(name, ScalaClassLoader.appLoader)
4541
def scalaSigAnnotationBytes(name: String, classLoader: ScalaClassLoader): Option[Array[Byte]] = {
4642
val bytes = classLoader.classBytes(name)
4743
val byteCode = ByteCode(bytes)
4844
val classFile = ClassFileParser.parse(byteCode)
4945
import classFile._
5046

51-
classFile annotation SCALA_SIG_ANNOTATION map { case Annotation(_, els) =>
52-
val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) getOrElse null
47+
classFile annotation Main.SCALA_SIG_ANNOTATION map { case Annotation(_, els) =>
48+
val bytesElem = els find (x => constant(x.elementNameIndex) == Main.BYTES_VALUE) getOrElse null
5349
val _bytes = bytesElem.elementValue match { case ConstValueIndex(x) => constantWrapped(x) }
5450
val bytes = _bytes.asInstanceOf[StringBytesPair].bytes
5551
val length = ByteCodecs.decode(bytes)
@@ -58,16 +54,15 @@ object Decode {
5854
}
5955
}
6056

61-
/** private[scala] so nobody gets the idea this is a supported interface.
62-
*/
57+
/** private[scala] so nobody gets the idea this is a supported interface. */
6358
private[scala] def caseParamNames(path: String): Option[List[String]] = {
6459
val (outer, inner) = (path indexOf '$') match {
6560
case -1 => (path, "")
6661
case x => (path take x, path drop (x + 1))
6762
}
6863

6964
for {
70-
clazz <- appLoader.tryToLoadClass[AnyRef](outer)
65+
clazz <- ScalaClassLoader.appLoader.tryToLoadClass[AnyRef](outer)
7166
ssig <- ScalaSigParser.parse(clazz)
7267
}
7368
yield {
@@ -85,11 +80,10 @@ object Decode {
8580
}
8681
}
8782

88-
/** Returns a map of Alias -> Type for the given package.
89-
*/
83+
/** Returns a map of Alias -> Type for the given package. */
9084
private[scala] def typeAliases(pkg: String) = {
9185
for {
92-
clazz <- appLoader.tryToLoadClass[AnyRef](pkg + ".package")
86+
clazz <- ScalaClassLoader.appLoader.tryToLoadClass[AnyRef](pkg + ".package")
9387
ssig <- ScalaSigParser.parse(clazz)
9488
}
9589
yield {

src/scalap/scala/tools/scalap/JavaWriter.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
**
66
*/
77

8-
98
package scala.tools.scalap
109

11-
import java.io._
1210
import scala.reflect.NameTransformer
1311

14-
class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer) {
12+
class JavaWriter(classfile: Classfile, writer: java.io.Writer) extends CodeWriter(writer) {
1513

1614
val cf = classfile
1715

src/scalap/scala/tools/scalap/Main.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
**
66
*/
77

8-
package scala
9-
package tools.scalap
8+
package scala.tools.scalap
109

1110
import java.io.{ PrintStream, OutputStreamWriter, ByteArrayOutputStream }
12-
import scala.reflect.NameTransformer
13-
import scalax.rules.scalasig._
11+
1412
import scala.tools.nsc.util.{ ClassPath, JavaClassPath }
15-
import scala.tools.util.PathResolver
16-
import ClassPath.DefaultJavaContext
13+
import scala.tools.nsc.util.ClassPath.DefaultJavaContext
1714
import scala.tools.nsc.io.AbstractFile
1815

16+
import scala.tools.scalap.scalasig._
17+
18+
1919
/**The main object used to execute scalap on the command-line.
2020
*
2121
* @author Matthias Zenger, Stephane Micheloud, Burak Emir, Ilya Sergey
@@ -104,7 +104,7 @@ class Main {
104104
// we have to encode every fragment of a name separately, otherwise the NameTransformer
105105
// will encode using unicode escaping dot separators as well
106106
// we can afford allocations because this is not a performance critical code
107-
classname.split('.').map(NameTransformer.encode).mkString(".")
107+
classname.split('.').map(scala.reflect.NameTransformer.encode).mkString(".")
108108
}
109109
val cls = path.findClass(encName)
110110
if (cls.isDefined && cls.get.binary.isDefined) {
@@ -185,7 +185,7 @@ object Main extends Main {
185185
val cparg = List("-classpath", "-cp") map (arguments getArgument _) reduceLeft (_ orElse _)
186186
val path = cparg match {
187187
case Some(cp) => new JavaClassPath(DefaultJavaContext.classesInExpandedPath(cp), DefaultJavaContext)
188-
case _ => PathResolver.fromPathString(".") // include '.' in the default classpath SI-6669
188+
case _ => scala.tools.util.PathResolver.fromPathString(".") // include '.' in the default classpath SI-6669
189189
}
190190
// print the classpath if output is verbose
191191
if (verbose)

src/scalap/scala/tools/scalap/MetaParser.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
*/
77

88

9-
package scala
10-
package tools.scalap
9+
package scala.tools.scalap
1110

12-
import java.util._
1311

1412

1513
/** a parser class for parsing meta type information in classfiles
1614
* generated by pico.
1715
*/
1816
class MetaParser(meta: String) {
19-
val scanner = new StringTokenizer(meta, "()[], \t<;", true)
17+
val scanner = new java.util.StringTokenizer(meta, "()[], \t<;", true)
2018
var token: String = _
2119
val res = new StringBuffer
2220

0 commit comments

Comments
 (0)