Skip to content

Commit bad9392

Browse files
author
Adriaan Moors
committed
Merge commit 'refs/pull/825/head'; commit 'refs/pull/827/head'; commit 'refs/pull/828/head'; commit 'refs/pull/850/head'; commit 'refs/pull/858/head' into 2.10.x
6 parents 026a70d + 67a1446 + 7050335 + 1670236 + da587e3 + df1b94e commit bad9392

File tree

62 files changed

+652
-184
lines changed

Some content is hidden

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

62 files changed

+652
-184
lines changed

lib/ant/ant-contrib.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
943cd5c8802b2a3a64a010efb86ec19bac142e40 ?ant-contrib.jar
1+
943cd5c8802b2a3a64a010efb86ec19bac142e40 *ant-contrib.jar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3fc1e35ca8c991fc3488548f7a276bd9053c179d ?ant-dotnet-1.0.jar
1+
3fc1e35ca8c991fc3488548f7a276bd9053c179d *ant-dotnet-1.0.jar

lib/ant/ant.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7b456ca6b93900f96e58cc8371f03d90a9c1c8d1 ?ant.jar
1+
7b456ca6b93900f96e58cc8371f03d90a9c1c8d1 *ant.jar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7e50e3e227d834695f1e0bf018a7326e06ee4c86 ?maven-ant-tasks-2.1.1.jar
1+
7e50e3e227d834695f1e0bf018a7326e06ee4c86 *maven-ant-tasks-2.1.1.jar

lib/ant/vizant.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2c61d6e9a912b3253194d5d6d3e1db7e2545ac4b ?vizant.jar
1+
2c61d6e9a912b3253194d5d6d3e1db7e2545ac4b *vizant.jar

lib/fjbg.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c3f9b576c91cb9761932ad936ccc4a71f33d2ef2 ?fjbg.jar
1+
8acc87f222210b4a5eb2675477602fc1759e7684 *fjbg.jar

lib/forkjoin.jar.desired.sha1

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

lib/jline.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a5261e70728c1847639e2b47d953441d0b217bcb ?jline.jar
1+
a5261e70728c1847639e2b47d953441d0b217bcb *jline.jar

lib/msil.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d48cb950ceded82a5e0ffae8ef2c68d0923ed00c ?msil.jar
1+
d48cb950ceded82a5e0ffae8ef2c68d0923ed00c *msil.jar

lib/scala-compiler.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
554bcc4a543360c8dc48fde91124dc57319d3460 ?scala-compiler.jar
1+
dacc6e38cdd2eabbf2e4780061c3b4c9e125274d *scala-compiler.jar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7db4c7523f0e268ce58de2ab4ae6a3dd0e903f43 ?scala-library-src.jar
1+
0772f79076f74e298e7bf77ad4dfa464c50efe61 *scala-library-src.jar

lib/scala-library.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
071d32b24daaeaf961675f248758fedd31a806ed ?scala-library.jar
1+
4edcb1b7030e74259cd906e9230d45a3fffc0444 *scala-library.jar

lib/scala-reflect.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b6e2bbbc1707104119adcb09aeb666690419c424 ?scala-reflect.jar
1+
1187b9c68ca80f951826b1a9b374e8646d9c9a71 *scala-reflect.jar

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,9 +2191,15 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
21912191
val st = pending.getOrElseUpdate(lv, mutable.Stack.empty[Label])
21922192
st.push(start)
21932193
}
2194-
def popScope(lv: Local, end: Label) {
2195-
val start = pending(lv).pop()
2196-
seen ::= LocVarEntry(lv, start, end)
2194+
def popScope(lv: Local, end: Label, iPos: Position) {
2195+
pending.get(lv) match {
2196+
case Some(st) if st.nonEmpty =>
2197+
val start = st.pop()
2198+
seen ::= LocVarEntry(lv, start, end)
2199+
case _ =>
2200+
// TODO SI-6049
2201+
getCurrentCUnit().warning(iPos, "Visited SCOPE_EXIT before visiting corresponding SCOPE_ENTER. SI-6049")
2202+
}
21972203
}
21982204

21992205
def getMerged(): collection.Map[Local, List[Interval]] = {
@@ -2406,7 +2412,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
24062412
// similarly, these labels aren't tracked in the `labels` map.
24072413
val end = new asm.Label
24082414
jmethod.visitLabel(end)
2409-
scoping.popScope(lv, end)
2415+
scoping.popScope(lv, end, instr.pos)
24102416
}
24112417
}
24122418

src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ abstract class InteractiveTest
8282

8383
/** Test's entry point */
8484
def main(args: Array[String]) {
85+
try execute()
86+
finally shutdown()
87+
}
88+
89+
protected def execute(): Unit = {
8590
loadSources()
86-
runTests()
87-
shutdown()
91+
runDefaultTests()
8892
}
8993

9094
/** Load all sources before executing the test. */
91-
private def loadSources() {
95+
protected def loadSources() {
9296
// ask the presentation compiler to track all sources. We do
9397
// not wait for the file to be entirely typed because we do want
9498
// to exercise the presentation compiler on scoped type requests.
@@ -100,7 +104,7 @@ abstract class InteractiveTest
100104
}
101105

102106
/** Run all defined `PresentationCompilerTestDef` */
103-
protected def runTests() {
107+
protected def runDefaultTests() {
104108
//TODO: integrate random tests!, i.e.: if (runRandomTests) randomTests(20, sourceFiles)
105109
testActions.foreach(_.runTest())
106110
}
@@ -109,7 +113,7 @@ abstract class InteractiveTest
109113
private def randomTests(n: Int, files: Array[SourceFile]) {
110114
val tester = new Tester(n, files, settings) {
111115
override val compiler = self.compiler
112-
override val reporter = compilerReporter
116+
override val reporter = new reporters.StoreReporter
113117
}
114118
tester.run()
115119
}

src/compiler/scala/tools/nsc/interactive/tests/InteractiveTestSettings.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ package tests
44

55
import java.io.File.pathSeparatorChar
66
import java.io.File.separatorChar
7-
87
import scala.tools.nsc.interactive.tests.core.PresentationCompilerInstance
9-
import scala.tools.nsc.io.File
10-
8+
import scala.tools.nsc.io.{File,Path}
119
import core.Reporter
1210
import core.TestSettings
1311

@@ -46,6 +44,11 @@ trait InteractiveTestSettings extends TestSettings with PresentationCompilerInst
4644
println("error processing arguments (unprocessed: %s)".format(rest))
4745
case _ => ()
4846
}
47+
48+
// Make the --sourcepath path provided in the .flags file (if any) relative to the test's base directory
49+
if(settings.sourcepath.isSetByUser)
50+
settings.sourcepath.value = (baseDir / Path(settings.sourcepath.value)).path
51+
4952
adjustPaths(settings.bootclasspath, settings.classpath, settings.javabootclasspath, settings.sourcepath)
5053
}
5154

src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package scala.tools.nsc
22
package interactive
33
package tests.core
44

5-
import reporters.StoreReporter
5+
import reporters.{Reporter => CompilerReporter}
6+
import scala.reflect.internal.util.Position
67

78
/** Trait encapsulating the creation of a presentation compiler's instance.*/
8-
private[tests] trait PresentationCompilerInstance {
9+
private[tests] trait PresentationCompilerInstance extends TestSettings {
910
protected val settings = new Settings
10-
protected val compilerReporter = new StoreReporter
11+
protected val compilerReporter: CompilerReporter = new InteractiveReporter {
12+
override def compiler = PresentationCompilerInstance.this.compiler
13+
}
1114

1215
protected lazy val compiler: Global = {
1316
prepareSettings(settings)

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ trait ContextErrors {
562562

563563
// SelectFromTypeTree
564564
def TypeSelectionFromVolatileTypeError(tree: Tree, qual: Tree) = {
565-
issueNormalTypeError(tree, "illegal type selection from volatile type "+qual.tpe)
565+
val hiBound = qual.tpe.bounds.hi
566+
val addendum = if (hiBound =:= qual.tpe) "" else s" (with upper bound ${hiBound})"
567+
issueNormalTypeError(tree, s"illegal type selection from volatile type ${qual.tpe}${addendum}")
566568
setError(tree)
567569
}
568570

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,6 @@ trait Namers extends MethodSynthesis {
5252
def newNamerFor(context: Context, tree: Tree): Namer =
5353
newNamer(context.makeNewScope(tree, tree.symbol))
5454

55-
// In the typeCompleter (templateSig) of a case class (resp it's module),
56-
// synthetic `copy` (reps `apply`, `unapply`) methods are added. To compute
57-
// their signatures, the corresponding ClassDef is needed.
58-
// During naming, for each case class module symbol, the corresponding ClassDef
59-
// is stored in this map. The map is cleared lazily, i.e. when the new symbol
60-
// is created with the same name, the old one (if present) is wiped out, or the
61-
// entry is deleted when it is used and no longer needed.
62-
private val classOfModuleClass = perRunCaches.newWeakMap[Symbol, WeakReference[ClassDef]]()
63-
64-
// Default getters of constructors are added to the companion object in the
65-
// typeCompleter of the constructor (methodSig). To compute the signature,
66-
// we need the ClassDef. To create and enter the symbols into the companion
67-
// object, we need the templateNamer of that module class.
68-
// This map is extended during naming of classes, the Namer is added in when
69-
// it's available, i.e. in the type completer (templateSig) of the module class.
70-
private[typechecker] val classAndNamerOfModule = perRunCaches.newMap[Symbol, (ClassDef, Namer)]()
71-
72-
def resetNamer() {
73-
classAndNamerOfModule.clear()
74-
}
75-
7655
abstract class Namer(val context: Context) extends MethodSynth with NamerContextErrors { thisNamer =>
7756

7857
import NamerErrorGen._
@@ -618,15 +597,15 @@ trait Namers extends MethodSynthesis {
618597
MaxParametersCaseClassError(tree)
619598

620599
val m = ensureCompanionObject(tree, caseModuleDef)
621-
classOfModuleClass(m.moduleClass) = new WeakReference(tree)
600+
m.moduleClass.addAttachment(new ClassForCaseCompanionAttachment(tree))
622601
}
623602
val hasDefault = impl.body exists {
624603
case DefDef(_, nme.CONSTRUCTOR, _, vparamss, _, _) => mexists(vparamss)(_.mods.hasDefault)
625604
case _ => false
626605
}
627606
if (hasDefault) {
628607
val m = ensureCompanionObject(tree)
629-
classAndNamerOfModule(m) = (tree, null)
608+
m.addAttachment(new ConstructorDefaultsAttachment(tree, null))
630609
}
631610
val owner = tree.symbol.owner
632611
if (settings.lint.value && owner.isPackageObjectClass && !mods.isImplicit) {
@@ -657,7 +636,8 @@ trait Namers extends MethodSynthesis {
657636
if (sym.isLazy)
658637
sym.lazyAccessor andAlso enterIfNotThere
659638

660-
defaultParametersOfMethod(sym) foreach { symRef => enterIfNotThere(symRef()) }
639+
for (defAtt <- sym.attachments.get[DefaultsOfLocalMethodAttachment])
640+
defAtt.defaultGetters foreach enterIfNotThere
661641
}
662642
this.context
663643
}
@@ -846,23 +826,20 @@ trait Namers extends MethodSynthesis {
846826
// add apply and unapply methods to companion objects of case classes,
847827
// unless they exist already; here, "clazz" is the module class
848828
if (clazz.isModuleClass) {
849-
Namers.this.classOfModuleClass get clazz foreach { cdefRef =>
850-
val cdef = cdefRef()
851-
if (cdef.mods.isCase) addApplyUnapply(cdef, templateNamer)
852-
classOfModuleClass -= clazz
829+
clazz.attachments.get[ClassForCaseCompanionAttachment] foreach { cma =>
830+
val cdef = cma.caseClass
831+
assert(cdef.mods.isCase, "expected case class: "+ cdef)
832+
addApplyUnapply(cdef, templateNamer)
853833
}
854834
}
855835

856836
// add the copy method to case classes; this needs to be done here, not in SyntheticMethods, because
857837
// the namer phase must traverse this copy method to create default getters for its parameters.
858838
// here, clazz is the ClassSymbol of the case class (not the module).
859-
// @check: this seems to work only if the type completer of the class runs before the one of the
860-
// module class: the one from the module class removes the entry from classOfModuleClass (see above).
861839
if (clazz.isClass && !clazz.hasModuleFlag) {
862840
val modClass = companionSymbolOf(clazz, context).moduleClass
863-
Namers.this.classOfModuleClass get modClass map { cdefRef =>
864-
val cdef = cdefRef()
865-
841+
modClass.attachments.get[ClassForCaseCompanionAttachment] foreach { cma =>
842+
val cdef = cma.caseClass
866843
def hasCopy(decls: Scope) = (decls lookup nme.copy) != NoSymbol
867844
if (cdef.mods.isCase && !hasCopy(decls) &&
868845
!parents.exists(p => hasCopy(p.typeSymbol.info.decls)) &&
@@ -874,9 +851,8 @@ trait Namers extends MethodSynthesis {
874851
// if default getters (for constructor defaults) need to be added to that module, here's the namer
875852
// to use. clazz is the ModuleClass. sourceModule works also for classes defined in methods.
876853
val module = clazz.sourceModule
877-
classAndNamerOfModule get module foreach {
878-
case (cdef, _) =>
879-
classAndNamerOfModule(module) = (cdef, templateNamer)
854+
for (cda <- module.attachments.get[ConstructorDefaultsAttachment]) {
855+
cda.companionModuleClassNamer = templateNamer
880856
}
881857
ClassInfoType(parents, decls, clazz)
882858
}
@@ -1097,13 +1073,15 @@ trait Namers extends MethodSynthesis {
10971073
val module = companionSymbolOf(clazz, context)
10981074
module.initialize // call type completer (typedTemplate), adds the
10991075
// module's templateNamer to classAndNamerOfModule
1100-
classAndNamerOfModule get module match {
1101-
case s @ Some((cdef, nmr)) if nmr != null =>
1102-
moduleNamer = s
1103-
(cdef, nmr)
1076+
module.attachments.get[ConstructorDefaultsAttachment] match {
1077+
// by martin: the null case can happen in IDE; this is really an ugly hack on top of an ugly hack but it seems to work
1078+
// later by lukas: disabled when fixing SI-5975, i think it cannot happen anymore
1079+
case Some(cda) /*if cma.companionModuleClassNamer == null*/ =>
1080+
val p = (cda.classWithDefault, cda.companionModuleClassNamer)
1081+
moduleNamer = Some(p)
1082+
p
11041083
case _ =>
11051084
return // fix #3649 (prevent crash in erroneous source code)
1106-
// nmr == null can happen in IDE; this is really an ugly hack on top[ of an ugly hack but it seems to work
11071085
}
11081086
}
11091087
deftParams = cdef.tparams map copyUntypedInvariant
@@ -1141,11 +1119,14 @@ trait Namers extends MethodSynthesis {
11411119
clazz.resetFlag(INTERFACE) // there's a concrete member now
11421120
val default = parentNamer.enterSyntheticSym(defaultTree)
11431121
if (forInteractive && default.owner.isTerm) {
1144-
// enter into map from method symbols to default arguments.
1145-
// if compiling the same local block several times (which can happen in interactive mode)
1146-
// we might otherwise not find the default symbol, because the second time it the
1147-
// method symbol will be re-entered in the scope but the default parameter will not.
1148-
defaultParametersOfMethod(meth) += new WeakReference(default)
1122+
// save the default getters as attachments in the method symbol. if compiling the
1123+
// same local block several times (which can happen in interactive mode) we might
1124+
// otherwise not find the default symbol, because the second time it the method
1125+
// symbol will be re-entered in the scope but the default parameter will not.
1126+
val att = meth.attachments.get[DefaultsOfLocalMethodAttachment] match {
1127+
case Some(att) => att.defaultGetters += default
1128+
case None => meth.addAttachment(new DefaultsOfLocalMethodAttachment(default))
1129+
}
11491130
}
11501131
} else if (baseHasDefault) {
11511132
// the parameter does not have a default itself, but the

src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ trait NamesDefaults { self: Analyzer =>
2121
import definitions._
2222
import NamesDefaultsErrorsGen._
2323

24-
val defaultParametersOfMethod =
25-
perRunCaches.newWeakMap[Symbol, Set[WeakReference[Symbol]]]() withDefaultValue Set()
24+
// Default getters of constructors are added to the companion object in the
25+
// typeCompleter of the constructor (methodSig). To compute the signature,
26+
// we need the ClassDef. To create and enter the symbols into the companion
27+
// object, we need the templateNamer of that module class. These two are stored
28+
// as an attachment in the companion module symbol
29+
class ConstructorDefaultsAttachment(val classWithDefault: ClassDef, var companionModuleClassNamer: Namer)
30+
31+
// To attach the default getters of local (term-owned) methods to the method symbol.
32+
// Used in Namer.enterExistingSym: it needs to re-enter the method symbol and also
33+
// default getters, which could not be found otherwise.
34+
class DefaultsOfLocalMethodAttachment(val defaultGetters: mutable.Set[Symbol]) {
35+
def this(default: Symbol) = this(mutable.Set(default))
36+
}
2637

2738
case class NamedApplyInfo(
2839
qual: Option[Tree],

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ trait Typers extends Modes with Adaptations with Tags {
4747
def resetTyper() {
4848
//println("resetTyper called")
4949
resetContexts()
50-
resetNamer()
5150
resetImplicits()
5251
transformed.clear()
5352
}
@@ -5114,7 +5113,7 @@ trait Typers extends Modes with Adaptations with Tags {
51145113

51155114
case SelectFromTypeTree(qual, selector) =>
51165115
val qual1 = typedType(qual, mode)
5117-
if (qual1.tpe.isVolatile) TypeSelectionFromVolatileTypeError(tree, qual)
5116+
if (qual1.tpe.isVolatile) TypeSelectionFromVolatileTypeError(tree, qual1)
51185117
else typedSelect(qual1, selector)
51195118

51205119
case CompoundTypeTree(templ) =>

src/compiler/scala/tools/nsc/typechecker/Unapplies.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ trait Unapplies extends ast.TreeDSL
2323

2424
private val unapplyParamName = nme.x_0
2525

26+
27+
// In the typeCompleter (templateSig) of a case class (resp it's module),
28+
// synthetic `copy` (reps `apply`, `unapply`) methods are added. To compute
29+
// their signatures, the corresponding ClassDef is needed. During naming (in
30+
// `enterClassDef`), the case class ClassDef is added as an attachment to the
31+
// moduleClass symbol of the companion module.
32+
class ClassForCaseCompanionAttachment(val caseClass: ClassDef)
33+
2634
/** returns type list for return type of the extraction */
2735
def unapplyTypeList(ufn: Symbol, ufntpe: Type) = {
2836
assert(ufn.isMethod, ufn)

src/compiler/scala/tools/reflect/FastTrack.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ trait FastTrack {
1515
import definitions._
1616

1717
import language.implicitConversions
18-
private implicit def context2taggers(c0: MacroContext) : Taggers { val c: c0.type } = new { val c: c0.type = c0 } with Taggers
19-
private implicit def context2contextreifiers(c0: MacroContext) : ContextReifiers { val c: c0.type } = new { val c: c0.type = c0 } with ContextReifiers
18+
private implicit def context2taggers(c0: MacroContext): Taggers { val c: c0.type } = new { val c: c0.type = c0 } with Taggers
19+
private implicit def context2contextreifiers(c0: MacroContext): ContextReifiers { val c: c0.type } = new { val c: c0.type = c0 } with ContextReifiers
20+
private implicit def context2macroimplementations(c0: MacroContext): MacroImplementations { val c: c0.type } = new { val c: c0.type = c0 } with MacroImplementations
2021

2122
implicit def fastTrackEntry2MacroRuntime(entry: FastTrackEntry): MacroRuntime = args => entry.run(args)
2223
type FastTrackExpander = PartialFunction[(MacroContext, Tree), Tree]
@@ -42,6 +43,7 @@ trait FastTrack {
4243
ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) }
4344
MacroContextReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExprForMacroContext(c.prefix.tree, expr) }
4445
ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree }
46+
StringContext_f bindTo { case (c, Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args) }
4547
registry
4648
}
4749
}

0 commit comments

Comments
 (0)