summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-05-08 23:21:29 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-05-09 11:47:19 +0200
commita13231498f1c6661706cbf4baf9f5c3374bc85cd (patch)
treec69cf3fb66f6e0ed2309f1d9ec296c5d5a8ad56a /src/compiler
parent972244d7e3de18c833b179277912c737301b5437 (diff)
parentb5392a0f034afe23aff183d8673464c848f76241 (diff)
downloadscala-a13231498f1c6661706cbf4baf9f5c3374bc85cd.tar.gz
scala-a13231498f1c6661706cbf4baf9f5c3374bc85cd.tar.bz2
scala-a13231498f1c6661706cbf4baf9f5c3374bc85cd.zip
Merge commit 'b5392a0' into merge/master-to-2.11.x
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala30
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala14
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala11
5 files changed, 40 insertions, 21 deletions
diff --git a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala
index 1413065a27..a13a778b2f 100644
--- a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala
+++ b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala
@@ -53,7 +53,7 @@ abstract class DefaultMacroCompiler extends Resolvers
(EmptyTree, TermName(""), Nil)
}
val bundleImplRef = MacroImplRefCompiler(
- atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(New(maybeBundleRef, List(List(Ident(Predef_???)))), methName), targs)),
+ atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(New(maybeBundleRef, List(List(Literal(Constant(null))))), methName), targs)),
isImplBundle = true
)
val vanillaResult = tryCompile(vanillaImplRef)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 9e631febee..ffc45b21ea 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -654,9 +654,10 @@ self =>
def isIdentExcept(except: Name) = isIdent && in.name != except
def isIdentOf(name: Name) = isIdent && in.name == name
- def isUnaryOp = isIdent && raw.isUnary(in.name)
- def isRawStar = isIdent && in.name == raw.STAR
- def isRawBar = isIdent && in.name == raw.BAR
+ def isUnaryOp = isIdent && raw.isUnary(in.name)
+ def isRawStar = isRawIdent && in.name == raw.STAR
+ def isRawBar = isRawIdent && in.name == raw.BAR
+ def isRawIdent = in.token == IDENTIFIER
def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
def isMacro = in.token == IDENTIFIER && in.name == nme.MACROkw
@@ -1001,19 +1002,30 @@ self =>
}
def infixTypeRest(t: Tree, mode: InfixMode.Value): Tree = {
- if (isIdent && in.name != nme.STAR) {
- val opOffset = in.offset
+ // Detect postfix star for repeated args.
+ // Only RPAREN can follow, but accept COMMA and EQUALS for error's sake.
+ // Take RBRACE as a paren typo.
+ def checkRepeatedParam = if (isRawStar) {
+ lookingAhead (in.token match {
+ case RPAREN | COMMA | EQUALS | RBRACE => t
+ case _ => EmptyTree
+ })
+ } else EmptyTree
+ def asInfix = {
+ val opOffset = in.offset
val leftAssoc = treeInfo.isLeftAssoc(in.name)
- if (mode != InfixMode.FirstOp) checkAssoc(opOffset, in.name, leftAssoc = mode == InfixMode.LeftOp)
- val op = identForType()
- val tycon = atPos(opOffset) { Ident(op) }
+ if (mode != InfixMode.FirstOp)
+ checkAssoc(opOffset, in.name, leftAssoc = mode == InfixMode.LeftOp)
+ val tycon = atPos(opOffset) { Ident(identForType()) }
newLineOptWhenFollowing(isTypeIntroToken)
def mkOp(t1: Tree) = atPos(t.pos.start, opOffset) { AppliedTypeTree(tycon, List(t, t1)) }
if (leftAssoc)
infixTypeRest(mkOp(compoundType()), InfixMode.LeftOp)
else
mkOp(infixType(InfixMode.RightOp))
- } else t
+ }
+ if (isIdent) checkRepeatedParam orElse asInfix
+ else t
}
/** {{{
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index 359e5d6c29..f800dbf9cd 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -239,6 +239,13 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
}
/*
+ * must-single-thread
+ */
+ def serialVUID(csym: Symbol): Option[Long] = csym getAnnotation definitions.SerialVersionUIDAttr collect {
+ case AnnotationInfo(_, _, (_, LiteralAnnotArg(const)) :: Nil) => const.longValue
+ }
+
+ /*
* Populates the InnerClasses JVM attribute with `refedInnerClasses`.
* In addition to inner classes mentioned somewhere in `jclass` (where `jclass` is a class file being emitted)
* `refedInnerClasses` should contain those inner classes defined as direct member classes of `jclass`
@@ -881,13 +888,6 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
val MIN_SWITCH_DENSITY = 0.7
/*
- * must-single-thread
- */
- def serialVUID(csym: Symbol): Option[Long] = csym getAnnotation definitions.SerialVersionUIDAttr collect {
- case AnnotationInfo(_, Literal(const) :: _, _) => const.longValue
- }
-
- /*
* Add public static final field serialVersionUID with value `id`
*
* can-multi-thread
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index a389816caf..b7f9b30e19 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -1142,9 +1142,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def isParcelableClass = isAndroidParcelableClass(clasz.symbol)
- def serialVUID: Option[Long] = clasz.symbol getAnnotation SerialVersionUIDAttr collect {
- case AnnotationInfo(_, Literal(const) :: _, _) => const.longValue
- }
+ def serialVUID: Option[Long] = genBCode.serialVUID(clasz.symbol)
private def getSuperInterfaces(c: IClass): Array[String] = {
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index b166bf988d..4540017b62 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -132,7 +132,16 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
defaultMethodNames.toList.distinct foreach { name =>
val methods = clazz.info.findMember(name, 0L, requiredFlags = METHOD, stableOnly = false).alternatives
- val haveDefaults = methods filter (sym => mexists(sym.info.paramss)(_.hasDefault) && !nme.isProtectedAccessorName(sym.name))
+ def hasDefaultParam(tpe: Type): Boolean = tpe match {
+ case MethodType(params, restpe) => (params exists (_.hasDefault)) || hasDefaultParam(restpe)
+ case _ => false
+ }
+ val haveDefaults = methods filter (
+ if (settings.isScala211)
+ (sym => mexists(sym.info.paramss)(_.hasDefault) && !nme.isProtectedAccessorName(sym.name))
+ else
+ (sym => hasDefaultParam(sym.info) && !nme.isProtectedAccessorName(sym.name))
+ )
if (haveDefaults.lengthCompare(1) > 0) {
val owners = haveDefaults map (_.owner)