Skip to content

Commit c42c174

Browse files
committed
Merge branch 'merge-2.10-wip' into merge-2.10
* merge-2.10-wip: Fixing OSGi distribution. Fix for rangepos crasher. SI-6685 fixes error handling in typedApply Test cases for SI-5726, SI-5733, SI-6320, SI-6551, SI-6722. Asserts about Tree qualifiers. Fix for SI-6731, dropped trees in selectDynamic. neg test added SI-5753 macros cannot be loaded when inherited from a class or a trait Take advantage of the margin stripping interpolator. Adds a margin stripping string interpolator. SI-6718 fixes a volatile test Mark pattern matcher synthetics as SYNTHETIC. Set symbol flags at creation. Fix for SI-6687, wrong isVar logic. Fix for SI-6706, Symbol breakage under GC. findEntry implementation code more concise and DRYer. Fix for SI-6357, cycle with value classes. Refactoring of adaptMethod SI-6677 Insert required cast in `new qual.foo.T` Conflicts: src/compiler/scala/tools/nsc/transform/Erasure.scala src/compiler/scala/tools/nsc/typechecker/Typers.scala src/reflect/scala/reflect/internal/SymbolTable.scala src/reflect/scala/reflect/internal/util/package.scala test/files/neg/gadts1.check
2 parents 4b2330b + b84ecc5 commit c42c174

Some content is hidden

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

53 files changed

+675
-139
lines changed

build.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,12 @@ DISTRIBUTION
26722672
<target name="dist.base" depends="dist.start">
26732673
<mkdir dir="${dist.dir}/lib"/>
26742674
<copy toDir="${dist.dir}/lib">
2675-
<fileset dir="${build-pack.dir}/lib"/>
2675+
<fileset dir="${build-pack.dir}/lib">
2676+
<include name="jline.jar"/>
2677+
<include name="scalacheck.jar"/>
2678+
<include name="scala-partest.jar"/>
2679+
<include name="scalap.jar"/>
2680+
</fileset>
26762681
</copy>
26772682
<mkdir dir="${dist.dir}/bin"/>
26782683
<!-- TODO - Stop being inefficient and don't copy OSGi bundles overtop other jars. -->

src/compiler/scala/reflect/reify/Errors.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ trait Errors {
2727
}
2828

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

src/compiler/scala/tools/nsc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
5656
* The class `C` is stored as a tree attachment.
5757
*/
5858
case class InjectDerivedValue(arg: Tree)
59-
extends SymTree
59+
extends SymTree with TermTree
6060

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ self =>
18981898
case _ =>
18991899
}
19001900
val typeAppliedTree = in.token match {
1901-
case LBRACKET => atPos(start, in.offset)(TypeApply(convertToTypeId(t), typeArgs()))
1901+
case LBRACKET => atPos(start, in.offset)(AppliedTypeTree(convertToTypeId(t), typeArgs()))
19021902
case _ => t
19031903
}
19041904
in.token match {

src/compiler/scala/tools/nsc/transform/Erasure.scala

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,19 @@ abstract class Erasure extends AddInterfaces
437437
noclash = false
438438
unit.error(
439439
if (member.owner == root) member.pos else root.pos,
440-
s"""bridge generated for member ${fulldef(member)}
441-
|which overrides ${fulldef(other)}
442-
|clashes with definition of $what;
443-
|both have erased type ${exitingPostErasure(bridge.tpe)}""".stripMargin)
440+
sm"""bridge generated for member ${fulldef(member)}
441+
|which overrides ${fulldef(other)}
442+
|clashes with definition of $what;
443+
|both have erased type ${exitingPostErasure(bridge.tpe)}""")
444444
}
445445
for (bc <- root.baseClasses) {
446446
if (settings.debug.value)
447447
exitingPostErasure(println(
448-
s"""check bridge overrides in $bc
449-
${bc.info.nonPrivateDecl(bridge.name)}
450-
${site.memberType(bridge)}
451-
${site.memberType(bc.info.nonPrivateDecl(bridge.name) orElse IntClass)}
452-
${(bridge.matchingSymbol(bc, site))}""".stripMargin))
448+
sm"""check bridge overrides in $bc
449+
|${bc.info.nonPrivateDecl(bridge.name)}
450+
|${site.memberType(bridge)}
451+
|${site.memberType(bc.info.nonPrivateDecl(bridge.name) orElse IntClass)}
452+
|${(bridge.matchingSymbol(bc, site))}"""))
453453

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

777-
if (isPrimitiveValueMember(tree.symbol) && !isPrimitiveValueType(qual1.tpe))
777+
def selectFrom(qual: Tree) = treeCopy.Select(tree, qual, name)
778+
779+
if (isPrimitiveValueMember(tree.symbol) && !isPrimitiveValueType(qual1.tpe)) {
778780
tree.symbol = NoSymbol
779-
else if (qual1.tpe.isInstanceOf[MethodType] && qual1.tpe.params.isEmpty) {
781+
selectFrom(qual1)
782+
} else if (isMethodTypeWithEmptyParams(qual1.tpe)) {
780783
assert(qual1.symbol.isStable, qual1.symbol);
781-
qual1 = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType
784+
val applied = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType
785+
adaptMember(selectFrom(applied))
782786
} else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.typeSymbol isSubClass tree.symbol.owner))) {
783787
assert(tree.symbol.owner != ArrayClass)
784-
qual1 = cast(qual1, tree.symbol.owner.tpe)
788+
selectFrom(cast(qual1, tree.symbol.owner.tpe))
789+
} else {
790+
selectFrom(qual1)
785791
}
786-
treeCopy.Select(tree, qual1, name)
787792
}
788793
case SelectFromArray(qual, name, erasure) =>
789794
var qual1 = typedQualifier(qual)
@@ -861,6 +866,11 @@ abstract class Erasure extends AddInterfaces
861866
tree1
862867
}
863868
}
869+
870+
private def isMethodTypeWithEmptyParams(tpe: Type) = tpe match {
871+
case MethodType(Nil, _) => true
872+
case _ => false
873+
}
864874
}
865875

866876
/** The erasure transformer */

src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ abstract class UnCurry extends InfoTransform
371371
}
372372

373373
val isDefinedAtMethodDef = {
374-
val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL)
374+
val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL | SYNTHETIC)
375375
val params = methSym newSyntheticValueParams formals
376376
methSym setInfoAndEnter MethodType(params, BooleanClass.tpe)
377377

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ trait ContextErrors {
106106
s"$name extends Any, not AnyRef"
107107
)
108108
if (isPrimitiveValueType(found) || isTrivialTopType(tp)) "" else "\n" +
109-
s"""|Note that $what.
110-
|Such types can participate in value classes, but instances
111-
|cannot appear in singleton types or in reference comparisons.""".stripMargin
109+
sm"""|Note that $what.
110+
|Such types can participate in value classes, but instances
111+
|cannot appear in singleton types or in reference comparisons."""
112112
}
113113

114114
import ErrorUtils._
@@ -1125,9 +1125,9 @@ trait ContextErrors {
11251125
(isView: Boolean, pt: Type, tree: Tree)(implicit context0: Context) = {
11261126
if (!info1.tpe.isErroneous && !info2.tpe.isErroneous) {
11271127
def coreMsg =
1128-
s"""| $pre1 ${info1.sym.fullLocationString} of type ${info1.tpe}
1129-
| $pre2 ${info2.sym.fullLocationString} of type ${info2.tpe}
1130-
| $trailer""".stripMargin
1128+
sm"""| $pre1 ${info1.sym.fullLocationString} of type ${info1.tpe}
1129+
| $pre2 ${info2.sym.fullLocationString} of type ${info2.tpe}
1130+
| $trailer"""
11311131
def viewMsg = {
11321132
val found :: req :: _ = pt.typeArgs
11331133
def explanation = {
@@ -1138,19 +1138,19 @@ trait ContextErrors {
11381138
// involving Any, are further explained from foundReqMsg.
11391139
if (AnyRefClass.tpe <:< req) (
11401140
if (sym == AnyClass || sym == UnitClass) (
1141-
s"""|Note: ${sym.name} is not implicitly converted to AnyRef. You can safely
1142-
|pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so.""".stripMargin
1141+
sm"""|Note: ${sym.name} is not implicitly converted to AnyRef. You can safely
1142+
|pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so."""
11431143
)
11441144
else boxedClass get sym map (boxed =>
1145-
s"""|Note: an implicit exists from ${sym.fullName} => ${boxed.fullName}, but
1146-
|methods inherited from Object are rendered ambiguous. This is to avoid
1147-
|a blanket implicit which would convert any ${sym.fullName} to any AnyRef.
1148-
|You may wish to use a type ascription: `x: ${boxed.fullName}`.""".stripMargin
1145+
sm"""|Note: an implicit exists from ${sym.fullName} => ${boxed.fullName}, but
1146+
|methods inherited from Object are rendered ambiguous. This is to avoid
1147+
|a blanket implicit which would convert any ${sym.fullName} to any AnyRef.
1148+
|You may wish to use a type ascription: `x: ${boxed.fullName}`."""
11491149
) getOrElse ""
11501150
)
11511151
else
1152-
s"""|Note that implicit conversions are not applicable because they are ambiguous:
1153-
|${coreMsg}are possible conversion functions from $found to $req""".stripMargin
1152+
sm"""|Note that implicit conversions are not applicable because they are ambiguous:
1153+
|${coreMsg}are possible conversion functions from $found to $req"""
11541154
}
11551155
typeErrorMsg(found, req, infer.isPossiblyMissingArgs(found, req)) + (
11561156
if (explanation == "") "" else "\n" + explanation

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,17 +1298,17 @@ trait Implicits {
12981298
else {
12991299
if (ReflectRuntimeUniverse == NoSymbol) {
13001300
// todo. write a test for this
1301-
context.error(pos, s"""
1302-
|to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
1303-
|however typetag -> manifest conversion requires Scala reflection, which is not present on the classpath.
1304-
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin)
1301+
context.error(pos,
1302+
sm"""to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
1303+
|however typetag -> manifest conversion requires Scala reflection, which is not present on the classpath.
1304+
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""")
13051305
return SearchFailure
13061306
}
13071307
if (resolveClassTag(pos, tp, allowMaterialization = true) == EmptyTree) {
1308-
context.error(pos, s"""
1309-
|to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
1310-
|however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
1311-
|to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""".trim.stripMargin)
1308+
context.error(pos,
1309+
sm"""to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
1310+
|however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
1311+
|to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""")
13121312
return SearchFailure
13131313
}
13141314
val cm = typed(Ident(ReflectRuntimeCurrentMirror))

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,9 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
117117
}
118118

119119
def pickle(macroImplRef: Tree): Tree = {
120-
val macroImpl = macroImplRef.symbol
120+
val MacroImplReference(owner, macroImpl, targs) = macroImplRef
121121
val paramss = macroImpl.paramss
122122

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

141-
loop(macroImpl.owner.enclClass)
134+
loop(owner)
142135
}
143136

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

164157
// assign NoType to all freshly created AST nodes
165158
// otherwise pickler will choke on tree.tpe being null

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
11511151

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

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

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

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

36063606
def newCaseSym = newSynthCaseLabel("case") setInfo MethodType(Nil, restpe)

0 commit comments

Comments
 (0)