Permalink
Browse files

Hardening implicit classes.

Closes SI-5728.
  • Loading branch information...
paulp committed May 3, 2012
1 parent 8068e12 commit ca74659bb06611b87474ffe2fd17b131cd3d34b0
@@ -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")
}
}
@@ -0,0 +1,4 @@
t5728.scala:3: error: implicit classes must accept exactly one primary constructor parameter
implicit class Foo
^
one error found
@@ -0,0 +1,7 @@
object Test {
implicit class Foo
implicit def Foo = new Foo
}

0 comments on commit ca74659

Please sign in to comment.