Skip to content

Commit 9afc00c

Browse files
committed
Merge pull request scala#1664 from paulp/merge-2.10.x-master
Merge 2.10.x into master.
2 parents 889cead + f0e9237 commit 9afc00c

Some content is hidden

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

58 files changed

+736
-180
lines changed

src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -455,28 +455,16 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
455455
def inheritanceDiagram = makeInheritanceDiagram(this)
456456
def contentDiagram = makeContentDiagram(this)
457457

458-
def groupSearch[T](extractor: Comment => T, default: T): T = {
459-
// query this template
460-
if (comment.isDefined) {
461-
val entity = extractor(comment.get)
462-
if (entity != default) return entity
458+
def groupSearch[T](extractor: Comment => Option[T]): Option[T] = {
459+
val comments = comment +: linearizationTemplates.collect { case dtpl: DocTemplateImpl => dtpl.comment }
460+
comments.flatten.map(extractor).flatten.headOption orElse {
461+
Option(inTpl) flatMap (_.groupSearch(extractor))
463462
}
464-
// query linearization
465-
if (!sym.isPackage)
466-
for (tpl <- linearizationTemplates.collect{ case dtpl: DocTemplateImpl if dtpl!=this => dtpl}) {
467-
val entity = tpl.groupSearch(extractor, default)
468-
if (entity != default) return entity
469-
}
470-
// query inTpl, going up the ownerChain
471-
if (inTpl != null)
472-
inTpl.groupSearch(extractor, default)
473-
else
474-
default
475463
}
476464

477-
def groupDescription(group: String): Option[Body] = groupSearch(_.groupDesc.get(group), if (group == defaultGroup) defaultGroupDesc else None)
478-
def groupPriority(group: String): Int = groupSearch(_.groupPrio.get(group) match { case Some(prio) => prio; case _ => 0 }, if (group == defaultGroup) defaultGroupPriority else 0)
479-
def groupName(group: String): String = groupSearch(_.groupNames.get(group) match { case Some(name) => name; case _ => group }, if (group == defaultGroup) defaultGroupName else group)
465+
def groupDescription(group: String): Option[Body] = groupSearch(_.groupDesc.get(group)) orElse { if (group == defaultGroup) defaultGroupDesc else None }
466+
def groupPriority(group: String): Int = groupSearch(_.groupPrio.get(group)) getOrElse { if (group == defaultGroup) defaultGroupPriority else 0 }
467+
def groupName(group: String): String = groupSearch(_.groupNames.get(group)) getOrElse { if (group == defaultGroup) defaultGroupName else group }
480468
}
481469

482470
abstract class PackageImpl(sym: Symbol, inTpl: PackageImpl) extends DocTemplateImpl(sym, inTpl) with Package {

src/compiler/scala/tools/nsc/reporters/Reporter.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ abstract class Reporter {
1919
class Severity(val id: Int) extends severity.Value {
2020
var count: Int = 0
2121
}
22-
val INFO = new Severity(0)
23-
val WARNING = new Severity(1)
24-
val ERROR = new Severity(2)
22+
val INFO = new Severity(0) {
23+
override def toString: String = "INFO"
24+
}
25+
val WARNING = new Severity(1) {
26+
override def toString: String = "WARNING"
27+
}
28+
val ERROR = new Severity(2) {
29+
override def toString: String = "ERROR"
30+
}
2531

2632
/** Whether very long lines can be truncated. This exists so important
2733
* debugging information (like printing the classpath) is not rendered

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ trait MethodSynthesis {
373373
// spot that brand of them. In other words it's an artifact of the implementation.
374374
val tpt = derivedSym.tpe.finalResultType match {
375375
case ExistentialType(_, _) => TypeTree()
376+
case _ if mods.isDeferred => TypeTree()
376377
case tp => TypeTree(tp)
377378
}
378379
tpt setPos derivedSym.pos.focus

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,17 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
414414
// (the prefix of the argument passed to the unapply must equal the prefix of the type of the binder)
415415
val treeMaker = TypeTestTreeMaker(patBinder, patBinder, extractor.paramType, extractor.paramType)(pos, extractorArgTypeTest = true)
416416
(List(treeMaker), treeMaker.nextBinder)
417-
} else (Nil, patBinder)
417+
} else {
418+
// no type test needed, but the tree maker relies on `patBinderOrCasted` having type `extractor.paramType` (and not just some type compatible with it)
419+
// SI-6624 shows this is necessary because apparently patBinder may have an unfortunate type (.decls don't have the case field accessors)
420+
// TODO: get to the bottom of this -- I assume it happens when type checking infers a weird type for an unapply call
421+
// by going back to the parameterType for the extractor call we get a saner type, so let's just do that for now
422+
/* TODO: uncomment when `settings.developer` and `devWarning` become available
423+
if (settings.developer.value && !(patBinder.info =:= extractor.paramType))
424+
devWarning(s"resetting info of $patBinder: ${patBinder.info} to ${extractor.paramType}")
425+
*/
426+
(Nil, patBinder setInfo extractor.paramType)
427+
}
418428

419429
withSubPats(typeTestTreeMaker :+ extractor.treeMaker(patBinderOrCasted, pos), extractor.subBindersAndPatterns: _*)
420430
}

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,10 @@ trait Typers extends Modes with Adaptations with Tags {
10581058
instantiateToMethodType(mt)
10591059

10601060
case _ =>
1061+
def shouldInsertApply(tree: Tree) = inAllModes(mode, EXPRmode | FUNmode) && (tree.tpe match {
1062+
case _: MethodType | _: OverloadedType | _: PolyType => false
1063+
case _ => applyPossible
1064+
})
10611065
def applyPossible = {
10621066
def applyMeth = member(adaptToName(tree, nme.apply), nme.apply)
10631067
dyna.acceptsApplyDynamic(tree.tpe) || (
@@ -1071,14 +1075,12 @@ trait Typers extends Modes with Adaptations with Tags {
10711075
adaptType()
10721076
else if (
10731077
inExprModeButNot(mode, FUNmode) && !tree.isDef && // typechecking application
1074-
tree.symbol != null && tree.symbol.isTermMacro) // of a macro
1078+
tree.symbol != null && tree.symbol.isTermMacro && // of a macro
1079+
!tree.attachments.get[SuppressMacroExpansionAttachment.type].isDefined)
10751080
macroExpand(this, tree, mode, pt)
10761081
else if (inAllModes(mode, PATTERNmode | FUNmode))
10771082
adaptConstrPattern()
1078-
else if (inAllModes(mode, EXPRmode | FUNmode) &&
1079-
!tree.tpe.isInstanceOf[MethodType] &&
1080-
!tree.tpe.isInstanceOf[OverloadedType] &&
1081-
applyPossible)
1083+
else if (shouldInsertApply(tree))
10821084
insertApply()
10831085
else if (!context.undetparams.isEmpty && !inPolyMode(mode)) { // (9)
10841086
assert(!inHKMode(mode), modeString(mode)) //@M
@@ -3772,9 +3774,14 @@ trait Typers extends Modes with Adaptations with Tags {
37723774
case t: ValOrDefDef => t.rhs
37733775
case t => t
37743776
}
3775-
val (outer, explicitTargs) = cxTree1 match {
3777+
val cxTree2 = cxTree1 match {
3778+
case Typed(t, tpe) => t // ignore outer type annotation
3779+
case t => t
3780+
}
3781+
val (outer, explicitTargs) = cxTree2 match {
37763782
case TypeApply(fun, targs) => (fun, targs)
37773783
case Apply(TypeApply(fun, targs), args) => (Apply(fun, args), targs)
3784+
case Select(TypeApply(fun, targs), nme) => (Select(fun, nme), targs)
37783785
case t => (t, Nil)
37793786
}
37803787
def hasNamedArg(as: List[Tree]) = as.collectFirst{case AssignOrNamedArg(lhs, rhs) =>}.nonEmpty
@@ -4855,9 +4862,9 @@ trait Typers extends Modes with Adaptations with Tags {
48554862
// find out whether the programmer is trying to eta-expand a macro def
48564863
// to do that we need to typecheck the tree first (we need a symbol of the eta-expandee)
48574864
// that typecheck must not trigger macro expansions, so we explicitly prohibit them
4858-
// Q: "but, " - you may ask - ", `typed1` doesn't call adapt, which does macro expansion, so why explicit check?"
4859-
// A: solely for robustness reasons. this mechanism might change in the future, which might break unprotected code
4860-
val exprTyped = context.withMacrosDisabled(typed1(expr, mode, pt))
4865+
// however we cannot do `context.withMacrosDisabled`
4866+
// because `expr` might contain nested macro calls (see SI-6673)
4867+
val exprTyped = typed1(expr updateAttachment SuppressMacroExpansionAttachment, mode, pt)
48614868
exprTyped match {
48624869
case macroDef if macroDef.symbol != null && macroDef.symbol.isTermMacro && !macroDef.symbol.isErroneous =>
48634870
MacroEtaError(exprTyped)
@@ -5001,8 +5008,14 @@ trait Typers extends Modes with Adaptations with Tags {
50015008
}
50025009

50035010
def typedTypeTree(tree: TypeTree) = {
5004-
if (tree.original != null)
5005-
tree setType typedType(tree.original, mode).tpe
5011+
if (tree.original != null) {
5012+
val newTpt = typedType(tree.original, mode)
5013+
tree setType newTpt.tpe
5014+
newTpt match {
5015+
case tt @ TypeTree() => tree setOriginal tt.original
5016+
case _ => tree
5017+
}
5018+
}
50065019
else
50075020
// we should get here only when something before failed
50085021
// and we try again (@see tryTypedApply). In that case we can assign

src/library/scala/collection/IterableLike.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ self =>
171171
* fewer elements than size.
172172
*/
173173
def sliding(size: Int): Iterator[Repr] = sliding(size, 1)
174-
174+
175175
/** Groups elements in fixed size blocks by passing a "sliding window"
176176
* over them (as opposed to partitioning them, as is done in grouped.)
177177
* @see [[scala.collection.Iterator]], method `sliding`
@@ -293,7 +293,6 @@ self =>
293293

294294
override /*TraversableLike*/ def view = new IterableView[A, Repr] {
295295
protected lazy val underlying = self.repr
296-
override def isEmpty = self.isEmpty
297296
override def iterator = self.iterator
298297
}
299298

src/library/scala/collection/SeqLike.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
630630

631631
override def view = new SeqView[A, Repr] {
632632
protected lazy val underlying = self.repr
633-
override def isEmpty = self.isEmpty
634633
override def iterator = self.iterator
635634
override def length = self.length
636635
override def apply(idx: Int) = self.apply(idx)

src/library/scala/collection/TraversableLike.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ trait TraversableLike[+A, +Repr] extends Any
660660
def view = new TraversableView[A, Repr] {
661661
protected lazy val underlying = self.repr
662662
override def foreach[U](f: A => U) = self foreach f
663-
override def isEmpty = self.isEmpty
664663
}
665664

666665
/** Creates a non-strict view of a slice of this $coll.

src/library/scala/collection/TraversableViewLike.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ trait TraversableViewLike[+A,
192192
override def span(p: A => Boolean): (This, This) = (newTakenWhile(p), newDroppedWhile(p))
193193
override def splitAt(n: Int): (This, This) = (newTaken(n), newDropped(n))
194194

195-
// Without this, isEmpty tests go back to the Traversable default, which
196-
// involves starting a foreach, which can force the first element of the
197-
// view. This is just a backstop - it's overridden at all the "def view"
198-
// instantiation points in the collections where the Coll type is known.
199-
override def isEmpty = underlying match {
200-
case x: GenTraversableOnce[_] => x.isEmpty
201-
case _ => super.isEmpty
202-
}
203-
204195
override def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[This, B, That]): That =
205196
newForced(thisSeq.scanLeft(z)(op)).asInstanceOf[That]
206197

src/library/scala/collection/generic/GenTraversableFactory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import scala.language.higherKinds
3636
* @see GenericCanBuildFrom
3737
*/
3838
abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]]
39-
extends GenericCompanion[CC] {
39+
extends GenericCompanion[CC] {
4040

4141
private[this] val ReusableCBFInstance: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] {
4242
override def apply() = newBuilder[Nothing]

0 commit comments

Comments
 (0)