summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl2
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-windows.tmpl9
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala4
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala6
-rw-r--r--src/reflect/scala/reflect/api/Internals.scala8
-rw-r--r--src/reflect/scala/reflect/internal/ReificationSupport.scala19
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala1
7 files changed, 41 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 194d92367b..d6dc167dd8 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -156,7 +156,7 @@ while [[ $# -gt 0 ]]; do
java_args=("${java_args[@@]}" "$1")
scala_args=("${scala_args[@@]}" "$1")
# respect user-supplied -Dscala.usejavacp
- case "$1" in -Dscala.usejavacp) OVERRIDE_USEJAVACP="" esac
+ case "$1" in -Dscala.usejavacp) OVERRIDE_USEJAVACP="";; esac
shift
;;
-J*)
diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
index 8441f3af23..9a2deb4da6 100644
--- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
@@ -25,6 +25,10 @@ shift
:notoolcp
+rem SI-8358, SI-8368 -- the default should really be false,
+rem but I don't want to flip the default during 2.11's RC cycle
+set _OVERRIDE_USEJAVACP="-Dscala.usejavacp=true"
+
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
set _JAVA_PARAMS=
@@ -45,6 +49,9 @@ if "%_TEST_PARAM:~0,2%"=="-J" (
)
if "%_TEST_PARAM:~0,2%"=="-D" (
+ if "%_TEST_PARAM%"=="-Dscala.usejavacp" (
+ set _OVERRIDE_USEJAVACP=
+ )
rem test if this was double-quoted property "-Dprop=42"
for /F "delims== tokens=1-2" %%G in ("%_TEST_PARAM%") DO (
if not "%%G" == "%_TEST_PARAM%" (
@@ -126,7 +133,7 @@ if "%_TOOL_CLASSPATH%"=="" (
if not "%_LINE_TOOLCP%"=="" call :add_cpath "%_LINE_TOOLCP%"
-set _PROPS=-Dscala.home="!_SCALA_HOME!" -Denv.emacs="%EMACS%" -Dscala.usejavacp=true @properties@
+set _PROPS=-Dscala.home="!_SCALA_HOME!" -Denv.emacs="%EMACS%" %_OVERRIDE_USEJAVACP% @properties@
rem echo "%_JAVACMD%" %_JAVA_OPTS% %_PROPS% -cp "%_TOOL_CLASSPATH%" @class@ @toolflags@ %*
"%_JAVACMD%" %_JAVA_OPTS% %_PROPS% -cp "%_TOOL_CLASSPATH%" @class@ @toolflags@ %*
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 8a7d30235f..d77c6b54a9 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -221,7 +221,9 @@ abstract class UnCurry extends InfoTransform
def mkMethod(owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags): DefDef =
gen.mkMethodFromFunction(localTyper)(fun, owner, name, additionalFlags)
- if (inlineFunctionExpansion) {
+ val canUseDelamdafyMethod = (inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation
+
+ if (inlineFunctionExpansion || !canUseDelamdafyMethod) {
val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation
anonClass setInfo ClassInfoType(parents, newScope, anonClass)
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index 850030e9ba..1b8b0686e8 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -199,6 +199,10 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticEmptyTypeTree)
case SyntacticImport(expr, selectors) =>
reifyBuildCall(nme.SyntacticImport, expr, selectors)
+ case SyntacticPartialFunction(cases) =>
+ reifyBuildCall(nme.SyntacticPartialFunction, cases)
+ case SyntacticMatch(scrutinee, cases) =>
+ reifyBuildCall(nme.SyntacticMatch, scrutinee, cases)
case Q(tree) if fillListHole.isDefinedAt(tree) =>
mirrorBuildCall(nme.SyntacticBlock, fillListHole(tree))
case Q(other) =>
@@ -211,8 +215,6 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticBlock, Nil)
case Try(block, catches, finalizer) =>
reifyBuildCall(nme.SyntacticTry, block, catches, finalizer)
- case Match(selector, cases) =>
- reifyBuildCall(nme.SyntacticMatch, selector, cases)
case CaseDef(pat, guard, body) if fillListHole.isDefinedAt(body) =>
mirrorCall(nme.CaseDef, reify(pat), reify(guard), mirrorBuildCall(nme.SyntacticBlock, fillListHole(body)))
// parser emits trees with scala package symbol to ensure
diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala
index d2e742726d..9faba7efd7 100644
--- a/src/reflect/scala/reflect/api/Internals.scala
+++ b/src/reflect/scala/reflect/api/Internals.scala
@@ -762,9 +762,15 @@ trait Internals { self: Universe =>
def unapply(lst: List[List[Tree]]): Option[List[List[T]]]
}
+ val SyntacticPartialFunction: SyntacticPartialFunctionExtractor
+ trait SyntacticPartialFunctionExtractor {
+ def apply(cases: List[Tree]): Match
+ def unapply(tree: Match): Option[List[CaseDef]]
+ }
+
val SyntacticMatch: SyntacticMatchExtractor
trait SyntacticMatchExtractor {
- def apply(selector: Tree, cases: List[Tree]): Match
+ def apply(scrutinee: Tree, cases: List[Tree]): Match
def unapply(tree: Match): Option[(Tree, List[CaseDef])]
}
diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala
index dfe1811ff0..9a130337b4 100644
--- a/src/reflect/scala/reflect/internal/ReificationSupport.scala
+++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala
@@ -850,9 +850,24 @@ trait ReificationSupport { self: SymbolTable =>
case tree => throw new IllegalArgumentException("$tree is not valid representation of pattern match case")
}
+ object SyntacticPartialFunction extends SyntacticPartialFunctionExtractor {
+ def apply(cases: List[Tree]): Match = Match(EmptyTree, mkCases(cases))
+ def unapply(tree: Match): Option[List[CaseDef]] = tree match {
+ case Match(EmptyTree, cases) => Some(cases)
+ case _ => None
+ }
+ }
+
object SyntacticMatch extends SyntacticMatchExtractor {
- def apply(selector: Tree, cases: List[Tree]) = Match(selector, mkCases(cases))
- def unapply(tree: Match): Option[(Tree, List[CaseDef])] = Match.unapply(tree)
+ def apply(scrutinee: Tree, cases: List[Tree]) = {
+ require(scrutinee.nonEmpty, "match's scrutinee may not be empty")
+ Match(scrutinee, mkCases(cases))
+ }
+
+ def unapply(tree: Match): Option[(Tree, List[CaseDef])] = tree match {
+ case Match(scrutinee, cases) if scrutinee.nonEmpty => Some((scrutinee, cases))
+ case _ => None
+ }
}
object SyntacticTry extends SyntacticTryExtractor {
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index 640e0606c7..10959ff41f 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -630,6 +630,7 @@ trait StdNames {
val SyntacticNew: NameType = "SyntacticNew"
val SyntacticObjectDef: NameType = "SyntacticObjectDef"
val SyntacticPackageObjectDef: NameType = "SyntacticPackageObjectDef"
+ val SyntacticPartialFunction: NameType = "SyntacticPartialFunction"
val SyntacticPatDef: NameType = "SyntacticPatDef"
val SyntacticSelectType: NameType = "SyntacticSelectType"
val SyntacticSelectTerm: NameType = "SyntacticSelectTerm"