diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-03 09:30:16 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-03 10:53:02 -0700 |
commit | ca74659bb06611b87474ffe2fd17b131cd3d34b0 (patch) | |
tree | be3664d400a0b534c1936555b660264ca4c9931d /src/compiler | |
parent | 8068e1208466ab17af40c2670230ba5ac9704e0c (diff) | |
download | scala-ca74659bb06611b87474ffe2fd17b131cd3d34b0.tar.gz scala-ca74659bb06611b87474ffe2fd17b131cd3d34b0.tar.bz2 scala-ca74659bb06611b87474ffe2fd17b131cd3d34b0.zip |
Hardening implicit classes.
Closes SI-5728.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index e4296774a1..6620ef7347 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -608,11 +608,12 @@ trait Namers extends MethodSynthesis { def enterClassDef(tree: ClassDef) { val ClassDef(mods, name, tparams, impl) = tree + val primaryConstructorArity = treeInfo.firstConstructorArgs(impl.body).size tree.symbol = enterClassSymbol(tree) tree.symbol setInfo completerOf(tree) if (mods.isCase) { - if (treeInfo.firstConstructorArgs(impl.body).size > MaxFunctionArity) + if (primaryConstructorArity > MaxFunctionArity) MaxParametersCaseClassError(tree) val m = ensureCompanionObject(tree, caseModuleDef) @@ -636,8 +637,11 @@ trait Namers extends MethodSynthesis { // Suggested location only. if (mods.isImplicit) { - log("enter implicit wrapper "+tree+", owner = "+owner) - enterImplicitWrapper(tree) + if (primaryConstructorArity == 1) { + log("enter implicit wrapper "+tree+", owner = "+owner) + enterImplicitWrapper(tree) + } + else context.unit.error(tree.pos, "implicit classes must accept exactly one primary constructor parameter") } } |