summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2011-07-25 23:50:55 +0000
committerPhilipp Haller <hallerp@gmail.com>2011-07-25 23:50:55 +0000
commit460f57d5d30cd42e35b55337f9a146070243b20e (patch)
treeed5141d7a397f6b84f961de5755036400b2f3e58
parentac2ecfb3af887f8d9ac57af459517fec9b615cd8 (diff)
downloadscala-460f57d5d30cd42e35b55337f9a146070243b20e.tar.gz
scala-460f57d5d30cd42e35b55337f9a146070243b20e.tar.bz2
scala-460f57d5d30cd42e35b55337f9a146070243b20e.zip
Enable implicit parameters in the presence of v...
Enable implicit parameters in the presence of view- or context bounds. Fix SI-4839. Review by moors.
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala12
2 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index f0d6f4c5bf..3ea091c394 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -2039,8 +2039,6 @@ self =>
return Nil
if (in.token == IMPLICIT) {
- if (contextBounds.nonEmpty)
- syntaxError("cannot have both implicit parameters and context bounds `: ...' or view bounds `<% ...' on type parameters", false)
in.nextToken()
implicitmod = Flags.IMPLICIT
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 79aa69efe7..a154009ce0 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -601,7 +601,17 @@ abstract class TreeBuilder {
else {
val mods = Modifiers(if (owner.isTypeName) PARAMACCESSOR | LOCAL | PRIVATE else PARAM)
def makeEvidenceParam(tpt: Tree) = ValDef(mods | IMPLICIT, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree)
- vparamss ::: List(contextBounds map makeEvidenceParam)
+ val evidenceParams = contextBounds map makeEvidenceParam
+ if (vparamss.isEmpty)
+ List(evidenceParams)
+ else {
+ val lastParams = vparamss(vparamss.size - 1)
+ if (!lastParams.isEmpty && (lastParams(0).mods hasFlag IMPLICIT))
+ // append lastParams to evidenceParams
+ (vparamss take (vparamss.size - 1)) ::: List(evidenceParams ::: lastParams)
+ else
+ vparamss ::: List(evidenceParams)
+ }
}
}