summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actors/scala/actors/Future.scala14
-rw-r--r--src/actors/scala/actors/remote/NetKernel.scala8
-rw-r--r--src/actors/scala/actors/remote/Proxy.scala4
-rw-r--r--src/actors/scala/actors/remote/RemoteActor.scala4
-rw-r--r--src/actors/scala/actors/remote/TcpService.scala8
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Resolvers.scala2
-rw-r--r--src/compiler/scala/tools/ant/ScalaTool.scala4
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Compilers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala40
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala22
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala6
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala2
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala6
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/Mixer.scala99
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala21
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala111
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala31
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
-rw-r--r--src/compiler/scala/tools/nsc/util/package.scala35
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala20
-rw-r--r--src/eclipse/partest/.classpath2
-rw-r--r--src/eclipse/scaladoc/.classpath6
-rw-r--r--src/interactive/scala/tools/nsc/interactive/CompilerControl.scala37
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala164
-rw-r--r--src/interactive/scala/tools/nsc/interactive/REPL.scala55
-rw-r--r--src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala201
-rw-r--r--src/library/scala/Predef.scala6
-rw-r--r--src/library/scala/annotation/migration.scala5
-rw-r--r--src/library/scala/collection/immutable/Range.scala16
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala6
-rw-r--r--src/library/scala/math/BigDecimal.scala3
-rw-r--r--src/library/scala/math/BigInt.scala3
-rw-r--r--src/library/scala/reflect/ClassManifestDeprecatedApis.scala23
-rw-r--r--src/library/scala/reflect/Manifest.scala12
-rw-r--r--src/library/scala/runtime/WorksheetSupport.scala93
-rw-r--r--src/library/scala/util/control/NonFatal.scala4
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala8
-rw-r--r--src/reflect/scala/reflect/api/JavaUniverse.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala16
-rw-r--r--src/reflect/scala/reflect/internal/FreshNames.scala35
-rw-r--r--src/reflect/scala/reflect/internal/Mirrors.scala12
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala24
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala8
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala6
-rw-r--r--src/reflect/scala/reflect/internal/util/FreshNameCreator.scala7
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala1
-rw-r--r--src/repl/scala/tools/nsc/interpreter/IMain.scala3
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JavapClass.scala2
-rw-r--r--src/scaladoc/scala/tools/ant/Scaladoc.scala6
-rw-r--r--src/scalap/scala/tools/scalap/Arguments.scala6
59 files changed, 313 insertions, 941 deletions
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index 9d123cb2d5..4421c7a07a 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -180,17 +180,17 @@ object Futures {
var cnt = 0
val mappedFts = fts.map(ft =>
- Pair({cnt+=1; cnt-1}, ft))
+ ({cnt+=1; cnt-1}, ft))
- val unsetFts = mappedFts.filter((p: Pair[Int, Future[Any]]) => {
+ val unsetFts = mappedFts.filter((p: Tuple2[Int, Future[Any]]) => {
if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false }
else { resultsMap(p._1) = None; true }
})
- val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => {
+ val partFuns = unsetFts.map((p: Tuple2[Int, Future[Any]]) => {
val FutCh = p._2.inputChannel
- val singleCase: PartialFunction[Any, Pair[Int, Any]] = {
- case FutCh ! any => Pair(p._1, any)
+ val singleCase: PartialFunction[Any, Tuple2[Int, Any]] = {
+ case FutCh ! any => (p._1, any)
}
singleCase
})
@@ -201,7 +201,7 @@ object Futures {
}
Actor.timer.schedule(timerTask, timeout)
- def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
+ def awaitWith(partFuns: Seq[PartialFunction[Any, Tuple2[Int, Any]]]) {
val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
@@ -212,7 +212,7 @@ object Futures {
case _ => {
val pfOpt = partFuns find (_ isDefinedAt msg)
val pf = pfOpt.get // succeeds always
- val Pair(idx, subres) = pf(msg)
+ val (idx, subres) = pf(msg)
resultsMap(idx) = Some(subres)
val partFunsRest = partFuns filter (_ != pf)
diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala
index 4795ff3eb6..57d7af6d26 100644
--- a/src/actors/scala/actors/remote/NetKernel.scala
+++ b/src/actors/scala/actors/remote/NetKernel.scala
@@ -43,8 +43,8 @@ private[remote] class NetKernel(service: Service) {
private val names = new mutable.HashMap[OutputChannel[Any], Symbol]
def register(name: Symbol, a: OutputChannel[Any]): Unit = synchronized {
- actors += Pair(name, a)
- names += Pair(a, name)
+ actors(name) = a
+ names(a) = name
}
def getOrCreateName(from: OutputChannel[Any]) = names.get(from) match {
@@ -79,7 +79,7 @@ private[remote] class NetKernel(service: Service) {
def createProxy(node: Node, sym: Symbol): Proxy = {
val p = new Proxy(node, sym, this)
- proxies += Pair((node, sym), p)
+ proxies((node, sym)) = p
p
}
@@ -99,7 +99,7 @@ private[remote] class NetKernel(service: Service) {
proxies.synchronized {
proxies.get((senderNode, senderName)) match {
case Some(senderProxy) => // do nothing
- case None => proxies += Pair((senderNode, senderName), p)
+ case None => proxies((senderNode, senderName)) = p
}
}
diff --git a/src/actors/scala/actors/remote/Proxy.scala b/src/actors/scala/actors/remote/Proxy.scala
index 43a43ac99c..9949b36181 100644
--- a/src/actors/scala/actors/remote/Proxy.scala
+++ b/src/actors/scala/actors/remote/Proxy.scala
@@ -142,7 +142,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create a new reply channel...
val replyCh = new Channel[Any](this)
// ...that maps to session
- sessionMap += Pair(replyCh, session)
+ sessionMap(replyCh) = session
// local send
out.send(msg, replyCh)
@@ -178,7 +178,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create fresh session ID...
val fresh = FreshNameCreator.newName(node+"@"+name)
// ...that maps to reply channel
- channelMap += Pair(fresh, sender)
+ channelMap(fresh) = sender
kernel.forward(sender, node, name, msg, fresh)
} else {
kernel.forward(sender, node, name, msg, 'nosession)
diff --git a/src/actors/scala/actors/remote/RemoteActor.scala b/src/actors/scala/actors/remote/RemoteActor.scala
index 799076a01f..2daf9ceb43 100644
--- a/src/actors/scala/actors/remote/RemoteActor.scala
+++ b/src/actors/scala/actors/remote/RemoteActor.scala
@@ -64,7 +64,7 @@ object RemoteActor {
val serv = TcpService(port, cl)
val kern = serv.kernel
val s = Actor.self(Scheduler)
- kernels += Pair(s, kern)
+ kernels(s) = kern
s.onTerminate {
Debug.info("alive actor "+s+" terminated")
@@ -90,7 +90,7 @@ object RemoteActor {
val kernel = kernels.get(Actor.self(Scheduler)) match {
case None =>
val serv = TcpService(TcpService.generatePort, cl)
- kernels += Pair(Actor.self(Scheduler), serv.kernel)
+ kernels(Actor.self(Scheduler)) = serv.kernel
serv.kernel
case Some(k) =>
k
diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala
index 75e36b2738..69e5c46c52 100644
--- a/src/actors/scala/actors/remote/TcpService.scala
+++ b/src/actors/scala/actors/remote/TcpService.scala
@@ -35,7 +35,7 @@ object TcpService {
service
case None =>
val service = new TcpService(port, cl)
- ports += Pair(port, service)
+ ports(port) = service
service.start()
Debug.info("created service at "+service.node)
service
@@ -106,9 +106,9 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
// when remote net kernel comes up
(pendingSends.get(node): @unchecked) match {
case None =>
- pendingSends += Pair(node, List(data))
+ pendingSends(node) = List(data)
case Some(msgs) if msgs.length < TcpService.BufSize =>
- pendingSends += Pair(node, data :: msgs)
+ pendingSends(node) = data :: msgs
}
}
@@ -183,7 +183,7 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
new mutable.HashMap[Node, TcpServiceWorker]
private[actors] def addConnection(node: Node, worker: TcpServiceWorker) = synchronized {
- connections += Pair(node, worker)
+ connections(node) = worker
}
def getConnection(n: Node) = synchronized {
diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
index 03d306f593..e4851632a5 100644
--- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
@@ -9,7 +9,7 @@ trait Resolvers {
import global._
import analyzer._
- import definitions.{EmptyPackageClass => _, _}
+ import definitions._
import treeInfo._
import gen._
private val runDefinitions = currentRun.runDefinitions
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala
index e7ac53c8fb..bb6a933d3f 100644
--- a/src/compiler/scala/tools/ant/ScalaTool.scala
+++ b/src/compiler/scala/tools/ant/ScalaTool.scala
@@ -139,7 +139,7 @@ class ScalaTool extends ScalaMatchingTask {
val st = s.trim
val stArray = st.split("=", 2)
if (stArray.length == 2) {
- if (input != "") List(Pair(stArray(0), stArray(1))) else Nil
+ if (input != "") List((stArray(0), stArray(1))) else Nil
}
else
buildError("Property " + st + " is not formatted properly.")
@@ -170,7 +170,7 @@ class ScalaTool extends ScalaMatchingTask {
private def getProperties: String =
properties.map({
- case Pair(name,value) => "-D" + name + "=\"" + value + "\""
+ case (name,value) => "-D" + name + "=\"" + value + "\""
}).mkString("", " ", "")
/*============================================================================*\
diff --git a/src/compiler/scala/tools/ant/sabbus/Compilers.scala b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
index b1994233e8..a0aad49f20 100644
--- a/src/compiler/scala/tools/ant/sabbus/Compilers.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
@@ -27,7 +27,7 @@ object Compilers extends scala.collection.DefaultMap[String, Compiler] {
if (debug) println("Making compiler " + id)
if (debug) println(" memory before: " + freeMemoryString)
val comp = new Compiler(classpath, settings)
- container += Pair(id, comp)
+ container(id) = comp
if (debug) println(" memory after: " + freeMemoryString)
comp
}
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index d4ac21a6b8..4ac6672727 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -256,4 +256,44 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
val stats1 = if (stats.isEmpty) List(Literal(Constant(()))) else stats
mkNew(Nil, noSelfType, stats1, NoPosition, NoPosition)
}
+
+ /**
+ * Create a method based on a Function
+ *
+ * Used both to under `-Ydelambdafy:method` create a lifted function and
+ * under `-Ydelamdafy:inline` to create the apply method on the anonymous
+ * class.
+ *
+ * It creates a method definition with value params cloned from the
+ * original lambda. Then it calls a supplied function to create
+ * the body and types the result. Finally
+ * everything is wrapped up in a DefDef
+ *
+ * @param owner The owner for the new method
+ * @param name name for the new method
+ * @param additionalFlags flags to be put on the method in addition to FINAL
+ */
+ def mkMethodFromFunction(localTyper: analyzer.Typer)
+ (fun: Function, owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags) = {
+ val funParams = fun.vparams map (_.symbol)
+ val formals :+ restpe = fun.tpe.typeArgs
+
+ val methSym = owner.newMethod(name, fun.pos, FINAL | additionalFlags)
+
+ val paramSyms = map2(formals, fun.vparams) {
+ (tp, vparam) => methSym.newSyntheticValueParam(tp, vparam.name)
+ }
+
+ methSym setInfo MethodType(paramSyms, restpe.deconst)
+
+ fun.body.substituteSymbols(funParams, paramSyms)
+ fun.body changeOwner (fun.symbol -> methSym)
+
+ val methDef = DefDef(methSym, fun.body)
+
+ // Have to repack the type to avoid mismatches when existentials
+ // appear in the result - see SI-4869.
+ methDef.tpt setType localTyper.packedType(fun.body, methSym).deconst
+ methDef
+ }
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index ef4052d5f3..0429e295b4 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1774,10 +1774,12 @@ self =>
in.nextToken()
if (in.token == SUBTYPE || in.token == SUPERTYPE) wildcardType(start)
else atPos(start) { Bind(tpnme.WILDCARD, EmptyTree) }
- case IDENTIFIER if nme.isVariableName(in.name) =>
- atPos(start) { Bind(identForType(), EmptyTree) }
case _ =>
- typ()
+ typ() match {
+ case Ident(name: TypeName) if nme.isVariableName(name) =>
+ atPos(start) { Bind(name, EmptyTree) }
+ case t => t
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index 60f7857d0c..939641c3eb 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -69,7 +69,7 @@ abstract class Liveness {
case STORE_LOCAL(local) if (!genSet(local)) => killSet = killSet + local
case _ => ()
}
- Pair(genSet, killSet)
+ (genSet, killSet)
}
override def run() {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index 7a53293384..f10d7cdc40 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -418,7 +418,7 @@ abstract class TypeFlowAnalysis {
!blackballed(concreteMethod)
}
if(isCandidate) {
- remainingCALLs += Pair(cm, CallsiteInfo(b, receiver, result.stack.length, concreteMethod))
+ remainingCALLs(cm) = CallsiteInfo(b, receiver, result.stack.length, concreteMethod)
} else {
remainingCALLs.remove(cm)
isOnWatchlist.remove(cm)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
index c166b0bb7e..4f9f4c9e31 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
@@ -741,13 +741,13 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
var flatKeys: List[Int] = Nil
var targets: List[asm.Label] = Nil
var default: asm.Label = null
- var switchBlocks: List[Pair[asm.Label, Tree]] = Nil
+ var switchBlocks: List[Tuple2[asm.Label, Tree]] = Nil
// collect switch blocks and their keys, but don't emit yet any switch-block.
for (caze @ CaseDef(pat, guard, body) <- tree.cases) {
assert(guard == EmptyTree, guard)
val switchBlockPoint = new asm.Label
- switchBlocks ::= Pair(switchBlockPoint, body)
+ switchBlocks ::= (switchBlockPoint, body)
pat match {
case Literal(value) =>
flatKeys ::= value.intValue
@@ -772,7 +772,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
// emit switch-blocks.
val postMatch = new asm.Label
for (sb <- switchBlocks.reverse) {
- val Pair(caseLabel, caseBody) = sb
+ val (caseLabel, caseBody) = sb
markProgramPoint(caseLabel)
genLoad(caseBody, generatedType)
bc goTo postMatch
@@ -790,7 +790,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
genLoad(expr, expectedType)
val end = currProgramPoint()
if (emitVars) { // add entries to LocalVariableTable JVM attribute
- for (Pair(sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
+ for ((sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
}
varsInScope = savedScope
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index c22ced26a5..64ed094a47 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -112,7 +112,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
val ta = exemplars.get(a)
val tb = exemplars.get(b)
- val res = Pair(ta.isInterface, tb.isInterface) match {
+ val res = (ta.isInterface, tb.isInterface) match {
case (true, true) =>
// exercised by test/files/run/t4761.scala
if (tb.isSubtypeOf(ta.c)) ta.c
@@ -759,7 +759,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
index 5fe03624cf..c921d11d00 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
@@ -436,7 +436,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
var labelDef: scala.collection.Map[Symbol, LabelDef] = null// (LabelDef-sym -> LabelDef)
// bookkeeping the scopes of non-synthetic local vars, to emit debug info (`emitVars`).
- var varsInScope: List[Pair[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
+ var varsInScope: List[Tuple2[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
// helpers around program-points.
def lastInsn: asm.tree.AbstractInsnNode = {
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
index 916d118b6e..5be5abd895 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -90,11 +90,11 @@ abstract class BCodeTypes extends BCodeIdiomatic {
)
boxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.boxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.boxMethod)
yield (msym -> classLiteral(primitiveTypeMap(csym)))
unboxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.unboxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.unboxMethod)
yield (msym -> primitiveTypeMap(csym))
// boxed classes are looked up in the `exemplars` map by jvmWiseLUB().
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index 5e885fdd04..e92f8c2541 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -293,7 +293,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def inameToSymbol(iname: String): Symbol = {
val name = global.newTypeName(iname)
val res0 =
- if (nme.isModuleName(name)) rootMirror.getModule(name.dropModule)
+ if (nme.isModuleName(name)) rootMirror.getModuleByName(name.dropModule)
else rootMirror.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested).
assert(res0 != NoSymbol)
val res = jsymbol(res0)
@@ -335,7 +335,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
assert(a.isClass)
assert(b.isClass)
- val res = Pair(a.isInterface, b.isInterface) match {
+ val res = (a.isInterface, b.isInterface) match {
case (true, true) =>
global.lub(List(a.tpe, b.tpe)).typeSymbol // TODO assert == firstCommonSuffix of resp. parents
case (true, false) =>
@@ -1014,7 +1014,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
@@ -2156,7 +2156,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def getMerged(): scala.collection.Map[Local, List[Interval]] = {
// TODO should but isn't: unbalanced start(s) of scope(s)
- val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }
+ val shouldBeEmpty = pending filter { p => val (_, st) = p; st.nonEmpty }
val merged = mutable.Map[Local, List[Interval]]()
def addToMerged(lv: Local, start: Label, end: Label) {
val intv = Interval(start, end)
@@ -2169,7 +2169,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
(b) take the latest end (onePastLast if none available)
(c) merge the thus made-up interval
*/
- for(Pair(k, st) <- shouldBeEmpty) {
+ for((k, st) <- shouldBeEmpty) {
var start = st.toList.sortBy(_.getOffset).head
if(merged.isDefinedAt(k)) {
val balancedStart = merged(k).head.lstart
@@ -2206,25 +2206,25 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
}
// adding non-param locals
var anonCounter = 0
- var fltnd: List[Triple[String, Local, Interval]] = Nil
- for(Pair(local, ranges) <- scoping.getMerged()) {
+ var fltnd: List[Tuple3[String, Local, Interval]] = Nil
+ for((local, ranges) <- scoping.getMerged()) {
var name = javaName(local.sym)
if (name == null) {
anonCounter += 1
name = "<anon" + anonCounter + ">"
}
for(intrvl <- ranges) {
- fltnd ::= Triple(name, local, intrvl)
+ fltnd ::= (name, local, intrvl)
}
}
// quest for deterministic output that Map.toList doesn't provide (so that ant test.stability doesn't complain).
val srtd = fltnd.sortBy { kr =>
- val Triple(name: String, _, intrvl: Interval) = kr
+ val (name: String, _, intrvl: Interval) = kr
- Triple(intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
+ (intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
}
- for(Triple(name, local, Interval(start, end)) <- srtd) {
+ for((name, local, Interval(start, end)) <- srtd) {
jmethod.visitLocalVariable(name, descriptor(local.kind), null, start, end, indexOf(local))
}
// "There may be no more than one LocalVariableTable attribute per local variable in the Code attribute"
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 0cfcea87f8..0f317422ac 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -119,7 +119,7 @@ abstract class DeadCodeElimination extends SubComponent {
m foreachBlock { bb =>
useful(bb) = new mutable.BitSet(bb.size)
var rd = rdef.in(bb)
- for (Pair(i, idx) <- bb.toList.zipWithIndex) {
+ for ((i, idx) <- bb.toList.zipWithIndex) {
// utility for adding to worklist
def moveToWorkList() = moveToWorkListIf(cond = true)
@@ -137,7 +137,7 @@ abstract class DeadCodeElimination extends SubComponent {
i match {
case LOAD_LOCAL(_) =>
- defs = defs + Pair(((bb, idx)), rd.vars)
+ defs = defs + (((bb, idx), rd.vars))
moveToWorkListIf(cond = false)
case STORE_LOCAL(l) =>
@@ -350,7 +350,7 @@ abstract class DeadCodeElimination extends SubComponent {
val oldInstr = bb.toList
bb.open()
bb.clear()
- for (Pair(i, idx) <- oldInstr.zipWithIndex) {
+ for ((i, idx) <- oldInstr.zipWithIndex) {
if (useful(bb)(idx)) {
debuglog(" * " + i + " is useful")
bb.emit(i, i.pos)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 1578caff26..d194c095f8 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -144,7 +144,7 @@ object Plugin {
// (j, Try(descriptor))
def required(j: Path) = j -> loadDescriptionFromJar(j)
- type Paired = Pair[Path, Try[PluginDescription]]
+ type Paired = Tuple2[Path, Try[PluginDescription]]
val included: List[Paired] = (dirs flatMap (_ ifDirectory scan)).flatten
val exploded: List[Paired] = jars flatMap (_ ifDirectory explode)
val explicit: List[Paired] = jars flatMap (_ ifFile required)
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 0544da5d3c..68362c066d 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -80,10 +80,4 @@ abstract class Reporter {
WARNING.count = 0
cancelled = false
}
-
- // sbt compat
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- def countElementsAsString(n: Int, elements: String): String = StringOps.countElementsAsString(n, elements)
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- def countAsString(n: Int): String = StringOps.countAsString(n)
}
diff --git a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala
deleted file mode 100644
index 3aecc06b1e..0000000000
--- a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala
+++ /dev/null
@@ -1,99 +0,0 @@
-package scala.tools.nsc.scratchpad
-
-import java.io.{FileInputStream, InputStreamReader, IOException}
-
-import scala.collection.mutable.ArrayBuffer
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-class Mixer {
-
- protected val stdSeparator = "//> "
- protected val ctdSeparator = "//| "
- protected val sepColumn = 50
- protected val tabInc = 8
-
- type Comments = Seq[(Int, Array[Char])]
-
- def parseComments(comments: Array[Char]): Iterator[(Int, Array[Char])] = new Iterator[(Int, Array[Char])] {
- var idx = 0
- def hasNext = idx < comments.length
- def next() = {
- val nextSpace = comments indexOf (' ', idx)
- var nextNL = comments indexOf ('\n', nextSpace + 1)
- if (nextNL < 0) nextNL = comments.length
- val result =
- (new String(comments.slice(idx, nextSpace)).toInt, comments.slice(nextSpace + 1, nextNL))
- idx = nextNL + 1
- result
- }
- }
-
- def mix(source: Array[Char], comments: Array[Char]): Array[Char] = {
- val mixed = new ArrayBuffer[Char]
- var written = 0
- def align() = {
- var idx = mixed.lastIndexOf('\n') + 1
- var col = 0
- while (idx < mixed.length) {
- col =
- if (mixed(idx) == '\t') (col / tabInc) * tabInc + tabInc
- else col + 1
- idx += 1
- }
- if (col > sepColumn) {
- mixed += '\n'
- col = 0
- }
- while (col < sepColumn) {
- mixed += ' '
- col += 1
- }
- }
- for ((offset, cs) <- parseComments(comments)) {
- val sep =
- if (written < offset) {
- for (i <- written until offset) mixed += source(i)
- written = offset
- stdSeparator
- } else {
- mixed += '\n'
- ctdSeparator
- }
- align()
- mixed ++= sep ++= cs
- }
- mixed ++= source.view(written, source.length)
- mixed.toArray
- }
-
-}
-
-object Mixer extends Mixer {
-
- def contents(name: String): Array[Char] = {
- val page = new Array[Char](2 << 14)
- val buf = new ArrayBuffer[Char]
- val in = new FileInputStream(name)
- val rdr = new InputStreamReader(in)
- var nread = 0
- do {
- nread = rdr.read(page, 0, page.length)
- buf ++= (if (nread == page.length) page else page.take(nread))
- } while (nread >= 0)
- buf.toArray
- }
-
- def main(args: Array[String]) {
- val mixer = new Mixer
- try {
- require(args.length == 2, "required arguments: file1 file2")
- val source = contents(args(0))
- val comments = contents(args(1))
- val mixed = mixer.mix(source, comments)
- println(mixed.mkString)
- } catch {
- case ex: IOException =>
- println("error: "+ ex.getMessage)
- }
- }
-}
diff --git a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
deleted file mode 100644
index 61c1717fea..0000000000
--- a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-package scala.tools.nsc
-package scratchpad
-
-import scala.reflect.internal.Chars._
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-object SourceInserter {
- def stripRight(cs: Array[Char]): Array[Char] = {
- val lines =
- new String(cs) split "\n"
- def leftPart(str: String) =
- (str split """//>|//\|""").head
- def isContinuation(str: String) =
- ((str contains "//>") || (str contains "//|")) && (leftPart(str) forall isWhitespace)
- def stripTrailingWS(str: String) =
- str take (str lastIndexWhere (!isWhitespace(_))) + 1
- val prefixes =
- lines filterNot isContinuation map leftPart map stripTrailingWS
- (prefixes mkString "\n").toArray
- }
-}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 3d648ccbac..844774e75f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -217,112 +217,33 @@ abstract class UnCurry extends InfoTransform
// nullary or parameterless
case fun1 if fun1 ne fun => fun1
case _ =>
- val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
- val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation
- anonClass setInfo ClassInfoType(parents, newScope, anonClass)
-
- val targs = fun.tpe.typeArgs
- val (formals, restpe) = (targs.init, targs.last)
+ def typedFunPos(t: Tree) = localTyper.typedPos(fun.pos)(t)
+ val funParams = fun.vparams map (_.symbol)
+ def mkMethod(owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags): DefDef =
+ gen.mkMethodFromFunction(localTyper)(fun, owner, name, additionalFlags)
if (inlineFunctionExpansion) {
- val applyMethodDef = {
- val methSym = anonClass.newMethod(nme.apply, fun.pos, FINAL)
- val paramSyms = map2(formals, fun.vparams) {
- (tp, param) => methSym.newSyntheticValueParam(tp, param.name)
- }
- methSym setInfoAndEnter MethodType(paramSyms, restpe)
-
- fun.vparams foreach (_.symbol.owner = methSym)
- fun.body changeOwner (fun.symbol -> methSym)
-
- val body = localTyper.typedPos(fun.pos)(fun.body)
- val methDef = DefDef(methSym, List(fun.vparams), body)
+ val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
+ val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation
+ anonClass setInfo ClassInfoType(parents, newScope, anonClass)
- // Have to repack the type to avoid mismatches when existentials
- // appear in the result - see SI-4869.
- methDef.tpt setType localTyper.packedType(body, methSym)
- methDef
- }
+ val applyMethodDef = mkMethod(anonClass, nme.apply)
+ anonClass.info.decls enter applyMethodDef.symbol
- localTyper.typedPos(fun.pos) {
+ typedFunPos {
Block(
- List(ClassDef(anonClass, NoMods, ListOfNil, List(applyMethodDef), fun.pos)),
+ ClassDef(anonClass, NoMods, ListOfNil, List(applyMethodDef), fun.pos),
Typed(New(anonClass.tpe), TypeTree(fun.tpe)))
}
} else {
- /**
- * Abstracts away the common functionality required to create both
- * the lifted function and the apply method on the anonymous class
- * It creates a method definition with value params cloned from the
- * original lambda. Then it calls a supplied function to create
- * the body and types the result. Finally
- * everything is wrapped up in a MethodDef
- *
- * TODO it is intended that this common functionality be used
- * whether inlineFunctionExpansion is true or not. However, it
- * seems to introduce subtle ownwership changes that produce
- * binary incompatible changes and so it is completely
- * hidden behind the inlineFunctionExpansion for now.
- *
- * @param owner The owner for the new method
- * @param name name for the new method
- * @param additionalFlags flags to be put on the method in addition to FINAL
- * @bodyF function that turns the method symbol and list of value params
- * into a body for the method
- */
- def createMethod(owner: Symbol, name: TermName, additionalFlags: Long)(bodyF: (Symbol, List[ValDef]) => Tree) = {
- val methSym = owner.newMethod(name, fun.pos, FINAL | additionalFlags)
- val vparams = fun.vparams map (_.duplicate)
-
- val paramSyms = map2(formals, vparams) {
- (tp, vparam) => methSym.newSyntheticValueParam(tp, vparam.name)
- }
- foreach2(vparams, paramSyms){(valdef, sym) => valdef.symbol = sym}
- vparams foreach (_.symbol.owner = methSym)
-
- val methodType = MethodType(paramSyms, restpe.deconst)
- methSym setInfo methodType
-
- // TODO this is probably cleaner if bodyF only works with symbols rather than parameter ValDefs
- val tempBody = bodyF(methSym, vparams)
- val body = localTyper.typedPos(fun.pos)(tempBody)
- val methDef = DefDef(methSym, List(vparams), body)
-
- // Have to repack the type to avoid mismatches when existentials
- // appear in the result - see SI-4869.
- methDef.tpt setType localTyper.packedType(body, methSym).deconst
- methDef
- }
-
- val methodFlags = ARTIFACT
// method definition with the same arguments, return type, and body as the original lambda
- val liftedMethod = createMethod(fun.symbol.owner, tpnme.ANON_FUN_NAME.toTermName, methodFlags){
- case(methSym, vparams) =>
- fun.body.substituteSymbols(fun.vparams map (_.symbol), vparams map (_.symbol))
- fun.body changeOwner (fun.symbol -> methSym)
- }
-
- // callsite for the lifted method
- val args = fun.vparams map { vparam =>
- val ident = Ident(vparam.symbol)
- // if -Yeta-expand-keeps-star is turned on then T* types can get through. In order
- // to forward them we need to forward x: T* ascribed as "x:_*"
- if (settings.etaExpandKeepsStar && definitions.isRepeatedParamType(vparam.tpt.tpe))
- gen.wildcardStar(ident)
- else
- ident
- }
-
- val funTyper = localTyper.typedPos(fun.pos) _
-
- val liftedMethodCall = funTyper(Apply(liftedMethod.symbol, args:_*))
+ val liftedMethod = mkMethod(fun.symbol.owner, nme.ANON_FUN_NAME, additionalFlags = ARTIFACT)
// new function whose body is just a call to the lifted method
- val newFun = treeCopy.Function(fun, fun.vparams, liftedMethodCall)
- funTyper(Block(
- List(funTyper(liftedMethod)),
- super.transform(newFun)
- ))
+ val newFun = deriveFunction(fun)(_ => typedFunPos(
+ gen.mkForwarder(gen.mkAttributedRef(liftedMethod.symbol), funParams :: Nil)
+ ))
+ typedFunPos(Block(liftedMethod, super.transform(newFun)))
}
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 01acbb8cc2..fdec1edcc0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -388,11 +388,11 @@ trait Implicits {
*/
private def dominates(dtor: Type, dted: Type): Boolean = {
def core(tp: Type): Type = tp.dealiasWiden match {
- case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner)
+ case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner)
case AnnotatedType(annots, tp, selfsym) => core(tp)
- case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
- case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
- case _ => tp
+ case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
+ case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
+ case _ => tp
}
def stripped(tp: Type): Type = {
// `t.typeSymbol` returns the symbol of the normalized type. If that normalized type
@@ -401,23 +401,18 @@ trait Implicits {
val syms = for (t <- tp; if t.typeSymbol.isTypeParameter) yield t.typeSymbol
deriveTypeWithWildcards(syms.distinct)(tp)
}
- def sum(xs: List[Int]) = (0 /: xs)(_ + _)
- def complexity(tp: Type): Int = tp.dealiasWiden match {
- case NoPrefix =>
- 0
- case SingleType(pre, sym) =>
- if (sym.isPackage) 0 else complexity(tp.dealiasWiden)
- case TypeRef(pre, sym, args) =>
- complexity(pre) + sum(args map complexity) + 1
- case RefinedType(parents, _) =>
- sum(parents map complexity) + 1
- case _ =>
- 1
+ def complexity(tp: Type): Int = tp.dealias match {
+ case NoPrefix => 0
+ case SingleType(pre, sym) => if (sym.isPackage) 0 else complexity(tp.dealiasWiden)
+ case ThisType(sym) => if (sym.isPackage) 0 else 1
+ case TypeRef(pre, sym, args) => complexity(pre) + (args map complexity).sum + 1
+ case RefinedType(parents, _) => (parents map complexity).sum + 1
+ case _ => 1
}
def overlaps(tp1: Type, tp2: Type): Boolean = (tp1, tp2) match {
case (RefinedType(parents, _), _) => parents exists (overlaps(_, tp2))
case (_, RefinedType(parents, _)) => parents exists (overlaps(tp1, _))
- case _ => tp1.typeSymbol == tp2.typeSymbol
+ case _ => tp1.typeSymbol == tp2.typeSymbol
}
val dtor1 = stripped(core(dtor))
val dted1 = stripped(core(dted))
@@ -664,6 +659,8 @@ trait Implicits {
if (context.hasErrors)
fail("hasMatchingSymbol reported error: " + context.firstError.get.errMsg)
+ else if (itree3.isErroneous)
+ fail("error typechecking implicit candidate")
else if (isLocal && !hasMatchingSymbol(itree2))
fail("candidate implicit %s is shadowed by %s".format(
info.sym.fullLocationString, itree2.symbol.fullLocationString))
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 8594309818..355e52ce2b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1698,15 +1698,16 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
psym addChild context.owner
else
pending += ParentSealedInheritanceError(parent, psym)
+ val parentTypeOfThis = parent.tpe.dealias.typeOfThis
- if (!(selfType <:< parent.tpe.typeOfThis) &&
+ if (!(selfType <:< parentTypeOfThis) &&
!phase.erasedTypes &&
!context.owner.isSynthetic && // don't check synthetic concrete classes for virtuals (part of DEVIRTUALIZE)
!selfType.isErroneous &&
!parent.tpe.isErroneous)
{
pending += ParentSelfTypeConformanceError(parent, selfType)
- if (settings.explaintypes) explainTypes(selfType, parent.tpe.typeOfThis)
+ if (settings.explaintypes) explainTypes(selfType, parentTypeOfThis)
}
if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError))
diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala
index cb46004174..4237f36ade 100644
--- a/src/compiler/scala/tools/nsc/util/package.scala
+++ b/src/compiler/scala/tools/nsc/util/package.scala
@@ -90,51 +90,22 @@ package object util {
lazy val trace = new SimpleTracer(System.out)
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- val StringOps = scala.reflect.internal.util.StringOps
-
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- type StringOps = scala.reflect.internal.util.StringOps
-
- @deprecated("scala.reflect.internal.util.WeakHashSet", "2.10.0")
- type WeakHashSet[T <: AnyRef] = scala.reflect.internal.util.WeakHashSet[T]
-
- @deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0")
- val Position = scala.reflect.internal.util.Position
-
+ // These four deprecated since 2.10.0 are still used in (at least)
+ // the sbt 0.12.4 compiler interface.
@deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0")
type Position = scala.reflect.internal.util.Position
-
@deprecated("Moved to scala.reflect.internal.util.NoPosition", "2.10.0")
val NoPosition = scala.reflect.internal.util.NoPosition
-
@deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0")
val FakePos = scala.reflect.internal.util.FakePos
-
@deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0")
type FakePos = scala.reflect.internal.util.FakePos
- @deprecated("Moved to scala.reflect.internal.util.OffsetPosition", "2.10.0")
- type OffsetPosition = scala.reflect.internal.util.OffsetPosition
-
+ // These three were still used in scala-refactoring.
@deprecated("Moved to scala.reflect.internal.util.RangePosition", "2.10.0")
type RangePosition = scala.reflect.internal.util.RangePosition
-
@deprecated("Moved to scala.reflect.internal.util.SourceFile", "2.10.0")
type SourceFile = scala.reflect.internal.util.SourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.NoSourceFile", "2.10.0")
- val NoSourceFile = scala.reflect.internal.util.NoSourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.NoFile", "2.10.0")
- val NoFile = scala.reflect.internal.util.NoFile
-
- @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0")
- val ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0")
- type ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile
-
@deprecated("Moved to scala.reflect.internal.util.BatchSourceFile", "2.10.0")
type BatchSourceFile = scala.reflect.internal.util.BatchSourceFile
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
index 3901184c25..126c14ac81 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
@@ -55,9 +55,7 @@ trait Parsers { self: Quasiquotes =>
def isHole(name: Name): Boolean = holeMap.contains(name)
- override implicit def fresh: FreshNameCreator = new FreshNameCreator {
- override def newName(prefix: String) = super.newName(nme.QUASIQUOTE_PREFIX + prefix)
- }
+ override implicit def fresh: FreshNameCreator = new FreshNameCreator(nme.QUASIQUOTE_PREFIX)
override val treeBuilder = new ParserTreeBuilder {
override implicit def fresh: FreshNameCreator = parser.fresh
@@ -189,19 +187,5 @@ trait Parsers { self: Quasiquotes =>
}
}
- // Extractor that matches names which were generated by call to
- // freshTermName or freshTypeName within quasiquotes. Such names
- // have qq$some$random$prefix$0 shape where qq$ part is added
- // by modified fresh name creator in QuasiquoteParser.
- object FreshName {
- def unapply(name: Name): Option[String] =
- name.toString.split("\\$").toSeq match {
- case qq +: (middle :+ last)
- if qq + "$" == nme.QUASIQUOTE_PREFIX
- && Try(last.toInt).isSuccess && middle.nonEmpty =>
- Some(middle.mkString("", "$", "$"))
- case _ =>
- None
- }
- }
+ object FreshName extends FreshNameExtractor(nme.QUASIQUOTE_PREFIX)
} \ No newline at end of file
diff --git a/src/eclipse/partest/.classpath b/src/eclipse/partest/.classpath
index e2a66118b9..35528a276d 100644
--- a/src/eclipse/partest/.classpath
+++ b/src/eclipse/partest/.classpath
@@ -5,7 +5,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
<classpathentry kind="var" path="M2_REPO/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-tools/testing/test-interface/0.5/test-interface-0.5.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M6/1.0.0-RC7/scala-partest_2.11.0-M6-1.0.0-RC7.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M7/1.0.0-RC8/scala-partest_2.11.0-M7-1.0.0-RC8.jar"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_COMPILER_CONTAINER"/>
diff --git a/src/eclipse/scaladoc/.classpath b/src/eclipse/scaladoc/.classpath
index ac67fd2b03..c8f0e89b8a 100644
--- a/src/eclipse/scaladoc/.classpath
+++ b/src/eclipse/scaladoc/.classpath
@@ -6,8 +6,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
<classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11.0-M6/1.0.0-RC6/scala-xml_2.11.0-M6-1.0.0-RC6.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11.0-M6/1.0.0-RC4/scala-parser-combinators_2.11.0-M6-1.0.0-RC4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M6/1.0.0-RC7/scala-partest_2.11.0-M6-1.0.0-RC7.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11.0-M7/1.0.0-RC7/scala-xml_2.11.0-M7-1.0.0-RC7.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11.0-M7/1.0.0-RC5/scala-parser-combinators_2.11.0-M7-1.0.0-RC5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M7/1.0.0-RC8/scala-partest_2.11.0-M7-1.0.0-RC8.jar"/>
<classpathentry kind="output" path="build-quick-scaladoc"/>
</classpath>
diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
index d036a6e853..69cae24808 100644
--- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
@@ -62,17 +62,6 @@ trait CompilerControl { self: Global =>
def onUnitOf[T](source: SourceFile)(op: RichCompilationUnit => T): T =
op(unitOfFile.getOrElse(source.file, new RichCompilationUnit(source)))
- /** The compilation unit corresponding to a source file
- * if it does not yet exist create a new one atomically
- * Note: We want to get roid of this operation as it messes compiler invariants.
- */
- @deprecated("use getUnitOf(s) or onUnitOf(s) instead", "2.10.0")
- def unitOf(s: SourceFile): RichCompilationUnit = getOrCreateUnitOf(s)
-
- /** The compilation unit corresponding to a position */
- @deprecated("use getUnitOf(pos.source) or onUnitOf(pos.source) instead", "2.10.0")
- def unitOf(pos: Position): RichCompilationUnit = getOrCreateUnitOf(pos.source)
-
/** Removes the CompilationUnit corresponding to the given SourceFile
* from consideration for recompilation.
*/
@@ -229,18 +218,6 @@ trait CompilerControl { self: Global =>
def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) =
postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response))
- /** Set sync var `response` to a pair consisting of
- * - the fully qualified name of the first top-level object definition in the file.
- * or "" if there are no object definitions.
- * - the text of the instrumented program which, when run,
- * prints its output and all defined values in a comment column.
- *
- * @param source The source file to be analyzed
- * @param response The response.
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def askInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) =
- postWorkItem(new AskInstrumentedItem(source, line, response))
/** Cancels current compiler run and start a fresh one where everything will be re-typechecked
* (but not re-loaded).
@@ -250,11 +227,6 @@ trait CompilerControl { self: Global =>
/** Tells the compile server to shutdown, and not to restart again */
def askShutdown() = scheduler raise ShutdownReq
- @deprecated("use parseTree(source) instead", "2.10.0") // deleted 2nd parameter, as this has to run on 2.8 also.
- def askParse(source: SourceFile, response: Response[Tree]) = respond(response) {
- parseTree(source)
- }
-
/** Returns parse tree for source `source`. No symbols are entered. Syntax errors are reported.
*
* This method is thread-safe and as such can safely run outside of the presentation
@@ -419,15 +391,6 @@ trait CompilerControl { self: Global =>
response raise new MissingResponse
}
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- case class AskInstrumentedItem(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem {
- def apply() = self.getInstrumented(source, line, response)
- override def toString = "getInstrumented "+source
-
- def raiseMissing() =
- response raise new MissingResponse
- }
-
/** A do-nothing work scheduler that responds immediately with MissingResponse.
*
* Used during compiler shutdown.
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index da838e0f83..441398e443 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -18,6 +18,7 @@ import symtab.Flags.{ACCESSOR, PARAMACCESSOR}
import scala.annotation.{ elidable, tailrec }
import scala.language.implicitConversions
import scala.tools.nsc.typechecker.Typers
+import scala.util.control.Breaks._
/**
* This trait allows the IDE to have an instance of the PC that
@@ -100,7 +101,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
with CompilerControl
with ContextTrees
with RichCompilationUnits
- with ScratchPadMaker
with Picklers {
import definitions._
@@ -406,85 +406,91 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
*
*/
private[interactive] def pollForWork(pos: Position) {
- if (!interruptsEnabled) return
- if (pos == NoPosition || nodesSeen % yieldPeriod == 0)
- Thread.`yield`()
-
- def nodeWithWork(): Option[WorkEvent] =
- if (scheduler.moreWork || pendingResponse.isCancelled) Some(new WorkEvent(nodesSeen, System.currentTimeMillis))
- else None
-
- nodesSeen += 1
- logreplay("atnode", nodeWithWork()) match {
- case Some(WorkEvent(id, _)) =>
- debugLog("some work at node "+id+" current = "+nodesSeen)
-// assert(id >= nodesSeen)
- moreWorkAtNode = id
- case None =>
- }
+ var loop: Boolean = true
+ while (loop) {
+ breakable{
+ loop = false
+ if (!interruptsEnabled) return
+ if (pos == NoPosition || nodesSeen % yieldPeriod == 0)
+ Thread.`yield`()
+
+ def nodeWithWork(): Option[WorkEvent] =
+ if (scheduler.moreWork || pendingResponse.isCancelled) Some(new WorkEvent(nodesSeen, System.currentTimeMillis))
+ else None
+
+ nodesSeen += 1
+ logreplay("atnode", nodeWithWork()) match {
+ case Some(WorkEvent(id, _)) =>
+ debugLog("some work at node "+id+" current = "+nodesSeen)
+ // assert(id >= nodesSeen)
+ moreWorkAtNode = id
+ case None =>
+ }
- if (nodesSeen >= moreWorkAtNode) {
-
- logreplay("asked", scheduler.pollInterrupt()) match {
- case Some(ir) =>
- try {
- interruptsEnabled = false
- debugLog("ask started"+timeStep)
- ir.execute()
- } finally {
- debugLog("ask finished"+timeStep)
- interruptsEnabled = true
+ if (nodesSeen >= moreWorkAtNode) {
+
+ logreplay("asked", scheduler.pollInterrupt()) match {
+ case Some(ir) =>
+ try {
+ interruptsEnabled = false
+ debugLog("ask started"+timeStep)
+ ir.execute()
+ } finally {
+ debugLog("ask finished"+timeStep)
+ interruptsEnabled = true
+ }
+ loop = true; break
+ case _ =>
}
- pollForWork(pos)
- case _ =>
- }
-
- if (logreplay("cancelled", pendingResponse.isCancelled)) {
- throw CancelException
- }
-
- logreplay("exception thrown", scheduler.pollThrowable()) match {
- case Some(ex: FreshRunReq) =>
- newTyperRun()
- minRunId = currentRunId
- demandNewCompilerRun()
-
- case Some(ShutdownReq) =>
- scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
- val units = scheduler.dequeueAll {
- case item: WorkItem => Some(item.raiseMissing())
- case _ => Some(())
- }
-
- // don't forget to service interrupt requests
- scheduler.dequeueAllInterrupts(_.execute())
-
- debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size))
- debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)"
- .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size))
- checkNoResponsesOutstanding()
- log.flush()
- scheduler = new NoWorkScheduler
- throw ShutdownReq
+ if (logreplay("cancelled", pendingResponse.isCancelled)) {
+ throw CancelException
}
- case Some(ex: Throwable) => log.flush(); throw ex
- case _ =>
- }
-
- lastWasReload = false
+ logreplay("exception thrown", scheduler.pollThrowable()) match {
+ case Some(ex: FreshRunReq) =>
+ newTyperRun()
+ minRunId = currentRunId
+ demandNewCompilerRun()
+
+ case Some(ShutdownReq) =>
+ scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
+ val units = scheduler.dequeueAll {
+ case item: WorkItem => Some(item.raiseMissing())
+ case _ => Some(())
+ }
+
+ // don't forget to service interrupt requests
+ scheduler.dequeueAllInterrupts(_.execute())
+
+ debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size))
+ debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)"
+ .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size))
+ checkNoResponsesOutstanding()
+
+ log.flush()
+ scheduler = new NoWorkScheduler
+ throw ShutdownReq
+ }
+
+ case Some(ex: Throwable) => log.flush(); throw ex
+ case _ =>
+ }
- logreplay("workitem", scheduler.nextWorkItem()) match {
- case Some(action) =>
- try {
- debugLog("picked up work item at "+pos+": "+action+timeStep)
- action()
- debugLog("done with work item: "+action)
- } finally {
- debugLog("quitting work item: "+action+timeStep)
+ lastWasReload = false
+
+ logreplay("workitem", scheduler.nextWorkItem()) match {
+ case Some(action) =>
+ try {
+ debugLog("picked up work item at "+pos+": "+action+timeStep)
+ action()
+ debugLog("done with work item: "+action)
+ } finally {
+ debugLog("quitting work item: "+action+timeStep)
+ }
+ case None =>
}
- case None =>
+ }
}
}
}
@@ -1171,18 +1177,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
}
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def getInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) {
- try {
- interruptsEnabled = false
- respond(response) {
- instrument(source, line)
- }
- } finally {
- interruptsEnabled = true
- }
- }
-
// ---------------- Helper classes ---------------------------
/** The typer run */
diff --git a/src/interactive/scala/tools/nsc/interactive/REPL.scala b/src/interactive/scala/tools/nsc/interactive/REPL.scala
index 33981771ec..8e9b0ceee0 100644
--- a/src/interactive/scala/tools/nsc/interactive/REPL.scala
+++ b/src/interactive/scala/tools/nsc/interactive/REPL.scala
@@ -9,7 +9,6 @@ package interactive
import scala.reflect.internal.util._
import scala.tools.nsc.reporters._
import scala.tools.nsc.io._
-import scala.tools.nsc.scratchpad.SourceInserter
import java.io.FileWriter
/** Interface of interactive compiler to a client such as an IDE
@@ -89,8 +88,6 @@ object REPL {
val completeResult = new Response[List[comp.Member]]
val typedResult = new Response[comp.Tree]
val structureResult = new Response[comp.Tree]
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- val instrumentedResult = new Response[(String, Array[Char])]
def makePos(file: String, off1: String, off2: String) = {
val source = toSourceFile(file)
@@ -112,52 +109,6 @@ object REPL {
show(structureResult)
}
- /** Write instrumented source file to disk.
- * @param iFullName The full name of the first top-level object in source
- * @param iContents An Array[Char] containing the instrumented source
- * @return The name of the instrumented source file
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def writeInstrumented(iFullName: String, suffix: String, iContents: Array[Char]): String = {
- val iSimpleName = iFullName drop ((iFullName lastIndexOf '.') + 1)
- val iSourceName = iSimpleName + suffix
- val ifile = new FileWriter(iSourceName)
- ifile.write(iContents)
- ifile.close()
- iSourceName
- }
-
- /** The method for implementing worksheet functionality.
- * @param arguments a file name, followed by optional command line arguments that are passed
- * to the compiler that processes the instrumented source.
- * @param line A line number that controls uop to which line results should be produced
- * If line = -1, results are produced for all expressions in the worksheet.
- * @return The generated file content containing original source in the left column
- * and outputs in the right column, or None if the presentation compiler
- * does not respond to askInstrumented.
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def instrument(arguments: List[String], line: Int): Option[(String, String)] = {
- val source = toSourceFile(arguments.head)
- // strip right hand side comment column and any trailing spaces from all lines
- val strippedContents = SourceInserter.stripRight(source.content)
- val strippedSource = new BatchSourceFile(source.file, strippedContents)
- println("stripped source = "+strippedSource+":"+strippedContents.mkString)
- comp.askReload(List(strippedSource), reloadResult)
- comp.askInstrumented(strippedSource, line, instrumentedResult)
- using(instrumentedResult) {
- case (iFullName, iContents) =>
- println(s"instrumented source $iFullName = ${iContents.mkString}")
- val iSourceName = writeInstrumented(iFullName, "$instrumented.scala", iContents)
- val sSourceName = writeInstrumented(iFullName, "$stripped.scala", strippedContents)
- (iSourceName, sSourceName)
-/*
- * val vdirOpt = compileInstrumented(iSourceName, arguments.tail)
- runInstrumented(vdirOpt, iFullName, strippedSource.content)
- */
- }
- }
-
loop { line =>
(line split " ").toList match {
case "reload" :: args =>
@@ -177,10 +128,6 @@ object REPL {
doComplete(makePos(file, off1, off2))
case List("complete", file, off1) =>
doComplete(makePos(file, off1, off1))
- case "instrument" :: arguments =>
- println(instrument(arguments, -1))
- case "instrumentTo" :: line :: arguments =>
- println(instrument(arguments, line.toInt))
case List("quit") =>
comp.askShutdown()
sys.exit(1)
@@ -195,8 +142,6 @@ object REPL {
| typeat <file> <pos>
| complete <file> <start-pos> <end-pos>
| compile <file> <pos>
- | instrument <file> <arg>*
- | instrumentTo <line-num> <file> <arg>*
| structure <file>
| quit
|""".stripMargin)
diff --git a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala
deleted file mode 100644
index 2400b97d97..0000000000
--- a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala
+++ /dev/null
@@ -1,201 +0,0 @@
-package scala
-package tools.nsc
-package interactive
-
-import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition}
-import scala.collection.mutable.ArrayBuffer
-import scala.reflect.internal.Chars.{isLineBreakChar, isWhitespace}
-import ast.parser.Tokens._
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-trait ScratchPadMaker { self: Global =>
-
- import definitions._
-
- private case class Patch(offset: Int, text: String)
-
- private class Patcher(contents: Array[Char], lex: LexicalStructure, endOffset: Int) extends Traverser {
- var objectName: String = ""
-
- private val patches = new ArrayBuffer[Patch]
- private val toPrint = new ArrayBuffer[String]
- private var skipped = 0
- private var resNum: Int = -1
-
- private def nextRes(): String = {
- resNum += 1
- "res$"+resNum
- }
-
- private def nameType(name: String, tpe: Type): String = {
- // if name ends in symbol character, add a space to separate it from the following ':'
- val pad = if (Character.isLetter(name.last) || Character.isDigit(name.last)) "" else " "
- name+pad+": "+tpe
- }
-
- private def nameType(sym: Symbol): String = nameType(sym.name.decoded, sym.tpe)
-
- private def literal(str: String) = "\"\"\""+str+"\"\"\""
-
- private val prologue = ";import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{"
-
- private val epilogue = "}"
-
- private def applyPendingPatches(offset: Int) = {
- if (skipped == 0) patches += Patch(offset, prologue)
- for (msg <- toPrint) patches += Patch(offset, ";System.out.println("+msg+")")
- toPrint.clear()
- }
-
- /** The position where to insert an instrumentation statement in front of given statement.
- * This is at the latest `stat.pos.start`. But in order not to mess with column numbers
- * in position we try to insert it at the end of the previous token instead.
- * Furthermore, `(' tokens have to be skipped because they do not show up
- * in statement range positions.
- */
- private def instrumentPos(start: Int): Int = {
- val (prevToken, prevStart, prevEnd) = lex.locate(start - 1)
- if (prevStart >= start) start
- else if (prevToken == LPAREN) instrumentPos(prevStart)
- else prevEnd
- }
-
- private def addSkip(stat: Tree): Unit = {
- val ipos = instrumentPos(stat.pos.start)
- if (stat.pos.start > skipped) applyPendingPatches(ipos)
- if (stat.pos.start >= endOffset)
- patches += Patch(ipos, ";$stop()")
- var end = stat.pos.end
- if (end > skipped) {
- while (end < contents.length && !isLineBreakChar(contents(end))) end += 1
- patches += Patch(ipos, ";$skip("+(end-skipped)+"); ")
- skipped = end
- }
- }
-
- private def addSandbox(expr: Tree) = {}
-// patches += (Patch(expr.pos.start, "sandbox("), Patch(expr.pos.end, ")"))
-
- private def resultString(prefix: String, expr: String) =
- literal(prefix + " = ") + " + $show(" + expr + ")"
-
- private def traverseStat(stat: Tree) =
- if (stat.pos.isInstanceOf[RangePosition]) {
- stat match {
- case ValDef(_, _, _, rhs) =>
- addSkip(stat)
- if (stat.symbol.isLazy)
- toPrint += literal(nameType(stat.symbol) + " = <lazy>")
- else if (!stat.symbol.isSynthetic) {
- addSandbox(rhs)
- toPrint += resultString(nameType(stat.symbol), stat.symbol.name.toString)
- }
- case DefDef(_, _, _, _, _, _) =>
- addSkip(stat)
- toPrint += literal(nameType(stat.symbol))
- case Annotated(_, arg) =>
- traverse(arg)
- case DocDef(_, defn) =>
- traverse(defn)
- case _ =>
- if (stat.isTerm) {
- addSkip(stat)
- if (stat.tpe.typeSymbol == UnitClass) {
- addSandbox(stat)
- } else {
- val resName = nextRes()
- val dispResName = resName filter ('$' != _)
- val offset = instrumentPos(stat.pos.start)
- patches += Patch(offset, "val " + resName + " = ")
- addSandbox(stat)
- toPrint += resultString(nameType(dispResName, stat.tpe), resName)
- }
- }
- }
- }
-
- override def traverse(tree: Tree): Unit = tree match {
- case PackageDef(_, _) =>
- super.traverse(tree)
- case ModuleDef(_, name, Template(_, _, body)) =>
- val topLevel = objectName.isEmpty
- if (topLevel) {
- objectName = tree.symbol.fullName
- body foreach traverseStat
- if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements
- applyPendingPatches(skipped)
- patches += Patch(skipped, epilogue)
- }
- }
- case _ =>
- }
-
- /** The patched text.
- * @require traverse is run first
- */
- def result: Array[Char] = {
- val reslen = contents.length + (patches map (_.text.length)).sum
- val res = Array.ofDim[Char](reslen)
- var lastOffset = 0
- var from = 0
- var to = 0
- for (Patch(offset, text) <- patches) {
- val delta = offset - lastOffset
- assert(delta >= 0)
- Array.copy(contents, from, res, to, delta)
- from += delta
- to += delta
- lastOffset = offset
- text.copyToArray(res, to)
- to += text.length
- }
- assert(contents.length - from == reslen - to)
- Array.copy(contents, from, res, to, contents.length - from)
- res
- }
- }
-
- class LexicalStructure(source: SourceFile) {
- val token = new ArrayBuffer[Int]
- val startOffset = new ArrayBuffer[Int]
- val endOffset = new ArrayBuffer[Int]
- private val scanner = new syntaxAnalyzer.UnitScanner(new CompilationUnit(source))
- scanner.init()
- while (scanner.token != EOF) {
- startOffset += scanner.offset
- token += scanner.token
- scanner.nextToken()
- endOffset += scanner.lastOffset
- }
-
- /** @return token that starts before or at offset, its startOffset, its endOffset
- */
- def locate(offset: Int): (Int, Int, Int) = {
- var lo = 0
- var hi = token.length - 1
- while (lo < hi) {
- val mid = (lo + hi + 1) / 2
- if (startOffset(mid) <= offset) lo = mid
- else hi = mid - 1
- }
- (token(lo), startOffset(lo), endOffset(lo))
- }
- }
-
- /** Compute an instrumented version of a sourcefile.
- * @param source The given sourcefile.
- * @param line The line up to which results should be printed, -1 = whole document.
- * @return A pair consisting of
- * - the fully qualified name of the first top-level object definition in the file.
- * or "" if there are no object definitions.
- * - the text of the instrumented program which, when run,
- * prints its output and all defined values in a comment column.
- */
- protected def instrument(source: SourceFile, line: Int): (String, Array[Char]) = {
- val tree = typedTree(source, forceReload = true)
- val endOffset = if (line < 0) source.length else source.lineToOffset(line + 1)
- val patcher = new Patcher(source.content, new LexicalStructure(source), endOffset)
- patcher.traverse(tree)
- (patcher.objectName, patcher.result)
- }
-}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index cd96b5182c..8900450fa3 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -26,8 +26,6 @@ import scala.io.ReadStdin
* [[scala.collection.immutable.Set]], and the [[scala.collection.immutable.List]]
* constructors ([[scala.collection.immutable.::]] and
* [[scala.collection.immutable.Nil]]).
- * The types `Pair` (a [[scala.Tuple2]]) and `Triple` (a [[scala.Tuple3]]), with
- * simple constructors, are also provided.
*
* === Console I/O ===
* Predef provides a number of simple functions for console I/O, such as
@@ -230,13 +228,17 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
// tupling ------------------------------------------------------------
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
type Pair[+A, +B] = Tuple2[A, B]
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
object Pair {
def apply[A, B](x: A, y: B) = Tuple2(x, y)
def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
}
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
type Triple[+A, +B, +C] = Tuple3[A, B, C]
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
object Triple {
def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z)
def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
diff --git a/src/library/scala/annotation/migration.scala b/src/library/scala/annotation/migration.scala
index 65bee4c2cb..e71be00f32 100644
--- a/src/library/scala/annotation/migration.scala
+++ b/src/library/scala/annotation/migration.scala
@@ -25,7 +25,4 @@ package scala.annotation
*
* @since 2.8
*/
- private[scala] final class migration(message: String, changedIn: String) extends scala.annotation.StaticAnnotation {
- @deprecated("Use the constructor taking two Strings instead.", "2.10.0")
- def this(majorVersion: Int, minorVersion: Int, message: String) = this(message, majorVersion + "." + minorVersion)
- }
+ private[scala] final class migration(message: String, changedIn: String) extends scala.annotation.StaticAnnotation
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 34b2346851..00f398a4b0 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -117,22 +117,6 @@ extends scala.collection.AbstractSeq[Int]
fail()
}
- @deprecated("Range.foreach() is now self-contained, making this auxiliary method redundant.", "2.10.1")
- def validateRangeBoundaries(f: Int => Any): Boolean = {
- validateMaxLength()
-
- start != Int.MinValue || end != Int.MinValue || {
- var count = 0
- var num = start
- while (count < numRangeElements) {
- f(num)
- count += 1
- num += step
- }
- false
- }
- }
-
final def apply(idx: Int): Int = {
validateMaxLength()
if (idx < 0 || idx >= numRangeElements) throw new IndexOutOfBoundsException(idx.toString)
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 418d859d79..b15601058e 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -82,11 +82,11 @@ private[concurrent] object Promise {
* 2. Complete, with a result.
* 3. Linked to another DefaultPromise.
*
- * If a DefaultPromise is linked it another DefaultPromise then it will
+ * If a DefaultPromise is linked to another DefaultPromise, it will
* delegate all its operations to that other promise. This means that two
* DefaultPromises that are linked will appear, to external callers, to have
- * exactly the same state and behaviour. E.g. they will both appear to be
- * either complete or incomplete, and with the same values.
+ * exactly the same state and behaviour. For instance, both will appear as
+ * incomplete, or as complete with the same result value.
*
* A DefaultPromise stores its state entirely in the AnyRef cell exposed by
* AbstractPromise. The type of object stored in the cell fully describes the
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index 0a2da16523..d783dd29f5 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -158,8 +158,7 @@ object BigDecimal {
* @author Stephane Micheloud
* @version 1.0
*/
-@deprecatedInheritance("This class will be made final.", "2.10.0")
-class BigDecimal(
+final class BigDecimal(
val bigDecimal: BigDec,
val mc: MathContext)
extends ScalaNumber with ScalaNumericConversions with Serializable {
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala
index b25dbefebd..5e70bdc2f6 100644
--- a/src/library/scala/math/BigInt.scala
+++ b/src/library/scala/math/BigInt.scala
@@ -109,8 +109,7 @@ object BigInt {
* @author Martin Odersky
* @version 1.0, 15/07/2003
*/
-@deprecatedInheritance("This class will be made final.", "2.10.0")
-class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
+final class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
/** Returns the hash code for this BigInt. */
override def hashCode(): Int =
if (isValidLong) unifiedPrimitiveHashcode()
diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
index 798746851a..ca7a3cddb8 100644
--- a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
+++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
@@ -16,6 +16,7 @@ import java.lang.{ Class => jClass }
trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
self: ClassManifest[T] =>
+ // Still in use in target test.junit.comp.
@deprecated("Use runtimeClass instead", "2.10.0")
def erasure: jClass[_] = runtimeClass
@@ -64,12 +65,12 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
// when the erasure is the same, even before considering variance.
!cannotMatch && {
// this part is wrong for not considering variance
- if (this.erasure == that.erasure)
+ if (this.runtimeClass == that.runtimeClass)
subargs(this.typeArguments, that.typeArguments)
// this part is wrong for punting unless the rhs has no type
// arguments, but it's better than a blindfolded pinata swing.
else
- that.typeArguments.isEmpty && subtype(this.erasure, that.erasure)
+ that.typeArguments.isEmpty && subtype(this.runtimeClass, that.runtimeClass)
}
}
@@ -91,29 +92,29 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
@deprecated("Use wrap instead", "2.10.0")
def arrayManifest: ClassManifest[Array[T]] =
- ClassManifest.classType[Array[T]](arrayClass[T](erasure), this)
+ ClassManifest.classType[Array[T]](arrayClass[T](runtimeClass), this)
override def newArray(len: Int): Array[T] =
- java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]]
+ java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]]
@deprecated("Use wrap.newArray instead", "2.10.0")
def newArray2(len: Int): Array[Array[T]] =
- java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len)
+ java.lang.reflect.Array.newInstance(arrayClass[T](runtimeClass), len)
.asInstanceOf[Array[Array[T]]]
@deprecated("Use wrap.wrap.newArray instead", "2.10.0")
def newArray3(len: Int): Array[Array[Array[T]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](runtimeClass)), len)
.asInstanceOf[Array[Array[Array[T]]]]
@deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0")
def newArray4(len: Int): Array[Array[Array[Array[T]]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass))), len)
.asInstanceOf[Array[Array[Array[Array[T]]]]]
@deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0")
def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass)))), len)
.asInstanceOf[Array[Array[Array[Array[Array[T]]]]]]
@deprecated("Create WrappedArray directly instead", "2.10.0")
@@ -131,7 +132,7 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
protected def argString =
if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]")
- else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]"
+ else if (runtimeClass.isArray) "["+ClassManifest.fromClass(runtimeClass.getComponentType)+"]"
else ""
}
@@ -221,7 +222,7 @@ object ClassManifestFactory {
*/
def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] =
new ClassManifest[T] {
- override def runtimeClass = upperbound.erasure
+ override def runtimeClass = upperbound.runtimeClass
override val typeArguments = args.toList
override def toString = prefix.toString+"#"+name+argString
}
@@ -236,6 +237,6 @@ private class ClassTypeManifest[T](
{
override def toString =
(if (prefix.isEmpty) "" else prefix.get.toString+"#") +
- (if (erasure.isArray) "Array" else erasure.getName) +
+ (if (runtimeClass.isArray) "Array" else runtimeClass.getName) +
argString
} \ No newline at end of file
diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala
index 3bc76da295..803c980058 100644
--- a/src/library/scala/reflect/Manifest.scala
+++ b/src/library/scala/reflect/Manifest.scala
@@ -46,7 +46,7 @@ trait Manifest[T] extends ClassManifest[T] with Equals {
override def typeArguments: List[Manifest[_]] = Nil
override def arrayManifest: Manifest[Array[T]] =
- Manifest.classType[Array[T]](arrayClass[T](erasure), this)
+ Manifest.classType[Array[T]](arrayClass[T](runtimeClass), this)
override def canEqual(that: Any): Boolean = that match {
case _: Manifest[_] => true
@@ -56,10 +56,10 @@ trait Manifest[T] extends ClassManifest[T] with Equals {
* faster than <:< and rules out most comparisons.
*/
override def equals(that: Any): Boolean = that match {
- case m: Manifest[_] => (m canEqual this) && (this.erasure == m.erasure) && (this <:< m) && (m <:< this)
+ case m: Manifest[_] => (m canEqual this) && (this.runtimeClass == m.runtimeClass) && (this <:< m) && (m <:< this)
case _ => false
}
- override def hashCode = this.erasure.##
+ override def hashCode = this.runtimeClass.##
}
// TODO undeprecated until Scala reflection becomes non-experimental
@@ -238,7 +238,7 @@ object ManifestFactory {
override val typeArguments: List[Manifest[_]]) extends Manifest[T] {
override def toString =
(if (prefix.isEmpty) "" else prefix.get.toString+"#") +
- (if (erasure.isArray) "Array" else erasure.getName) +
+ (if (runtimeClass.isArray) "Array" else runtimeClass.getName) +
argString
}
@@ -259,7 +259,7 @@ object ManifestFactory {
*/
def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] =
new Manifest[T] {
- def runtimeClass = upperBound.erasure
+ def runtimeClass = upperBound.runtimeClass
override def toString =
"_" +
(if (lowerBound eq Nothing) "" else " >: "+lowerBound) +
@@ -269,7 +269,7 @@ object ManifestFactory {
/** Manifest for the intersection type `parents_0 with ... with parents_n'. */
def intersectionType[T](parents: Manifest[_]*): Manifest[T] =
new Manifest[T] {
- def runtimeClass = parents.head.erasure
+ def runtimeClass = parents.head.runtimeClass
override def toString = parents.mkString(" with ")
}
}
diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala
deleted file mode 100644
index d86f8873aa..0000000000
--- a/src/library/scala/runtime/WorksheetSupport.scala
+++ /dev/null
@@ -1,93 +0,0 @@
-package scala.runtime
-import java.io.{OutputStream, PrintStream}
-import scala.runtime.ScalaRunTime.stringOf
-
-/** A utility object that's needed by the code that executes a worksheet.
- */
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-object WorksheetSupport {
-
- /** The offset in the source which should be printed */
- private var currentOffset = 0
-
- /** A stream that flushes in regular intervals so that output can be captured
- * in real time. The flush interval is determined by the field "flushInterval".
- * By default it is 30ms.
- */
- private class FlushedOutputStream(out: OutputStream) extends OutputStream {
- protected def flushInterval = 30000000L // interval between flushes, by default 30ms
- protected def width = 80 // output width, by default 80 characters
- protected def tabInc = 8 // tab increment, by default 8 characters
- private var lastFlush: Long = 0L
- private var col = -1
- override def write(b: Array[Byte], off: Int, len: Int) = {
- for (idx <- off until (off + len min b.length)) writeOne(b(idx).toInt)
- flush()
- }
- override def write(c: Int) {
- writeOne(c)
- flush()
- }
- override def flush() {
- val current = System.nanoTime
- if (current - lastFlush >= flushInterval) {
- out.flush()
- lastFlush = current
- }
- }
- def writeOne(c: Int) {
- if (col < 0) {
- col = 0
- write((currentOffset+" ").getBytes)
- }
- out.write(c)
- col =
- if (c == '\n') -1
- else if (c == '\t') (col / tabInc) * tabInc + tabInc
- else col + 1
- if (col >= width) writeOne('\n')
- }
- def ensureNewLine() = if (col > 0) writeOne('\n')
- }
-
- private val flushedOut = new FlushedOutputStream(System.out)
- private val printOut = new PrintStream(flushedOut)
-
- private def redirected(op: => Unit) = {
- val oldSysOut = System.out
- val oldSysErr = System.err
- val oldConsOut = Console.out
- val oldConsErr = Console.err
- System.setOut(printOut)
- System.setErr(printOut)
- Console.setOut(printOut)
- Console.setErr(printOut)
- try op
- finally {
- printOut.close()
- System.setOut(oldSysOut)
- System.setErr(oldSysErr)
- Console.setOut(oldConsOut)
- Console.setErr(oldConsErr)
- }
- }
-
- def $execute(op: => Unit) = redirected {
- try op
- catch {
- case ex: StopException => ;
- case ex: Throwable => ex.printStackTrace()
- }
- }
-
- def $skip(n: Int) = {
- flushedOut.ensureNewLine()
- currentOffset += n
- }
-
- def $stop() = throw new StopException
-
- def $show(x: Any): String = stringOf(x)
-}
-
-class StopException extends Exception
diff --git a/src/library/scala/util/control/NonFatal.scala b/src/library/scala/util/control/NonFatal.scala
index 11fb988e8e..9d3dfea074 100644
--- a/src/library/scala/util/control/NonFatal.scala
+++ b/src/library/scala/util/control/NonFatal.scala
@@ -11,9 +11,8 @@ package util.control
/**
* Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError`
- * (for example, `OutOfMemoryError`, a subclass of `VirtualMachineError`), `ThreadDeath`,
+ * (for example, `OutOfMemoryError` and `StackOverflowError`, subclasses of `VirtualMachineError`), `ThreadDeath`,
* `LinkageError`, `InterruptedException`, `ControlThrowable`.
- * However, `StackOverflowError` is matched, i.e. considered non-fatal.
*
* Note that [[scala.util.control.ControlThrowable]], an internal Throwable, is not matched by
* `NonFatal` (and would therefore be thrown).
@@ -34,7 +33,6 @@ object NonFatal {
* Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal
*/
def apply(t: Throwable): Boolean = t match {
- case _: StackOverflowError => true // StackOverflowError ok even though it is a VirtualMachineError
// VirtualMachineError includes OutOfMemoryError and other fatal errors
case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable => false
case _ => true
diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index c85664349e..1bfaeb255b 100644
--- a/src/library/scala/util/hashing/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -275,12 +275,4 @@ object MurmurHash3 extends MurmurHash3 {
finalizeHash(h, n)
}
*/
-
- @deprecated("Use unorderedHash", "2.10.0")
- final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int =
- unorderedHash(xs.seq, seed)
-
- @deprecated("Use orderedHash", "2.10.0")
- final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int =
- orderedHash(xs.seq, seed)
}
diff --git a/src/reflect/scala/reflect/api/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala
index 6fc76c9693..df5e0699a5 100644
--- a/src/reflect/scala/reflect/api/JavaUniverse.scala
+++ b/src/reflect/scala/reflect/api/JavaUniverse.scala
@@ -34,7 +34,7 @@ trait JavaUniverse extends Universe with JavaMirrors { self =>
mirror.universe match {
case ju: JavaUniverse =>
val jm = mirror.asInstanceOf[ju.Mirror]
- val sym = jm.classSymbol(manifest.erasure)
+ val sym = jm.classSymbol(manifest.runtimeClass)
val tpe =
if (manifest.typeArguments.isEmpty) sym.toType
else ju.appliedType(sym.toTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe))
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 563f23cb3b..19f06894c8 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -16,7 +16,7 @@ import scala.reflect.api.{Universe => ApiUniverse}
trait Definitions extends api.StandardDefinitions {
self: SymbolTable =>
- import rootMirror.{getModule, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule}
+ import rootMirror.{getModuleByName, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule}
object definitions extends DefinitionsClass
@@ -87,7 +87,7 @@ trait Definitions extends api.StandardDefinitions {
lazy val abbrvTag = symbolsMap(ScalaValueClasses, nameToTag) withDefaultValue OBJECT_TAG
lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight)
- lazy val boxedModule = classesMap(x => getModule(boxedName(x)))
+ lazy val boxedModule = classesMap(x => getModuleByName(boxedName(x)))
lazy val boxedClass = classesMap(x => getClassByName(boxedName(x)))
lazy val refClass = classesMap(x => getRequiredClass("scala.runtime." + x + "Ref"))
lazy val volatileRefClass = classesMap(x => getRequiredClass("scala.runtime.Volatile" + x + "Ref"))
@@ -153,18 +153,6 @@ trait Definitions extends api.StandardDefinitions {
private var isInitialized = false
def isDefinitionsInitialized = isInitialized
- @deprecated("Moved to rootMirror.RootPackage", "2.10.0")
- val RootPackage: ModuleSymbol = rootMirror.RootPackage
-
- @deprecated("Moved to rootMirror.RootClass", "2.10.0")
- val RootClass: ClassSymbol = rootMirror.RootClass
-
- @deprecated("Moved to rootMirror.EmptyPackage", "2.10.0")
- val EmptyPackage: ModuleSymbol = rootMirror.EmptyPackage
-
- @deprecated("Moved to rootMirror.EmptyPackageClass", "2.10.0")
- val EmptyPackageClass: ClassSymbol = rootMirror.EmptyPackageClass
-
// It becomes tricky to create dedicated objects for other symbols because
// of initialization order issues.
lazy val JavaLangPackage = getPackage("java.lang")
diff --git a/src/reflect/scala/reflect/internal/FreshNames.scala b/src/reflect/scala/reflect/internal/FreshNames.scala
new file mode 100644
index 0000000000..bb488aa2a8
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/FreshNames.scala
@@ -0,0 +1,35 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ */
+
+package scala
+package reflect
+package internal
+
+import scala.reflect.internal.util.FreshNameCreator
+
+trait FreshNames { self: Names =>
+ // default fresh name creator used to abstract over currentUnit.fresh and runtime fresh name creator
+ def currentFreshNameCreator: FreshNameCreator
+
+ // create fresh term/type name using implicit fresh name creator
+ def freshTermName(prefix: String = "x$")(implicit creator: FreshNameCreator): TermName = newTermName(creator.newName(prefix))
+ def freshTypeName(prefix: String)(implicit creator: FreshNameCreator): TypeName = newTypeName(creator.newName(prefix))
+
+ // Extractor that matches names which were generated by some
+ // FreshNameCreator with known prefix. Extracts user-specified
+ // prefix that was used as a parameter to newName by stripping
+ // global creator prefix and unique number in the end of the name.
+ class FreshNameExtractor(creatorPrefix: String = "") {
+ // quote prefix so that it can be used with replaceFirst
+ // which expects regExp rather than simple string
+ val quotedCreatorPrefix = java.util.regex.Pattern.quote(creatorPrefix)
+
+ def unapply(name: Name): Option[String] = {
+ val sname = name.toString
+ // name should start with creatorPrefix and end with number
+ if (!sname.startsWith(creatorPrefix) || !sname.matches("^.*\\d*$")) None
+ else Some(NameTransformer.decode(sname.replaceFirst(quotedCreatorPrefix, "").replaceAll("\\d*$", "")))
+ }
+ }
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala
index e122fa498b..3a630b6a16 100644
--- a/src/reflect/scala/reflect/internal/Mirrors.scala
+++ b/src/reflect/scala/reflect/internal/Mirrors.scala
@@ -96,10 +96,6 @@ trait Mirrors extends api.Mirrors {
}
}
- @deprecated("Use getClassByName", "2.10.0")
- def getClass(fullname: Name): ClassSymbol =
- getClassByName(fullname)
-
def getClassByName(fullname: Name): ClassSymbol =
ensureClassSymbol(fullname.toString, getModuleOrClass(fullname.toTypeName))
@@ -131,15 +127,11 @@ trait Mirrors extends api.Mirrors {
case _ => MissingRequirementError.notFound("object " + fullname)
}
- @deprecated("Use getModuleByName", "2.10.0")
- def getModule(fullname: Name): ModuleSymbol =
- getModuleByName(fullname)
-
def getModuleByName(fullname: Name): ModuleSymbol =
ensureModuleSymbol(fullname.toString, getModuleOrClass(fullname.toTermName), allowPackages = true)
def getRequiredModule(fullname: String): ModuleSymbol =
- getModule(newTermNameCached(fullname))
+ getModuleByName(newTermNameCached(fullname))
// TODO: What syntax do we think should work here? Say you have an object
// like scala.Predef. You can't say requiredModule[scala.Predef] since there's
@@ -155,7 +147,7 @@ trait Mirrors extends api.Mirrors {
getModuleIfDefined(newTermNameCached(fullname))
def getModuleIfDefined(fullname: Name): Symbol =
- wrapMissing(getModule(fullname.toTermName))
+ wrapMissing(getModuleByName(fullname.toTermName))
/** @inheritdoc
*
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index 4998580a7d..c3f3e35fb3 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -42,6 +42,7 @@ abstract class SymbolTable extends macros.Universe
with BuildUtils
with PrivateWithin
with pickling.Translations
+ with FreshNames
{
val gen = new TreeGen { val global: SymbolTable.this.type = SymbolTable.this }
@@ -398,11 +399,6 @@ abstract class SymbolTable extends macros.Universe
* Adds the `sm` String interpolator to a [[scala.StringContext]].
*/
implicit val StringContextStripMarginOps: StringContext => StringContextStripMarginOps = util.StringContextStripMarginOps
-
- // fresh name creation
- def currentFreshNameCreator: FreshNameCreator
- def freshTermName(prefix: String = "x$")(implicit creator: FreshNameCreator): TermName = newTermName(creator.newName(prefix))
- def freshTypeName(prefix: String)(implicit creator: FreshNameCreator): TypeName = newTypeName(creator.newName(prefix))
}
object SymbolTableStats {
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index bd17c18119..85bc3158f6 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -452,23 +452,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
case _ => new StubTermSymbol(this, name.toTermName, missingMessage)
}
- @deprecated("Use the other signature", "2.10.0")
- def newClass(pos: Position, name: TypeName): Symbol = newClass(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newModuleClass(pos: Position, name: TypeName): Symbol = newModuleClass(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newLabel(pos: Position, name: TermName): MethodSymbol = newLabel(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newValue(pos: Position, name: TermName): TermSymbol = newTermSymbol(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newAliasType(pos: Position, name: TypeName): Symbol = newAliasType(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newAbstractType(pos: Position, name: TypeName): Symbol = newAbstractType(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newExistential(pos: Position, name: TypeName): Symbol = newExistential(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newMethod(pos: Position, name: TermName): MethodSymbol = newMethod(name, pos)
-
// ----- locking and unlocking ------------------------------------------------------
// True if the symbol is unlocked.
@@ -2047,10 +2030,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
else if (isMethod || isClass) this
else owner.logicallyEnclosingMember
- /** Kept for source compatibility with 2.9. Scala IDE for Eclipse relies on this. */
- @deprecated("Use enclosingTopLevelClass", "2.10.0")
- def toplevelClass: Symbol = enclosingTopLevelClass
-
/** The top-level class containing this symbol. */
def enclosingTopLevelClass: Symbol =
if (isTopLevel) {
@@ -2365,9 +2344,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def associatedFile: AbstractFile = enclosingTopLevelClass.associatedFile
def associatedFile_=(f: AbstractFile) { abort("associatedFile_= inapplicable for " + this) }
- @deprecated("Use associatedFile_= instead", "2.10.0")
- def sourceFile_=(f: AbstractFile): Unit = associatedFile_=(f)
-
/** If this is a sealed class, its known direct subclasses.
* Otherwise, the empty set.
*/
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 48db8f7bf7..8fdf4dc27a 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -849,7 +849,7 @@ abstract class TreeInfo {
})
def isMacroApplication(tree: Tree): Boolean =
- !tree.isDef && tree.symbol != null && tree.symbol.isMacro && !tree.symbol.isErroneous
+ !tree.isDef && tree.symbol != null && tree.symbol.isTermMacro && !tree.symbol.isErroneous
def isMacroApplicationOrBlock(tree: Tree): Boolean = tree match {
case Block(_, expr) => isMacroApplicationOrBlock(expr)
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index af0af8afe8..d191fbd38f 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -590,7 +590,7 @@ trait Trees extends api.Trees {
def TypeTree(tp: Type): TypeTree = TypeTree() setType tp
private def TypeTreeMemberType(sym: Symbol): TypeTree = {
// Needed for pos/t4970*.scala. See SI-7853
- val resType = (sym.owner.thisType memberType sym).finalResultType
+ val resType = (if (sym.isLocal) sym.tpe else (sym.owner.thisType memberType sym)).finalResultType
atPos(sym.pos.focus)(TypeTree(resType))
}
@@ -1804,6 +1804,12 @@ trait Trees extends api.Trees {
case t =>
sys.error("Not a LabelDef: " + t + "/" + t.getClass)
}
+ def deriveFunction(func: Tree)(applyToRhs: Tree => Tree): Function = func match {
+ case Function(params0, rhs0) =>
+ treeCopy.Function(func, params0, applyToRhs(rhs0))
+ case t =>
+ sys.error("Not a Function: " + t + "/" + t.getClass)
+ }
// -------------- Classtags --------------------------------------------------------
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index 9a54ad8217..f5aa048e6a 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -717,6 +717,12 @@ private[internal] trait TypeMaps {
else appliedType(tcon.typeConstructor, args)
case SingleType(NoPrefix, sym) =>
substFor(sym)
+ case ClassInfoType(parents, decls, sym) =>
+ val parents1 = parents mapConserve this
+ // We don't touch decls here; they will be touched when an enclosing TreeSubstitutor
+ // transforms the tree that defines them.
+ if (parents1 eq parents) tp
+ else ClassInfoType(parents1, decls, sym)
case _ =>
tp
}
diff --git a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
index 3e54de8e1e..8442c1015f 100644
--- a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
+++ b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
@@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicLong
import scala.collection.mutable
import scala.reflect.NameTransformer
-class FreshNameCreator {
+class FreshNameCreator(creatorPrefix: String = "") {
protected val counters = new ConcurrentHashMap[String, AtomicLong]()
/**
@@ -21,7 +21,8 @@ class FreshNameCreator {
*/
def newName(prefix: String): String = {
val safePrefix = NameTransformer.encode(prefix)
- counters.putIfAbsent(safePrefix, new AtomicLong(0));
- safePrefix + counters.get(safePrefix).incrementAndGet();
+ counters.putIfAbsent(safePrefix, new AtomicLong(0))
+ val idx = counters.get(safePrefix).incrementAndGet()
+ s"$creatorPrefix$safePrefix$idx"
}
}
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index bce506ee0a..344f7682c1 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -51,6 +51,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
// inaccessible: this.SimpleNameOrdering
this.traceSymbols
this.perRunCaches
+ this.FreshNameExtractor
this.FixedMirrorTreeCreator
this.FixedMirrorTypeCreator
this.CompoundTypeTreeOriginalAttachment
diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala
index 0d55423247..8fba1e538e 100644
--- a/src/repl/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala
@@ -9,10 +9,11 @@ package interpreter
import PartialFunction.cond
import scala.language.implicitConversions
+import scala.beans.BeanProperty
import scala.collection.mutable
import scala.concurrent.{ Future, ExecutionContext }
import scala.reflect.runtime.{ universe => ru }
-import scala.reflect.{ BeanProperty, ClassTag, classTag }
+import scala.reflect.{ ClassTag, classTag }
import scala.reflect.internal.util.{ BatchSourceFile, SourceFile }
import scala.tools.util.PathResolver
import scala.tools.nsc.io.AbstractFile
diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
index 50c90968af..496d5face1 100644
--- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
@@ -180,7 +180,7 @@ class JavapClass(
/** Base class for javap tool adapters for java 6 and 7. */
abstract class JavapTool {
type ByteAry = Array[Byte]
- type Input = Pair[String, Try[ByteAry]]
+ type Input = Tuple2[String, Try[ByteAry]]
/** Run the tool. */
def apply(raw: Boolean, options: Seq[String])(inputs: Seq[Input]): List[JpResult]
diff --git a/src/scaladoc/scala/tools/ant/Scaladoc.scala b/src/scaladoc/scala/tools/ant/Scaladoc.scala
index fd6d637212..36a1405b11 100644
--- a/src/scaladoc/scala/tools/ant/Scaladoc.scala
+++ b/src/scaladoc/scala/tools/ant/Scaladoc.scala
@@ -574,7 +574,7 @@ class Scaladoc extends ScalaMatchingTask {
\*============================================================================*/
/** Initializes settings and source files */
- protected def initialize: Pair[Settings, List[File]] = {
+ protected def initialize: Tuple2[Settings, List[File]] = {
// Tests if all mandatory attributes are set and valid.
if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (getOrigin.isEmpty) buildError("Attribute 'srcdir' is not set.")
@@ -660,14 +660,14 @@ class Scaladoc extends ScalaMatchingTask {
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
docSettings processArgumentString addParams
- Pair(docSettings, sourceFiles)
+ (docSettings, sourceFiles)
}
def safeBuildError(message: String): Unit = if (nofail) log(message) else buildError(message)
/** Performs the compilation. */
override def execute() = {
- val Pair(docSettings, sourceFiles) = initialize
+ val (docSettings, sourceFiles) = initialize
val reporter = new ConsoleReporter(docSettings)
try {
val docProcessor = new scala.tools.nsc.doc.DocFactory(reporter, docSettings)
diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala
index 41346d13c0..cb0a92b6b3 100644
--- a/src/scalap/scala/tools/scalap/Arguments.scala
+++ b/src/scalap/scala/tools/scalap/Arguments.scala
@@ -46,8 +46,8 @@ object Arguments {
}
def parseBinding(str: String, separator: Char): (String, String) = (str indexOf separator) match {
- case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; Pair("", "")
- case idx => Pair((str take idx).trim, (str drop (idx + 1)).trim)
+ case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; ("", "")
+ case idx => ((str take idx).trim, (str drop (idx + 1)).trim)
}
def parse(args: Array[String]): Arguments = {
@@ -141,7 +141,7 @@ class Arguments {
if (key.length > 0)
bindings.getOrElseUpdate(tag, new mutable.HashMap)(key) = value
- def addBinding(tag: String, binding: Pair[String, String]): Unit =
+ def addBinding(tag: String, binding: Tuple2[String, String]): Unit =
addBinding(tag, binding._1, binding._2)
def addOther(arg: String): Unit = others += arg