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

src/scalap/scala/tools/scalap/Properties.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
package scala.tools.scalap
1010

1111
/** Loads decoder.properties from the jar. */
12-
object Properties extends scala.util.PropertiesTrait
13-
{
12+
object Properties extends scala.util.PropertiesTrait {
1413
protected def propCategory = "decoder"
1514
protected def pickJarBasedOn = classOf[Classfile]
1615
}

src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala renamed to src/scalap/scala/tools/scalap/rules/Memoisable.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
//
1111
// -----------------------------------------------------------------------------
1212

13-
package scala.tools.scalap
14-
package scalax
15-
package rules
13+
package scala.tools.scalap.rules
1614

1715
import scala.collection.mutable
1816

@@ -22,7 +20,7 @@ trait MemoisableRules extends Rules {
2220
from[In] { in => in.memo(key, rule(in)) }
2321
}
2422

25-
override def ruleWithName[In, Out, A, X](name : String, f : In => rules.Result[Out, A, X]) = super.ruleWithName(name, (in : In) => in match {
23+
override def ruleWithName[In, Out, A, X](name : String, f : In => Result[Out, A, X]) = super.ruleWithName(name, (in : In) => in match {
2624
case s : Memoisable => s.memo(name, f(in))
2725
case _ => f(in)
2826
})
@@ -56,6 +54,3 @@ trait DefaultMemoisable extends Memoisable {
5654
if(DefaultMemoisable.debug) println(key + " -> " + t + " (" + out + ")")
5755
}
5856
}
59-
60-
61-

src/scalap/scala/tools/scalap/scalax/rules/Result.scala renamed to src/scalap/scala/tools/scalap/rules/Result.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
//
1111
// -----------------------------------------------------------------------------
1212

13-
package scala.tools.scalap
14-
package scalax
15-
package rules;
13+
package scala.tools.scalap.rules;
1614

1715
/** Represents the combined value of two rules applied in sequence.
1816
*

src/scalap/scala/tools/scalap/scalax/rules/Rule.scala renamed to src/scalap/scala/tools/scalap/rules/Rule.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
//
1111
// -----------------------------------------------------------------------------
1212

13-
package scala.tools.scalap
14-
package scalax
15-
package rules
13+
package scala.tools.scalap.rules
1614

1715
/** A Rule is a function from some input to a Result. The result may be:
1816
* <ul>
@@ -91,11 +89,11 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) {
9189
/** Apply the result of this rule to the function returned by the previous rule */
9290
def <~:[InPrev, B, X2 >: X](prev : => Rule[InPrev, In, A => B, X2]) = for (fa2b <- prev; a <- this) yield fa2b(a)
9391

94-
def ~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield new ~(a, b)
92+
def ~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield new ~(a, b)
9593

96-
def ~-![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield a
94+
def ~-![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield a
9795

98-
def -~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield b
96+
def -~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield b
9997

10098
def -[In2 <: In](exclude : => Rule[In2, Any, Any, Any]) = !exclude -~ this
10199

@@ -172,6 +170,3 @@ trait Choice[-In, +Out, +A, +X] extends Rule[In, Out, A, X] {
172170
lazy val choices = Choice.this.choices ::: other :: Nil
173171
}
174172
}
175-
176-
177-

src/scalap/scala/tools/scalap/scalax/rules/Rules.scala renamed to src/scalap/scala/tools/scalap/rules/Rules.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// -----------------------------------------------------------------------------
1212

1313
package scala.tools.scalap
14-
package scalax
1514
package rules
1615

1716
trait Name {
@@ -26,12 +25,17 @@ trait Name {
2625
* Inspired by the Scala parser combinator.
2726
*/
2827
trait Rules {
29-
implicit def rule[In, Out, A, X](f : In => Result[Out, A, X]) : Rule[In, Out, A, X] = new DefaultRule(f)
3028

29+
import scala.language.implicitConversions
30+
implicit def rule[In, Out, A, X](f : In => Result[Out, A, X]) : Rule[In, Out, A, X] = new DefaultRule(f)
3131
implicit def inRule[In, Out, A, X](rule : Rule[In, Out, A, X]) : InRule[In, Out, A, X] = new InRule(rule)
3232
implicit def seqRule[In, A, X](rule : Rule[In, In, A, X]) : SeqRule[In, A, X] = new SeqRule(rule)
3333

34-
def from[In] = new {
34+
trait FromRule[In] {
35+
def apply[Out, A, X](f : In => Result[Out, A, X]): Rule[In, Out, A, X]
36+
}
37+
38+
def from[In] = new FromRule[In] {
3539
def apply[Out, A, X](f : In => Result[Out, A, X]) = rule(f)
3640
}
3741

src/scalap/scala/tools/scalap/scalax/rules/SeqRule.scala renamed to src/scalap/scala/tools/scalap/rules/SeqRule.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
//
1111
// -----------------------------------------------------------------------------
1212

13-
package scala.tools.scalap
14-
package scalax
15-
package rules
13+
package scala.tools.scalap.rules
1614

1715
/**
1816
* A workaround for the difficulties of dealing with
@@ -49,7 +47,7 @@ class SeqRule[S, +A, +X](rule : Rule[S, S, A, X]) {
4947

5048
/** Creates a rule that always succeeds with a Boolean value.
5149
* Value is 'true' if this rule succeeds, 'false' otherwise */
52-
def -? = ? map { _ isDefined }
50+
def -? = ? map { _.isDefined }
5351

5452
def * = from[S] {
5553
// tail-recursive function with reverse list accumulator
@@ -98,4 +96,3 @@ class SeqRule[S, +A, +X](rule : Rule[S, S, A, X]) {
9896
in => rep(0, in)
9997
}
10098
}
101-
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package scala.tools.scalap
2+
3+
package object rules {
4+
// make some language features in this package compile without warning
5+
implicit def postfixOps = scala.language.postfixOps
6+
}

0 commit comments

Comments
 (0)