Skip to content

Commit aea3cbc

Browse files
committed
Merge pull request scala#2554 from paulp/merge/v2.10.1-326-g4f8c306-to-master
Merge v2.10.1-326-g4f8c306 into master
2 parents 0823aed + b7c352a commit aea3cbc

File tree

73 files changed

+2519
-1292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2519
-1292
lines changed

lib/forkjoin.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f93a2525b5616d3a4bee7848fabbb2856b56f653 *forkjoin.jar
1+
ddd7d5398733c4fbbb8355c049e258d47af636cf ?forkjoin.jar

src/actors/scala/actors/remote/TcpService.scala

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package remote
1414

1515
import java.io.{DataInputStream, DataOutputStream, IOException}
1616
import java.lang.{Thread, SecurityException}
17-
import java.net.{InetAddress, ServerSocket, Socket, UnknownHostException}
17+
import java.net.{InetAddress, InetSocketAddress, ServerSocket, Socket, SocketTimeoutException, UnknownHostException}
1818

1919
import scala.collection.mutable
2020
import scala.util.Random
@@ -60,6 +60,23 @@ object TcpService {
6060
portnum
6161
}
6262

63+
private val connectTimeoutMillis = {
64+
val propName = "scala.actors.tcpSocket.connectTimeoutMillis"
65+
val defaultTimeoutMillis = 0
66+
sys.props get propName flatMap {
67+
timeout =>
68+
try {
69+
val to = timeout.toInt
70+
Debug.info("Using socket timeout $to")
71+
Some(to)
72+
} catch {
73+
case e: NumberFormatException =>
74+
Debug.warning(s"""Could not parse $propName = "$timeout" as an Int""")
75+
None
76+
}
77+
} getOrElse defaultTimeoutMillis
78+
}
79+
6380
var BufSize: Int = 65536
6481
}
6582

@@ -178,7 +195,15 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
178195
}
179196

180197
def connect(n: Node): TcpServiceWorker = synchronized {
181-
val socket = new Socket(n.address, n.port)
198+
val socket = new Socket()
199+
val start = System.nanoTime
200+
try {
201+
socket.connect(new InetSocketAddress(n.address, n.port), TcpService.connectTimeoutMillis)
202+
} catch {
203+
case e: SocketTimeoutException =>
204+
Debug.warning(f"Timed out connecting to $n after ${(System.nanoTime - start) / math.pow(10, 9)}%.3f seconds")
205+
throw e
206+
}
182207
val worker = new TcpServiceWorker(this, socket)
183208
worker.sendNode(n)
184209
worker.start()

src/compiler/scala/reflect/macros/util/Traces.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ trait Traces {
66

77
val macroDebugLite = globalSettings.YmacrodebugLite.value
88
val macroDebugVerbose = globalSettings.YmacrodebugVerbose.value
9-
val macroTraceLite = scala.tools.nsc.util.trace when (macroDebugLite || macroDebugVerbose)
10-
val macroTraceVerbose = scala.tools.nsc.util.trace when macroDebugVerbose
119
@inline final def macroLogLite(msg: => Any) { if (macroDebugLite || macroDebugVerbose) println(msg) }
1210
@inline final def macroLogVerbose(msg: => Any) { if (macroDebugVerbose) println(msg) }
1311
}

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,8 @@ self =>
10861086
* | symbol
10871087
* | null
10881088
* }}}
1089-
* @note The returned tree does not yet have a position
10901089
*/
1091-
def literal(isNegated: Boolean = false, inPattern: Boolean = false): Tree = {
1090+
def literal(isNegated: Boolean = false, inPattern: Boolean = false, start: Int = in.offset): Tree = atPos(start) {
10921091
def finish(value: Any): Tree = try newLiteral(value) finally in.nextToken()
10931092
if (in.token == SYMBOLLIT)
10941093
Apply(scalaDot(nme.Symbol), List(finish(in.strVal)))
@@ -1282,12 +1281,12 @@ self =>
12821281
parseTry
12831282
case WHILE =>
12841283
def parseWhile = {
1284+
val start = in.offset
12851285
atPos(in.skipToken()) {
1286-
val lname: Name = freshTermName(nme.WHILE_PREFIX)
12871286
val cond = condExpr()
12881287
newLinesOpt()
12891288
val body = expr()
1290-
makeWhile(lname.toTermName, cond, body)
1289+
makeWhile(start, cond, body)
12911290
}
12921291
}
12931292
parseWhile
@@ -1460,7 +1459,7 @@ self =>
14601459
atPos(in.offset) {
14611460
val name = nme.toUnaryName(rawIdent().toTermName)
14621461
if (name == nme.UNARY_- && isNumericLit)
1463-
simpleExprRest(atPos(in.offset)(literal(isNegated = true)), canApply = true)
1462+
simpleExprRest(literal(isNegated = true), canApply = true)
14641463
else
14651464
Select(stripParens(simpleExpr()), name)
14661465
}
@@ -1485,7 +1484,7 @@ self =>
14851484
def simpleExpr(): Tree = {
14861485
var canApply = true
14871486
val t =
1488-
if (isLiteral) atPos(in.offset)(literal())
1487+
if (isLiteral) literal()
14891488
else in.token match {
14901489
case XMLSTART =>
14911490
xmlLiteral()
@@ -1862,7 +1861,7 @@ self =>
18621861
case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT =>
18631862
t match {
18641863
case Ident(nme.MINUS) =>
1865-
return atPos(start) { literal(isNegated = true, inPattern = true) }
1864+
return literal(isNegated = true, inPattern = true, start = start)
18661865
case _ =>
18671866
}
18681867
case _ =>
@@ -1880,7 +1879,7 @@ self =>
18801879
atPos(start, start) { Ident(nme.WILDCARD) }
18811880
case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT |
18821881
STRINGLIT | INTERPOLATIONID | SYMBOLLIT | TRUE | FALSE | NULL =>
1883-
atPos(start) { literal(inPattern = true) }
1882+
literal(inPattern = true)
18841883
case LPAREN =>
18851884
atPos(start)(makeParens(noSeq.patterns()))
18861885
case XMLSTART =>

src/compiler/scala/tools/nsc/ast/parser/Scanners.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ trait Scanners extends ScannersCommon {
467467
if (ch == '\"') {
468468
nextRawChar()
469469
if (ch == '\"') {
470+
offset += 3
470471
nextRawChar()
471472
getStringPart(multiLine = true)
472473
sepRegions = STRINGPART :: sepRegions // indicate string part
@@ -476,6 +477,7 @@ trait Scanners extends ScannersCommon {
476477
strVal = ""
477478
}
478479
} else {
480+
offset += 1
479481
getStringPart(multiLine = false)
480482
sepRegions = STRINGLIT :: sepRegions // indicate single line string part
481483
}

src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,13 @@ abstract class TreeBuilder {
248248
else CompoundTypeTree(Template(tps, emptyValDef, Nil))
249249

250250
/** Create tree representing a while loop */
251-
def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = {
252-
val continu = atPos(o2p(body.pos pointOrElse wrappingPos(List(cond, body)).pos.endOrPoint)) { Apply(Ident(lname), Nil) }
251+
def makeWhile(startPos: Int, cond: Tree, body: Tree): Tree = {
252+
val lname = freshTermName(nme.WHILE_PREFIX)
253+
def default = wrappingPos(List(cond, body)) match {
254+
case p if p.isDefined => p.endOrPoint
255+
case _ => startPos
256+
}
257+
val continu = atPos(o2p(body.pos pointOrElse default)) { Apply(Ident(lname), Nil) }
253258
val rhs = If(cond, Block(List(body), continu), Literal(Constant(())))
254259
LabelDef(lname, Nil, rhs)
255260
}

src/compiler/scala/tools/nsc/javac/JavaParsers.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
368368
case FINAL =>
369369
flags |= Flags.FINAL
370370
in.nextToken()
371+
case DEFAULT =>
372+
flags |= Flags.DEFAULTMETHOD
373+
in.nextToken()
371374
case NATIVE =>
372375
addAnnot(NativeAttr)
373376
in.nextToken()
@@ -485,8 +488,9 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
485488
val vparams = formalParams()
486489
if (!isVoid) rtpt = optArrayBrackets(rtpt)
487490
optThrows()
491+
val bodyOk = !inInterface || (mods hasFlag Flags.DEFAULTMETHOD)
488492
val body =
489-
if (!inInterface && in.token == LBRACE) {
493+
if (bodyOk && in.token == LBRACE) {
490494
methodBody()
491495
} else {
492496
if (parentToken == AT && in.token == DEFAULT) {

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ abstract class ClassfileParser {
7575

7676
private def handleMissing(e: MissingRequirementError) = {
7777
if (settings.debug) e.printStackTrace
78-
throw new IOException("Missing dependency '" + e.req + "', required by " + in.file)
78+
throw new IOException(s"Missing dependency '${e.req}', required by ${in.file}")
7979
}
8080
private def handleError(e: Exception) = {
8181
if (settings.debug) e.printStackTrace()
82-
throw new IOException("class file '%s' is broken\n(%s/%s)".format(
83-
in.file,
84-
e.getClass,
85-
if (e.getMessage eq null) "" else e.getMessage)
86-
)
82+
throw new IOException(s"class file '${in.file}' is broken\n(${e.getClass}/${e.getMessage})")
8783
}
8884
private def mismatchError(c: Symbol) = {
89-
throw new IOException("class file '%s' has location not matching its contents: contains ".format(in.file) + c)
85+
throw new IOException(s"class file '${in.file}' has location not matching its contents: contains $c")
9086
}
9187

9288
private def parseErrorHandler[T]: PartialFunction[Throwable, T] = {
@@ -95,8 +91,8 @@ abstract class ClassfileParser {
9591
}
9692
@inline private def pushBusy[T](sym: Symbol)(body: => T): T = {
9793
busy match {
98-
case Some(`sym`) => throw new IOException("unsatisfiable cyclic dependency in '%s'".format(sym))
99-
case Some(sym1) => throw new IOException("illegal class file dependency between '%s' and '%s'".format(sym, sym1))
94+
case Some(`sym`) => throw new IOException(s"unsatisfiable cyclic dependency in '$sym'")
95+
case Some(sym1) => throw new IOException(s"illegal class file dependency between '$sym' and '$sym1'")
10096
case _ => ()
10197
}
10298

@@ -242,8 +238,6 @@ abstract class ClassfileParser {
242238

243239
forceMangledName(tpe0.typeSymbol.name, module = false)
244240
val (name, tpe) = getNameAndType(in.getChar(start + 3), ownerTpe)
245-
// println("new tpe: " + tpe + " at phase: " + phase)
246-
247241
if (name == nme.MODULE_INSTANCE_FIELD) {
248242
val index = in.getChar(start + 1)
249243
val name = getExternalName(in.getChar(starts(index) + 1))
@@ -254,14 +248,12 @@ abstract class ClassfileParser {
254248
} else {
255249
val origName = nme.unexpandedName(name)
256250
val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol
257-
// println("\t" + owner.info.member(name).tpe.widen + " =:= " + tpe)
258251
f = owner.info.findMember(origName, 0, 0, stableOnly = false).suchThat(_.tpe.widen =:= tpe)
259252
if (f == NoSymbol)
260253
f = owner.info.findMember(newTermName(origName + nme.LOCAL_SUFFIX_STRING), 0, 0, stableOnly = false).suchThat(_.tpe =:= tpe)
261254
if (f == NoSymbol) {
262255
// if it's an impl class, try to find it's static member inside the class
263256
if (ownerTpe.typeSymbol.isImplClass) {
264-
// println("impl class, member: " + owner.tpe.member(origName) + ": " + owner.tpe.member(origName).tpe)
265257
f = ownerTpe.findMember(origName, 0, 0, stableOnly = false).suchThat(_.tpe =:= tpe)
266258
} else {
267259
log("Couldn't find " + name + ": " + tpe + " inside: \n" + ownerTpe)
@@ -272,11 +264,13 @@ abstract class ClassfileParser {
272264
f setInfo tpe
273265
log("created fake member " + f.fullName)
274266
}
275-
// println("\townerTpe.decls: " + ownerTpe.decls)
276-
// println("Looking for: " + name + ": " + tpe + " inside: " + ownerTpe.typeSymbol + "\n\tand found: " + ownerTpe.members)
277267
}
278268
}
279-
assert(f != NoSymbol, "could not find\n " + name + ": " + tpe + "\ninside:\n " + ownerTpe.members.mkString(", "))
269+
assert(f != NoSymbol,
270+
s"could not find $name: $tpe in $ownerTpe" + (
271+
if (settings.debug.value) ownerTpe.members.mkString(", members are:\n ", "\n ", "") else ""
272+
)
273+
)
280274
values(index) = f
281275
}
282276
f
@@ -560,11 +554,9 @@ abstract class ClassfileParser {
560554
def addEnclosingTParams(clazz: Symbol) {
561555
var sym = clazz.owner
562556
while (sym.isClass && !sym.isModuleClass) {
563-
// println("adding tparams of " + sym)
564-
for (t <- sym.tpe.typeArgs) {
565-
// println("\tadding " + (t.typeSymbol.name + "->" + t.typeSymbol))
557+
for (t <- sym.tpe.typeArgs)
566558
classTParams = classTParams + (t.typeSymbol.name -> t.typeSymbol)
567-
}
559+
568560
sym = sym.owner
569561
}
570562
}
@@ -838,8 +830,6 @@ abstract class ClassfileParser {
838830
val sig = pool.getExternalName(u2)
839831
val newType = sigToType(sym, sig)
840832
sym.setInfo(newType)
841-
if (settings.debug && settings.verbose)
842-
println("" + sym + "; signature = " + sig + " type = " + newType)
843833
}
844834
else in.skip(attrLen)
845835
case tpnme.SyntheticATTR =>
@@ -856,10 +846,10 @@ abstract class ClassfileParser {
856846
val c = pool.getConstant(u2)
857847
val c1 = convertTo(c, symtype)
858848
if (c1 ne null) sym.setInfo(ConstantType(c1))
859-
else println("failure to convert " + c + " to " + symtype); //debug
849+
else debugwarn(s"failure to convert $c to $symtype")
860850
case tpnme.ScalaSignatureATTR =>
861851
if (!isScalaAnnot) {
862-
debuglog("warning: symbol " + sym.fullName + " has pickled signature in attribute")
852+
debugwarn(s"symbol ${sym.fullName} has pickled signature in attribute")
863853
unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.name)
864854
}
865855
in.skip(attrLen)
@@ -904,6 +894,12 @@ abstract class ClassfileParser {
904894
case pkg => pkg.fullName(File.separatorChar)+File.separator+srcfileLeaf
905895
}
906896
srcfile0 = settings.outputDirs.srcFilesFor(in.file, srcpath).find(_.exists)
897+
case tpnme.CodeATTR =>
898+
if (sym.owner.isInterface) {
899+
sym setFlag DEFAULTMETHOD
900+
log(s"$sym in ${sym.owner} is a java8+ default method.")
901+
}
902+
in.skip(attrLen)
907903
case _ =>
908904
in.skip(attrLen)
909905
}
@@ -991,16 +987,18 @@ abstract class ClassfileParser {
991987
}
992988
if (hasError) None
993989
else Some(AnnotationInfo(attrType, List(), nvpairs.toList))
994-
} catch {
995-
case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found
996-
case ex: Throwable =>
990+
}
991+
catch {
992+
case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found
993+
case ex: java.lang.Error => throw ex
994+
case ex: Throwable =>
997995
// We want to be robust when annotations are unavailable, so the very least
998996
// we can do is warn the user about the exception
999997
// There was a reference to ticket 1135, but that is outdated: a reference to a class not on
1000998
// the classpath would *not* end up here. A class not found is signaled
1001999
// with a `FatalError` exception, handled above. Here you'd end up after a NPE (for example),
10021000
// and that should never be swallowed silently.
1003-
warning("Caught: " + ex + " while parsing annotations in " + in.file)
1001+
warning(s"Caught: $ex while parsing annotations in ${in.file}")
10041002
if (settings.debug) ex.printStackTrace()
10051003

10061004
None // ignore malformed annotations

src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ abstract class Pickler extends SubComponent {
308308
putTree(definition)
309309
*/
310310
case Template(parents, self, body) =>
311-
writeNat(parents.length)
312311
putTrees(parents)
313312
putTree(self)
314313
putTrees(body)

src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ trait TreeAndTypeAnalysis extends Debugging {
9595
// TODO: when type tags are available, we will check -- when this is implemented, can we take that into account here?
9696
// similar to typer.infer.approximateAbstracts
9797
object typeArgsToWildcardsExceptArray extends TypeMap {
98-
def apply(tp: Type): Type = tp match {
98+
// SI-6771 dealias would be enough today, but future proofing with the dealiasWiden.
99+
// See neg/t6771b.scala for elaboration
100+
def apply(tp: Type): Type = tp.dealiasWiden match {
99101
case TypeRef(pre, sym, args) if args.nonEmpty && (sym ne ArrayClass) =>
100102
TypeRef(pre, sym, args map (_ => WildcardType))
101103
case _ =>

0 commit comments

Comments
 (0)