summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala10
-rw-r--r--test/files/neg/t5728.check4
-rw-r--r--test/files/neg/t5728.scala7
3 files changed, 18 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")
}
}
diff --git a/test/files/neg/t5728.check b/test/files/neg/t5728.check
new file mode 100644
index 0000000000..14f9c42ae0
--- /dev/null
+++ b/test/files/neg/t5728.check
@@ -0,0 +1,4 @@
+t5728.scala:3: error: implicit classes must accept exactly one primary constructor parameter
+ implicit class Foo
+ ^
+one error found
diff --git a/test/files/neg/t5728.scala b/test/files/neg/t5728.scala
new file mode 100644
index 0000000000..99337d06d4
--- /dev/null
+++ b/test/files/neg/t5728.scala
@@ -0,0 +1,7 @@
+object Test {
+
+ implicit class Foo
+
+ implicit def Foo = new Foo
+
+}