Skip to content

Commit

Permalink
Merge pull request #1716 from paulp/merge-2.10
Browse files Browse the repository at this point in the history
Merged 2.10.0/x into master.
  • Loading branch information
adriaanm committed Dec 6, 2012
2 parents 4b2330b + c42c174 commit 9547753
Show file tree
Hide file tree
Showing 53 changed files with 675 additions and 139 deletions.
7 changes: 6 additions & 1 deletion build.xml
Expand Up @@ -2672,7 +2672,12 @@ DISTRIBUTION
<target name="dist.base" depends="dist.start">
<mkdir dir="${dist.dir}/lib"/>
<copy toDir="${dist.dir}/lib">
<fileset dir="${build-pack.dir}/lib"/>
<fileset dir="${build-pack.dir}/lib">
<include name="jline.jar"/>
<include name="scalacheck.jar"/>
<include name="scala-partest.jar"/>
<include name="scalap.jar"/>
</fileset>
</copy>
<mkdir dir="${dist.dir}/bin"/>
<!-- TODO - Stop being inefficient and don't copy OSGi bundles overtop other jars. -->
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/scala/reflect/reify/Errors.scala
Expand Up @@ -27,10 +27,10 @@ trait Errors {
}

def CannotConvertManifestToTagWithoutScalaReflect(tpe: Type, manifestInScope: Tree) = {
val msg = s"""
|to create a type tag here, it is necessary to interoperate with the manifest `$manifestInScope` in scope.
|however manifest -> typetag conversion requires Scala reflection, which is not present on the classpath.
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin
val msg =
sm"""to create a type tag here, it is necessary to interoperate with the manifest `$manifestInScope` in scope.
|however manifest -> typetag conversion requires Scala reflection, which is not present on the classpath.
|to proceed put scala-reflect.jar on your compilation classpath and recompile."""
throw new ReificationException(defaultErrorPosition, msg)
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ast/Trees.scala
Expand Up @@ -56,7 +56,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
* The class `C` is stored as a tree attachment.
*/
case class InjectDerivedValue(arg: Tree)
extends SymTree
extends SymTree with TermTree

class PostfixSelect(qual: Tree, name: Name) extends Select(qual, name)

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Expand Up @@ -1898,7 +1898,7 @@ self =>
case _ =>
}
val typeAppliedTree = in.token match {
case LBRACKET => atPos(start, in.offset)(TypeApply(convertToTypeId(t), typeArgs()))
case LBRACKET => atPos(start, in.offset)(AppliedTypeTree(convertToTypeId(t), typeArgs()))
case _ => t
}
in.token match {
Expand Down
40 changes: 25 additions & 15 deletions src/compiler/scala/tools/nsc/transform/Erasure.scala
Expand Up @@ -437,19 +437,19 @@ abstract class Erasure extends AddInterfaces
noclash = false
unit.error(
if (member.owner == root) member.pos else root.pos,
s"""bridge generated for member ${fulldef(member)}
|which overrides ${fulldef(other)}
|clashes with definition of $what;
|both have erased type ${exitingPostErasure(bridge.tpe)}""".stripMargin)
sm"""bridge generated for member ${fulldef(member)}
|which overrides ${fulldef(other)}
|clashes with definition of $what;
|both have erased type ${exitingPostErasure(bridge.tpe)}""")
}
for (bc <- root.baseClasses) {
if (settings.debug.value)
exitingPostErasure(println(
s"""check bridge overrides in $bc
${bc.info.nonPrivateDecl(bridge.name)}
${site.memberType(bridge)}
${site.memberType(bc.info.nonPrivateDecl(bridge.name) orElse IntClass)}
${(bridge.matchingSymbol(bc, site))}""".stripMargin))
sm"""check bridge overrides in $bc
|${bc.info.nonPrivateDecl(bridge.name)}
|${site.memberType(bridge)}
|${site.memberType(bc.info.nonPrivateDecl(bridge.name) orElse IntClass)}
|${(bridge.matchingSymbol(bc, site))}"""))

def overriddenBy(sym: Symbol) =
sym.matchingSymbol(bc, site).alternatives filter (sym => !sym.isBridge)
Expand Down Expand Up @@ -693,7 +693,7 @@ abstract class Erasure extends AddInterfaces
adaptToType(unbox(tree, pt), pt)
else if (isPrimitiveValueType(tree.tpe) && !isPrimitiveValueType(pt)) {
adaptToType(box(tree, pt.toString), pt)
} else if (tree.tpe.isInstanceOf[MethodType] && tree.tpe.params.isEmpty) {
} else if (isMethodTypeWithEmptyParams(tree.tpe)) {
// [H] this assert fails when trying to typecheck tree !(SomeClass.this.bitmap) for single lazy val
//assert(tree.symbol.isStable, "adapt "+tree+":"+tree.tpe+" to "+pt)
adaptToType(Apply(tree, List()) setPos tree.pos setType tree.tpe.resultType, pt)
Expand Down Expand Up @@ -774,16 +774,21 @@ abstract class Erasure extends AddInterfaces
else if (!isPrimitiveValueType(qual1.tpe) && isPrimitiveValueMember(tree.symbol))
qual1 = unbox(qual1, tree.symbol.owner.tpe)

if (isPrimitiveValueMember(tree.symbol) && !isPrimitiveValueType(qual1.tpe))
def selectFrom(qual: Tree) = treeCopy.Select(tree, qual, name)

if (isPrimitiveValueMember(tree.symbol) && !isPrimitiveValueType(qual1.tpe)) {
tree.symbol = NoSymbol
else if (qual1.tpe.isInstanceOf[MethodType] && qual1.tpe.params.isEmpty) {
selectFrom(qual1)
} else if (isMethodTypeWithEmptyParams(qual1.tpe)) {
assert(qual1.symbol.isStable, qual1.symbol);
qual1 = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType
val applied = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType
adaptMember(selectFrom(applied))
} else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.typeSymbol isSubClass tree.symbol.owner))) {
assert(tree.symbol.owner != ArrayClass)
qual1 = cast(qual1, tree.symbol.owner.tpe)
selectFrom(cast(qual1, tree.symbol.owner.tpe))
} else {
selectFrom(qual1)
}
treeCopy.Select(tree, qual1, name)
}
case SelectFromArray(qual, name, erasure) =>
var qual1 = typedQualifier(qual)
Expand Down Expand Up @@ -861,6 +866,11 @@ abstract class Erasure extends AddInterfaces
tree1
}
}

private def isMethodTypeWithEmptyParams(tpe: Type) = tpe match {
case MethodType(Nil, _) => true
case _ => false
}
}

/** The erasure transformer */
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/UnCurry.scala
Expand Up @@ -371,7 +371,7 @@ abstract class UnCurry extends InfoTransform
}

val isDefinedAtMethodDef = {
val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL)
val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL | SYNTHETIC)
val params = methSym newSyntheticValueParams formals
methSym setInfoAndEnter MethodType(params, BooleanClass.tpe)

Expand Down
28 changes: 14 additions & 14 deletions src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
Expand Up @@ -106,9 +106,9 @@ trait ContextErrors {
s"$name extends Any, not AnyRef"
)
if (isPrimitiveValueType(found) || isTrivialTopType(tp)) "" else "\n" +
s"""|Note that $what.
|Such types can participate in value classes, but instances
|cannot appear in singleton types or in reference comparisons.""".stripMargin
sm"""|Note that $what.
|Such types can participate in value classes, but instances
|cannot appear in singleton types or in reference comparisons."""
}

import ErrorUtils._
Expand Down Expand Up @@ -1125,9 +1125,9 @@ trait ContextErrors {
(isView: Boolean, pt: Type, tree: Tree)(implicit context0: Context) = {
if (!info1.tpe.isErroneous && !info2.tpe.isErroneous) {
def coreMsg =
s"""| $pre1 ${info1.sym.fullLocationString} of type ${info1.tpe}
| $pre2 ${info2.sym.fullLocationString} of type ${info2.tpe}
| $trailer""".stripMargin
sm"""| $pre1 ${info1.sym.fullLocationString} of type ${info1.tpe}
| $pre2 ${info2.sym.fullLocationString} of type ${info2.tpe}
| $trailer"""
def viewMsg = {
val found :: req :: _ = pt.typeArgs
def explanation = {
Expand All @@ -1138,19 +1138,19 @@ trait ContextErrors {
// involving Any, are further explained from foundReqMsg.
if (AnyRefClass.tpe <:< req) (
if (sym == AnyClass || sym == UnitClass) (
s"""|Note: ${sym.name} is not implicitly converted to AnyRef. You can safely
|pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so.""".stripMargin
sm"""|Note: ${sym.name} is not implicitly converted to AnyRef. You can safely
|pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so."""
)
else boxedClass get sym map (boxed =>
s"""|Note: an implicit exists from ${sym.fullName} => ${boxed.fullName}, but
|methods inherited from Object are rendered ambiguous. This is to avoid
|a blanket implicit which would convert any ${sym.fullName} to any AnyRef.
|You may wish to use a type ascription: `x: ${boxed.fullName}`.""".stripMargin
sm"""|Note: an implicit exists from ${sym.fullName} => ${boxed.fullName}, but
|methods inherited from Object are rendered ambiguous. This is to avoid
|a blanket implicit which would convert any ${sym.fullName} to any AnyRef.
|You may wish to use a type ascription: `x: ${boxed.fullName}`."""
) getOrElse ""
)
else
s"""|Note that implicit conversions are not applicable because they are ambiguous:
|${coreMsg}are possible conversion functions from $found to $req""".stripMargin
sm"""|Note that implicit conversions are not applicable because they are ambiguous:
|${coreMsg}are possible conversion functions from $found to $req"""
}
typeErrorMsg(found, req, infer.isPossiblyMissingArgs(found, req)) + (
if (explanation == "") "" else "\n" + explanation
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Expand Up @@ -1298,17 +1298,17 @@ trait Implicits {
else {
if (ReflectRuntimeUniverse == NoSymbol) {
// todo. write a test for this
context.error(pos, s"""
|to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
|however typetag -> manifest conversion requires Scala reflection, which is not present on the classpath.
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin)
context.error(pos,
sm"""to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
|however typetag -> manifest conversion requires Scala reflection, which is not present on the classpath.
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""")
return SearchFailure
}
if (resolveClassTag(pos, tp, allowMaterialization = true) == EmptyTree) {
context.error(pos, s"""
|to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
|however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
|to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""".trim.stripMargin)
context.error(pos,
sm"""to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
|however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
|to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""")
return SearchFailure
}
val cm = typed(Ident(ReflectRuntimeCurrentMirror))
Expand Down
13 changes: 3 additions & 10 deletions src/compiler/scala/tools/nsc/typechecker/Macros.scala
Expand Up @@ -117,16 +117,9 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
}

def pickle(macroImplRef: Tree): Tree = {
val macroImpl = macroImplRef.symbol
val MacroImplReference(owner, macroImpl, targs) = macroImplRef
val paramss = macroImpl.paramss

// this logic relies on the assumptions that were valid for the old macro prototype
// namely that macro implementations can only be defined in top-level classes and modules
// with the new prototype that materialized in a SIP, macros need to be statically accessible, which is different
// for example, a macro def could be defined in a trait that is implemented by an object
// there are some more clever cases when seemingly non-static method ends up being statically accessible
// however, the code below doesn't account for these guys, because it'd take a look of time to get it right
// for now I leave it as a todo and move along to more the important stuff
// todo. refactor when fixing SI-5498
def className: String = {
def loop(sym: Symbol): String = sym match {
Expand All @@ -138,7 +131,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
loop(sym.owner) + separator + sym.javaSimpleName.toString
}

loop(macroImpl.owner.enclClass)
loop(owner)
}

def signature: List[Int] = {
Expand All @@ -159,7 +152,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// I just named it "macro", because it's macro-related, but I could as well name it "foobar"
val nucleus = Ident(newTermName("macro"))
val wrapped = Apply(nucleus, payload map { case (k, v) => Assign(pickleAtom(k), pickleAtom(v)) })
val pickle = gen.mkTypeApply(wrapped, treeInfo.typeArguments(macroImplRef.duplicate))
val pickle = gen.mkTypeApply(wrapped, targs map (_.duplicate))

// assign NoType to all freshly created AST nodes
// otherwise pickler will choke on tree.tpe being null
Expand Down
Expand Up @@ -1151,7 +1151,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL

// ExplicitOuter replaces `Select(q, outerSym) OBJ_EQ expectedPrefix` by `Select(q, outerAccessor(outerSym.owner)) OBJ_EQ expectedPrefix`
// if there's an outer accessor, otherwise the condition becomes `true` -- TODO: can we improve needsOuterTest so there's always an outerAccessor?
val outer = expectedTp.typeSymbol.newMethod(vpmName.outer) setInfo expectedTp.prefix setFlag SYNTHETIC | ARTIFACT
val outer = expectedTp.typeSymbol.newMethod(vpmName.outer, newFlags = SYNTHETIC | ARTIFACT) setInfo expectedTp.prefix

(Select(codegen._asInstanceOf(testedBinder, expectedTp), outer)) OBJ_EQ expectedOuter
}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL

// assert(owner ne null); assert(owner ne NoSymbol)
def freshSym(pos: Position, tp: Type = NoType, prefix: String = "x") =
NoSymbol.newTermSymbol(freshName(prefix), pos) setInfo tp
NoSymbol.newTermSymbol(freshName(prefix), pos, newFlags = SYNTHETIC) setInfo tp

def newSynthCaseLabel(name: String) =
NoSymbol.newLabel(freshName(name), NoPosition) setFlag treeInfo.SYNTH_CASE_FLAGS
Expand Down Expand Up @@ -3600,7 +3600,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
*/
def matcher(scrut: Tree, scrutSym: Symbol, restpe: Type)(cases: List[Casegen => Tree], matchFailGen: Option[Tree => Tree]): Tree = {
val matchEnd = newSynthCaseLabel("matchEnd")
val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, SYNTHETIC) setInfo restpe.withoutAnnotations
val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, newFlags = SYNTHETIC) setInfo restpe.withoutAnnotations
matchEnd setInfo MethodType(List(matchRes), restpe)

def newCaseSym = newSynthCaseLabel("case") setInfo MethodType(Nil, restpe)
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Expand Up @@ -1382,8 +1382,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
private def checkCompileTimeOnly(sym: Symbol, pos: Position) = {
if (sym.isCompileTimeOnly) {
def defaultMsg =
s"""|Reference to ${sym.fullLocationString} should not have survived past type checking,
|it should have been processed and eliminated during expansion of an enclosing macro.""".stripMargin
sm"""Reference to ${sym.fullLocationString} should not have survived past type checking,
|it should have been processed and eliminated during expansion of an enclosing macro."""
// The getOrElse part should never happen, it's just here as a backstop.
unit.error(pos, sym.compileTimeOnlyMessage getOrElse defaultMsg)
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
Expand Up @@ -525,8 +525,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
}
def isJavaProtected = host.isTrait && sym.isJavaDefined && {
restrictionError(pos, unit,
s"""|$clazz accesses protected $sym inside a concrete trait method.
|Add an accessor in a class extending ${sym.enclClass} as a workaround.""".stripMargin
sm"""$clazz accesses protected $sym inside a concrete trait method.
|Add an accessor in a class extending ${sym.enclClass} as a workaround."""
)
true
}
Expand Down
8 changes: 3 additions & 5 deletions src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
Expand Up @@ -268,11 +268,9 @@ abstract class TreeCheckers extends Analyzer {
if (sym.owner != currentOwner) {
val expected = currentOwner.ownerChain find (x => cond(x)) getOrElse { fail("DefTree can't find owner: ") ; NoSymbol }
if (sym.owner != expected)
fail("""|
| currentOwner chain: %s
| symbol chain: %s""".stripMargin.format(
currentOwner.ownerChain take 3 mkString " -> ",
sym.ownerChain mkString " -> ")
fail(sm"""|
| currentOwner chain: ${currentOwner.ownerChain take 3 mkString " -> "}
| symbol chain: ${sym.ownerChain mkString " -> "}"""
)
}
}
Expand Down

0 comments on commit 9547753

Please sign in to comment.