summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala20
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala43
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/library/scala/AnyVal.scala2
-rw-r--r--src/library/scala/App.scala12
-rw-r--r--src/library/scala/collection/GenSeqLike.scala2
-rw-r--r--src/reflect/scala/reflect/api/Trees.scala16
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala12
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala3
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala12
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala20
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala8
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala9
-rw-r--r--src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala11
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala1
-rw-r--r--test/files/presentation/context-bounds1.check51
-rw-r--r--test/files/presentation/context-bounds1/Test.scala3
-rw-r--r--test/files/presentation/context-bounds1/src/ContextBounds.scala13
-rw-r--r--test/files/presentation/t4287.check11
-rw-r--r--test/files/presentation/t4287/Test.scala3
-rw-r--r--test/files/presentation/t4287/src/Foo.scala5
-rw-r--r--test/files/presentation/t4287b.check6
-rw-r--r--test/files/presentation/t4287b/Test.scala3
-rw-r--r--test/files/presentation/t4287b/src/Foo.scala15
-rw-r--r--test/files/presentation/t4287c.check11
-rw-r--r--test/files/presentation/t4287c.flags1
-rw-r--r--test/files/presentation/t4287c/Test.scala3
-rw-r--r--test/files/presentation/t4287c/src/Foo.scala9
-rw-r--r--test/files/run/t4287inferredMethodTypes.check30
-rw-r--r--test/files/run/t4287inferredMethodTypes.scala25
-rw-r--r--test/files/run/t5603.check4
-rw-r--r--test/files/run/t7974.check104
-rw-r--r--test/files/run/t7974/Symbols.scala6
-rw-r--r--test/files/run/t7974/Test.scala20
-rw-r--r--test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala2
35 files changed, 431 insertions, 67 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 61ea9230a7..d122a1a207 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -623,15 +623,6 @@ self =>
syntaxError(tpt.pos, "no * parameter type allowed here", skipIt = false)
}
- /** Check that tree is a legal clause of a forSome. */
- def checkLegalExistential(t: Tree) = t match {
- case TypeDef(_, _, _, TypeBoundsTree(_, _)) |
- ValDef(_, _, _, EmptyTree) | EmptyTree =>
- ;
- case _ =>
- syntaxError(t.pos, "not a legal existential clause", skipIt = false)
- }
-
/* -------------- TOKEN CLASSES ------------------------------------------- */
def isModifier: Boolean = in.token match {
@@ -885,9 +876,14 @@ self =>
}
}
private def makeExistentialTypeTree(t: Tree) = {
- val whereClauses = refinement()
- whereClauses foreach checkLegalExistential
- ExistentialTypeTree(t, whereClauses)
+ // EmptyTrees in the result of refinement() stand for parse errors
+ // so it's okay for us to filter them out here
+ ExistentialTypeTree(t, refinement() flatMap {
+ case t @ TypeDef(_, _, _, TypeBoundsTree(_, _)) => Some(t)
+ case t @ ValDef(_, _, _, EmptyTree) => Some(t)
+ case EmptyTree => None
+ case _ => syntaxError(t.pos, "not a legal existential clause", skipIt = false); None
+ })
}
/** {{{
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 9738769db9..f14fce5de9 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -481,18 +481,33 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
* For instance, say we have a Scala class:
*
* class Cls {
- * // ...
- * def someSymbol = `symbolic
- * // ...
+ * def someSymbol1 = 'Symbolic1
+ * def someSymbol2 = 'Symbolic2
+ * def sameSymbol1 = 'Symbolic1
+ * val someSymbol3 = 'Symbolic3
* }
*
* After transformation, this class looks like this:
*
* class Cls {
- * private "static" val <some_name>$symbolic = Symbol("symbolic")
- * // ...
- * def someSymbol = <some_name>$symbolic
- * // ...
+ * private <static> var symbol$1: scala.Symbol
+ * private <static> var symbol$2: scala.Symbol
+ * private <static> var symbol$3: scala.Symbol
+ * private val someSymbol3: scala.Symbol
+ *
+ * private <static> def <clinit> = {
+ * symbol$1 = Symbol.apply("Symbolic1")
+ * symbol$2 = Symbol.apply("Symbolic2")
+ * }
+ *
+ * private def <init> = {
+ * someSymbol3 = symbol$3
+ * }
+ *
+ * def someSymbol1 = symbol$1
+ * def someSymbol2 = symbol$2
+ * def sameSymbol1 = symbol$1
+ * val someSymbol3 = someSymbol3
* }
*
* The reasoning behind this transformation is the following. Symbols get interned - they are stored
@@ -502,17 +517,17 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
* is accessed only once during class loading, and after that, the unique symbol is in the static
* member. Hence, it is cheap to both reach the unique symbol and do equality checks on it.
*
- * And, finally, be advised - scala symbol literal and the Symbol class of the compiler
+ * And, finally, be advised - Scala's Symbol literal (scala.Symbol) and the Symbol class of the compiler
* have little in common.
*/
case Apply(fn, (arg @ Literal(Constant(symname: String))) :: Nil) if fn.symbol == Symbol_apply =>
def transformApply = {
- // add the symbol name to a map if it's not there already
- val rhs = gen.mkMethodCall(Symbol_apply, arg :: Nil)
- val staticFieldSym = getSymbolStaticField(tree.pos, symname, rhs, tree)
- // create a reference to a static field
- val ntree = typedWithPos(tree.pos)(REF(staticFieldSym))
- super.transform(ntree)
+ // add the symbol name to a map if it's not there already
+ val rhs = gen.mkMethodCall(Symbol_apply, arg :: Nil)
+ val staticFieldSym = getSymbolStaticField(tree.pos, symname, rhs, tree)
+ // create a reference to a static field
+ val ntree = typedWithPos(tree.pos)(REF(staticFieldSym))
+ super.transform(ntree)
}
transformApply
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 14e16fc591..6b5afce993 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1912,7 +1912,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val primaryCtor1 = primaryCtor match {
case DefDef(_, _, _, _, _, Block(earlyVals :+ global.pendingSuperCall, unit)) =>
val argss = superArgs(parents1.head) getOrElse Nil
- val pos = wrappingPos(parents1.head.pos, argss.flatten)
+ val pos = wrappingPos(parents1.head.pos, primaryCtor :: argss.flatten).makeTransparent
val superCall = atPos(pos)(PrimarySuperCall(argss))
deriveDefDef(primaryCtor)(block => Block(earlyVals :+ superCall, unit) setPos pos) setPos pos
case _ => primaryCtor
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index 9def6cb054..ff62948413 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -33,7 +33,7 @@ package scala
*
* User-defined value classes which avoid object allocation...
*
- * - must have a single, public `val` parameter that is the underlying runtime representation.
+ * - must have a single `val` parameter that is the underlying runtime representation.
* - can define `def`s, but no `val`s, `var`s, or nested `traits`s, `class`es or `object`s.
* - typically extend no other trait apart from `AnyVal`.
* - cannot be used in type tests or pattern matching.
diff --git a/src/library/scala/App.scala b/src/library/scala/App.scala
index 90a8977e81..ef39ee2134 100644
--- a/src/library/scala/App.scala
+++ b/src/library/scala/App.scala
@@ -28,9 +28,8 @@ import scala.collection.mutable.ListBuffer
* functionality, which means that fields of the object will not have been initialized
* before the main method has been executed.'''''
*
- * It should also be noted that the `main` method will not normally need to be overridden:
- * the purpose is to turn the whole class body into the “main method”. You should only
- * chose to override it if you know what you are doing.
+ * It should also be noted that the `main` method should not be overridden:
+ * the whole class body becomes the “main method”.
*
* @author Martin Odersky
* @version 2.1, 15/02/2011
@@ -61,11 +60,12 @@ trait App extends DelayedInit {
}
/** The main method.
- * This stores all argument so that they can be retrieved with `args`
- * and the executes all initialization code segments in the order they were
- * passed to `delayedInit`
+ * This stores all arguments so that they can be retrieved with `args`
+ * and then executes all initialization code segments in the order in which
+ * they were passed to `delayedInit`.
* @param args the arguments passed to the main method
*/
+ @deprecatedOverriding("main should not be overridden", "2.11.0")
def main(args: Array[String]) = {
this._args = args
for (proc <- initCode) proc()
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 27b75c0491..e265beca1b 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -190,7 +190,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*/
def lastIndexWhere(p: A => Boolean, end: Int): Int
- /** Returns new $coll wih elements in reversed order.
+ /** Returns new $coll with elements in reversed order.
*
* $willNotTerminateInf
*
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala
index 241747e6d8..83da5141b9 100644
--- a/src/reflect/scala/reflect/api/Trees.scala
+++ b/src/reflect/scala/reflect/api/Trees.scala
@@ -2058,8 +2058,8 @@ trait Trees { self: Universe =>
* @group Extractors
*/
abstract class ExistentialTypeTreeExtractor {
- def apply(tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
- def unapply(existentialTypeTree: ExistentialTypeTree): Option[(Tree, List[Tree])]
+ def apply(tpt: Tree, whereClauses: List[MemberDef]): ExistentialTypeTree
+ def unapply(existentialTypeTree: ExistentialTypeTree): Option[(Tree, List[MemberDef])]
}
/** The API that all existential type trees support
@@ -2069,8 +2069,12 @@ trait Trees { self: Universe =>
/** The underlying type of the existential type. */
def tpt: Tree
- /** The clauses of the definition of the existential type. */
- def whereClauses: List[Tree]
+ /** The clauses of the definition of the existential type.
+ * Elements are one of the following:
+ * 1) TypeDef with TypeBoundsTree right-hand side
+ * 2) ValDef with empty right-hand side
+ */
+ def whereClauses: List[MemberDef]
}
/** A synthetic tree holding an arbitrary type. Not to be confused with
@@ -2533,7 +2537,7 @@ trait Trees { self: Universe =>
/** Creates a `ExistentialTypeTree` node from the given components, having a given `tree` as a prototype.
* Having a tree as a prototype means that the tree's attachments, type and symbol will be copied into the result.
*/
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]): ExistentialTypeTree
}
// ---------------------- traversing and transforming ------------------------------
@@ -2654,6 +2658,8 @@ trait Trees { self: Universe =>
def transformValDefss(treess: List[List[ValDef]]): List[List[ValDef]] =
treess mapConserve (transformValDefs(_))
/** Transforms a list of `CaseDef` nodes. */
+ def transformMemberDefs(trees: List[MemberDef]): List[MemberDef] =
+ trees mapConserve (tree => transform(tree).asInstanceOf[MemberDef])
def transformCaseDefs(trees: List[CaseDef]): List[CaseDef] =
trees mapConserve (tree => transform(tree).asInstanceOf[CaseDef])
/** Transforms a list of `Ident` nodes. */
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 1fe6f249b8..38be6fcf56 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -1207,15 +1207,21 @@ trait Definitions extends api.StandardDefinitions {
}
def getMemberMethod(owner: Symbol, name: Name): TermSymbol = {
getMember(owner, name.toTermName) match {
- // todo. member symbol becomes a term symbol in cleanup. is this a bug?
- // case x: MethodSymbol => x
case x: TermSymbol => x
case _ => fatalMissingSymbol(owner, name, "method")
}
}
+ private lazy val erasurePhase = findPhaseWithName("erasure")
def getMemberIfDefined(owner: Symbol, name: Name): Symbol =
- owner.info.nonPrivateMember(name)
+ // findMember considered harmful after erasure; e.g.
+ //
+ // scala> exitingErasure(Symbol_apply).isOverloaded
+ // res27: Boolean = true
+ //
+ enteringPhaseNotLaterThan(erasurePhase )(
+ owner.info.nonPrivateMember(name)
+ )
/** Using getDecl rather than getMember may avoid issues with
* OverloadedTypes turning up when you don't want them, if you
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index cc6e55192f..91ba552012 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -409,7 +409,7 @@ trait Importers extends api.Importers { to: SymbolTable =>
case from.TypeBoundsTree(lo, hi) =>
new TypeBoundsTree(importTree(lo), importTree(hi))
case from.ExistentialTypeTree(tpt, whereClauses) =>
- new ExistentialTypeTree(importTree(tpt), whereClauses map importTree)
+ new ExistentialTypeTree(importTree(tpt), whereClauses map importMemberDef)
case from.EmptyTree =>
EmptyTree
case null =>
@@ -475,6 +475,7 @@ trait Importers extends api.Importers { to: SymbolTable =>
new ImportSelector(importName(sel.name), sel.namePos, if (sel.rename != null) importName(sel.rename) else null, sel.renamePos)
def importValDef(tree: from.ValDef): ValDef = importTree(tree).asInstanceOf[ValDef]
def importTypeDef(tree: from.TypeDef): TypeDef = importTree(tree).asInstanceOf[TypeDef]
+ def importMemberDef(tree: from.MemberDef): MemberDef = importTree(tree).asInstanceOf[MemberDef]
def importTemplate(tree: from.Template): Template = importTree(tree).asInstanceOf[Template]
def importRefTree(tree: from.RefTree): RefTree = importTree(tree).asInstanceOf[RefTree]
def importIdent(tree: from.Ident): Ident = importTree(tree).asInstanceOf[Ident]
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index 0ce5a0fbea..c46a559d6d 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -244,6 +244,18 @@ abstract class SymbolTable extends macros.Universe
finally popPhase(saved)
}
+ final def findPhaseWithName(phaseName: String): Phase = {
+ var ph = phase
+ while (ph != NoPhase && ph.name != phaseName) {
+ ph = ph.prev
+ }
+ if (ph eq NoPhase) phase else ph
+ }
+ final def enteringPhaseWithName[T](phaseName: String)(body: => T): T = {
+ val phase = findPhaseWithName(phaseName)
+ enteringPhase(phase)(body)
+ }
+
def slowButSafeEnteringPhase[T](ph: Phase)(op: => T): T = {
if (isCompilerUniverse) enteringPhase(ph)(op)
else op
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index 6269004298..f6d21ec9bd 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -340,11 +340,13 @@ abstract class TreeGen extends macros.TreeBuilder {
// create parameters for <init> as synthetic trees.
var vparamss1 = mmap(vparamss) { vd =>
- atPos(vd.pos.focus) {
+ val param = atPos(vd.pos.makeTransparent) {
val mods = Modifiers(vd.mods.flags & (IMPLICIT | DEFAULTPARAM | BYNAMEPARAM) | PARAM | PARAMACCESSOR)
- ValDef(mods withAnnotations vd.mods.annotations, vd.name, vd.tpt.duplicate, vd.rhs.duplicate)
+ ValDef(mods withAnnotations vd.mods.annotations, vd.name, vd.tpt.duplicate, duplicateAndKeepPositions(vd.rhs))
}
+ param
}
+
val (edefs, rest) = body span treeInfo.isEarlyDef
val (evdefs, etdefs) = edefs partition treeInfo.isEarlyValDef
val gvdefs = evdefs map {
@@ -377,15 +379,21 @@ abstract class TreeGen extends macros.TreeBuilder {
// this means that we don't know what will be the arguments of the super call
// therefore here we emit a dummy which gets populated when the template is named and typechecked
Some(
- // TODO: previously this was `wrappingPos(superPos, lvdefs ::: argss.flatten)`
- // is it going to be a problem that we can no longer include the `argss`?
- atPos(wrappingPos(superPos, lvdefs)) (
+ atPos(wrappingPos(superPos, lvdefs ::: vparamss1.flatten).makeTransparent) (
DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant())))))
}
}
constr foreach (ensureNonOverlapping(_, parents ::: gvdefs, focus = false))
// Field definitions for the class - remove defaults.
- val fieldDefs = vparamss.flatten map (vd => copyValDef(vd)(mods = vd.mods &~ DEFAULTPARAM, rhs = EmptyTree))
+
+ val fieldDefs = vparamss.flatten map (vd => {
+ val field = copyValDef(vd)(mods = vd.mods &~ DEFAULTPARAM, rhs = EmptyTree)
+ // Prevent overlapping of `field` end's position with default argument's start position.
+ // This is needed for `Positions.Locator(pos).traverse` to return the correct tree when
+ // the `pos` is a point position with all its values equal to `vd.rhs.pos.start`.
+ if(field.pos.isRange && vd.rhs.pos.isRange) field.pos = field.pos.withEnd(vd.rhs.pos.start - 1)
+ field
+ })
global.Template(parents, self, gvdefs ::: fieldDefs ::: constr ++: etdefs ::: rest)
}
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index d191fbd38f..4a518f6c56 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -541,7 +541,7 @@ trait Trees extends api.Trees {
extends TypTree with TypeBoundsTreeApi
object TypeBoundsTree extends TypeBoundsTreeExtractor
- case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree])
+ case class ExistentialTypeTree(tpt: Tree, whereClauses: List[MemberDef])
extends TypTree with ExistentialTypeTreeApi
object ExistentialTypeTree extends ExistentialTypeTreeExtractor
@@ -694,7 +694,7 @@ trait Trees extends api.Trees {
new AppliedTypeTree(tpt, args).copyAttrs(tree)
def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree) =
new TypeBoundsTree(lo, hi).copyAttrs(tree)
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) =
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]) =
new ExistentialTypeTree(tpt, whereClauses).copyAttrs(tree)
}
@@ -910,7 +910,7 @@ trait Trees extends api.Trees {
if (lo0 == lo) && (hi0 == hi) => t
case _ => treeCopy.TypeBoundsTree(tree, lo, hi)
}
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) = tree match {
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]) = tree match {
case t @ ExistentialTypeTree(tpt0, whereClauses0)
if (tpt0 == tpt) && (whereClauses0 == whereClauses) => t
case _ => treeCopy.ExistentialTypeTree(tree, tpt, whereClauses)
@@ -1421,7 +1421,7 @@ trait Trees extends api.Trees {
case CompoundTypeTree(templ) =>
treeCopy.CompoundTypeTree(tree, transformTemplate(templ))
case ExistentialTypeTree(tpt, whereClauses) =>
- treeCopy.ExistentialTypeTree(tree, transform(tpt), transformTrees(whereClauses))
+ treeCopy.ExistentialTypeTree(tree, transform(tpt), transformMemberDefs(whereClauses))
case Return(expr) =>
treeCopy.Return(tree, transform(expr))
case Alternative(trees) =>
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index a6c34935ad..3d222fce10 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -487,6 +487,7 @@ abstract class UnPickler {
def nameRef() = readNameRef()
def tparamRef() = readTypeDefRef()
def vparamRef() = readValDefRef()
+ def memberRef() = readMemberDefRef()
def constRef() = readConstantRef()
def idRef() = readIdentRef()
def termNameRef() = readNameRef().toTermName
@@ -520,7 +521,7 @@ abstract class UnPickler {
case CLASStree => ClassDef(modsRef, typeNameRef, rep(tparamRef), implRef)
case COMPOUNDTYPEtree => CompoundTypeTree(implRef)
case DEFDEFtree => DefDef(modsRef, termNameRef, rep(tparamRef), rep(rep(vparamRef)), ref, ref)
- case EXISTENTIALTYPEtree => ExistentialTypeTree(ref, all(ref))
+ case EXISTENTIALTYPEtree => ExistentialTypeTree(ref, all(memberRef))
case FUNCTIONtree => Function(rep(vparamRef), ref)
case IMPORTtree => Import(ref, selectorsRef)
case LABELtree => LabelDef(termNameRef, rep(idRef), ref)
@@ -634,6 +635,12 @@ abstract class UnPickler {
case other =>
errorBadSignature("expected an TypeDef (" + other + ")")
}
+ protected def readMemberDefRef(): MemberDef =
+ readTreeRef() match {
+ case tree:MemberDef => tree
+ case other =>
+ errorBadSignature("expected an MemberDef (" + other + ")")
+ }
protected def errorBadSignature(msg: String) =
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg)
diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
index f61c1f3c50..e4a6503184 100644
--- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
+++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
@@ -41,7 +41,8 @@ trait TraceSymbolActivity {
}
}
- private def signature(id: Int) = runBeforeErasure(allSymbols(id).defString)
+ private lazy val erasurePhase = findPhaseWithName("erasure")
+ private def signature(id: Int) = enteringPhase(erasurePhase)(allSymbols(id).defString)
private def dashes(s: Any): String = ("" + s) map (_ => '-')
private def show(s1: Any, ss: Any*) {
@@ -87,14 +88,6 @@ trait TraceSymbolActivity {
private def showFreq[T, U](xs: Traversable[T])(groupFn: T => U, showFn: U => String) = {
showMapFreq(xs.toList groupBy groupFn)(showFn)
}
- private lazy val findErasurePhase: Phase = {
- var ph = phase
- while (ph != NoPhase && ph.name != "erasure") {
- ph = ph.prev
- }
- if (ph eq NoPhase) phase else ph
- }
- private def runBeforeErasure[T](body: => T): T = enteringPhase(findErasurePhase)(body)
def showAllSymbols() {
if (!enabled) return
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 9c4a3a5fe1..c87995275f 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -425,6 +425,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.languageFeatureModule
definitions.metaAnnotations
definitions.AnnotationDefaultAttr
+ // inaccessible: definitions.erasurePhase
definitions.isPhantomClass
definitions.syntheticCoreClasses
definitions.syntheticCoreMethods
diff --git a/test/files/presentation/context-bounds1.check b/test/files/presentation/context-bounds1.check
new file mode 100644
index 0000000000..b444de59a4
--- /dev/null
+++ b/test/files/presentation/context-bounds1.check
@@ -0,0 +1,51 @@
+reload: ContextBounds.scala
+
+askHyperlinkPos for `Blubb` at (2,23) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Blubb` at (13,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Foo` at (4,17) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Foo` at (9,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Blubb` at (4,32) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Blubb` at (13,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (4,42) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (4,51) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `blubb` at (4,66) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `blubb` at (2,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Foo` at (5,18) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Foo` at (9,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (5,25) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `foo` at (5,36) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `foo` at (10,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (10,14) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (9,11) ContextBounds.scala
+================================================================================
diff --git a/test/files/presentation/context-bounds1/Test.scala b/test/files/presentation/context-bounds1/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/context-bounds1/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/context-bounds1/src/ContextBounds.scala b/test/files/presentation/context-bounds1/src/ContextBounds.scala
new file mode 100644
index 0000000000..72a8f694a3
--- /dev/null
+++ b/test/files/presentation/context-bounds1/src/ContextBounds.scala
@@ -0,0 +1,13 @@
+object ContextBound {
+ val blubb = new Blubb/*#*/
+
+ def work[A: Foo/*#*/](f: Blubb/*#*/ => A/*#*/): A/*#*/ = f(blubb/*#*/) ensuring {
+ implicitly[Foo/*#*/[A/*#*/]].foo/*#*/(_) >= 42
+ }
+}
+
+trait Foo[A] {
+ def foo(a: A/*#*/): Int
+}
+
+class Blubb \ No newline at end of file
diff --git a/test/files/presentation/t4287.check b/test/files/presentation/t4287.check
new file mode 100644
index 0000000000..a922421e18
--- /dev/null
+++ b/test/files/presentation/t4287.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `B` at (1,24) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `B` at (3,8) Foo.scala
+================================================================================
+
+askHyperlinkPos for `a` at (1,31) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `a` at (4,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287/Test.scala b/test/files/presentation/t4287/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287/src/Foo.scala b/test/files/presentation/t4287/src/Foo.scala
new file mode 100644
index 0000000000..a744eaabe2
--- /dev/null
+++ b/test/files/presentation/t4287/src/Foo.scala
@@ -0,0 +1,5 @@
+class Baz(val f: Int = B/*#*/.a/*#*/)
+
+object B {
+ val a = 2
+}
diff --git a/test/files/presentation/t4287b.check b/test/files/presentation/t4287b.check
new file mode 100644
index 0000000000..d4b33650fd
--- /dev/null
+++ b/test/files/presentation/t4287b.check
@@ -0,0 +1,6 @@
+reload: Foo.scala
+
+askHyperlinkPos for `i` at (14,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `i` at (10,9) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287b/Test.scala b/test/files/presentation/t4287b/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287b/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287b/src/Foo.scala b/test/files/presentation/t4287b/src/Foo.scala
new file mode 100644
index 0000000000..47c676e2a2
--- /dev/null
+++ b/test/files/presentation/t4287b/src/Foo.scala
@@ -0,0 +1,15 @@
+trait Greeting {
+ val name: String
+ val msg = "How are you, "+name
+}
+
+object Greeting {
+ val hello = "hello"
+}
+
+class C(i: Int) extends {
+ val nameElse = "Bob"
+} with Greeting {
+ val name = "avc"
+ println(i/*#*/)
+} \ No newline at end of file
diff --git a/test/files/presentation/t4287c.check b/test/files/presentation/t4287c.check
new file mode 100644
index 0000000000..42fc30997d
--- /dev/null
+++ b/test/files/presentation/t4287c.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `A` at (1,18) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (3,8) Foo.scala
+================================================================================
+
+askHyperlinkPos for `a` at (1,25) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `a` at (4,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287c.flags b/test/files/presentation/t4287c.flags
new file mode 100644
index 0000000000..d1a8244169
--- /dev/null
+++ b/test/files/presentation/t4287c.flags
@@ -0,0 +1 @@
+-Yinfer-argument-types \ No newline at end of file
diff --git a/test/files/presentation/t4287c/Test.scala b/test/files/presentation/t4287c/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287c/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287c/src/Foo.scala b/test/files/presentation/t4287c/src/Foo.scala
new file mode 100644
index 0000000000..26870b5021
--- /dev/null
+++ b/test/files/presentation/t4287c/src/Foo.scala
@@ -0,0 +1,9 @@
+class A(a: Int = A/*#*/.a/*#*/)
+
+object A {
+ val a = 2
+}
+
+class B extends A {
+ def this(a) = this()
+} \ No newline at end of file
diff --git a/test/files/run/t4287inferredMethodTypes.check b/test/files/run/t4287inferredMethodTypes.check
new file mode 100644
index 0000000000..56e9c097cc
--- /dev/null
+++ b/test/files/run/t4287inferredMethodTypes.check
@@ -0,0 +1,30 @@
+[[syntax trees at end of typer]] // newSource1.scala
+[0:92]package [0:0]<empty> {
+ [0:21]class A extends [7:21][23]scala.AnyRef {
+ [8:16]<paramaccessor> private[this] val a: [8]Int = _;
+ <8:20>def <init>(<8:20>a: [11]<type: [11]scala.Int> = [17:20]A.a): [7]A = <8:20>{
+ <8:20><8:20><8:20>A.super.<init>();
+ <8:20>()
+ }
+ };
+ [23:47]object A extends [32:47][49]scala.AnyRef {
+ [49]def <init>(): [32]A.type = [49]{
+ [49][49][49]A.super.<init>();
+ [32]()
+ };
+ [36:45]private[this] val a: [40]Int = [44:45]2;
+ [40]<stable> <accessor> def a: [40]Int = [40][40]A.this.a;
+ [8]<synthetic> def <init>$default$1: [8]Int = [19]A.a
+ };
+ [49:92]class B extends [57:92][65:66]A {
+ [65]def <init>(): [57]B = [65]{
+ [65][65][65]B.super.<init>([65]A.<init>$default$1);
+ [57]()
+ };
+ [70:90]def <init>([79:80]a: [79]Int): [74]B = [84:90]{
+ [84:90][84:90][84]B.this.<init>();
+ [84]()
+ }
+ }
+}
+
diff --git a/test/files/run/t4287inferredMethodTypes.scala b/test/files/run/t4287inferredMethodTypes.scala
new file mode 100644
index 0000000000..f14e672da8
--- /dev/null
+++ b/test/files/run/t4287inferredMethodTypes.scala
@@ -0,0 +1,25 @@
+import scala.tools.partest.DirectTest
+
+object Test extends DirectTest {
+
+ override def extraSettings: String =
+ s"-usejavacp -Yinfer-argument-types -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}"
+
+ override def code = """
+class A(a: Int = A.a)
+
+object A {
+ val a = 2
+}
+
+class B extends A {
+ def this(a) = this()
+}
+ """.trim
+
+ override def show(): Unit = {
+ Console.withErr(System.out) {
+ compile()
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check
index 188f39ff82..760a92567c 100644
--- a/test/files/run/t5603.check
+++ b/test/files/run/t5603.check
@@ -10,10 +10,10 @@
[87:209]class C extends [94:209][151:159]Greeting {
[119:139]val nameElse = _;
[95:101]<paramaccessor> private[this] val i: [98:101]Int = _;
- <119:139>def <init>([95]i: [98]Int) = <119:139>{
+ <95:139>def <init>(<95:101>i: [98]Int) = <95:139>{
<119:139>val nameElse = <134:139>"Bob";
[NoPosition][NoPosition][NoPosition]super.<init>();
- [94]()
+ <95:139>()
};
[168:184]val name = [179:184]"avc";
[191:203][191:198]println([199:202]msg)
diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check
new file mode 100644
index 0000000000..0be496d8d0
--- /dev/null
+++ b/test/files/run/t7974.check
@@ -0,0 +1,104 @@
+public class Symbols {
+
+ // compiled from: Symbols.scala
+
+
+
+ // access flags 0x12
+ private final Lscala/Symbol; someSymbol3
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$1
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$2
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$3
+
+ // access flags 0x9
+ public static <clinit>()V
+ L0
+ LINENUMBER 2 L0
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic1"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ L1
+ LINENUMBER 3 L1
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic2"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$2 : Lscala/Symbol;
+ L2
+ LINENUMBER 5 L2
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic3"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$3 : Lscala/Symbol;
+ RETURN
+ MAXSTACK = 2
+ MAXLOCALS = 0
+
+ // access flags 0x1
+ public someSymbol1()Lscala/Symbol;
+ L0
+ LINENUMBER 2 L0
+ GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public someSymbol2()Lscala/Symbol;
+ L0
+ LINENUMBER 3 L0
+ GETSTATIC Symbols.symbol$2 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public sameSymbol1()Lscala/Symbol;
+ L0
+ LINENUMBER 4 L0
+ GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public someSymbol3()Lscala/Symbol;
+ L0
+ LINENUMBER 5 L0
+ ALOAD 0
+ GETFIELD Symbols.someSymbol3 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public <init>()V
+ L0
+ LINENUMBER 6 L0
+ ALOAD 0
+ INVOKESPECIAL java/lang/Object.<init> ()V
+ L1
+ LINENUMBER 5 L1
+ ALOAD 0
+ GETSTATIC Symbols.symbol$3 : Lscala/Symbol;
+ PUTFIELD Symbols.someSymbol3 : Lscala/Symbol;
+ RETURN
+ L2
+ LOCALVARIABLE this LSymbols; L0 L2 0
+ MAXSTACK = 2
+ MAXLOCALS = 1
+}
diff --git a/test/files/run/t7974/Symbols.scala b/test/files/run/t7974/Symbols.scala
new file mode 100644
index 0000000000..2363b724eb
--- /dev/null
+++ b/test/files/run/t7974/Symbols.scala
@@ -0,0 +1,6 @@
+class Symbols {
+ def someSymbol1 = 'Symbolic1
+ def someSymbol2 = 'Symbolic2
+ def sameSymbol1 = 'Symbolic1
+ val someSymbol3 = 'Symbolic3
+}
diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala
new file mode 100644
index 0000000000..9403ea332b
--- /dev/null
+++ b/test/files/run/t7974/Test.scala
@@ -0,0 +1,20 @@
+import java.io.PrintWriter;
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm.util._
+import scala.tools.nsc.util.stringFromWriter
+
+object Test extends BytecodeTest {
+ def show {
+ val classNode = loadClassNode("Symbols", skipDebugInfo = false)
+ val textifier = new Textifier
+ classNode.accept(new TraceClassVisitor(null, textifier, null))
+
+ val classString = stringFromWriter(w => textifier.print(w))
+ val result =
+ classString.split('\n')
+ .dropWhile(elem => elem != "public class Symbols {")
+ .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig"))
+ result foreach println
+ }
+}
diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
index c5cac3ea45..fe90d7222f 100644
--- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
+++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
@@ -92,7 +92,7 @@ trait ArbitraryTreesAndNames {
yield DefDef(mods, name, tparams, vparamss, tpt, rhs)
def genExistentialTypeTree(size: Int) =
- for(tpt <- genTree(size - 1); where <- smallList(size, genTree(size - 1)))
+ for(tpt <- genTree(size - 1); where <- smallList(size, oneOf(genValDef(size - 1), genTypeDef(size - 1))))
yield ExistentialTypeTree(tpt, where)
def genFunction(size: Int) =