diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala | 12 |
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) + } } } |