summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala6
-rw-r--r--test/files/neg/t8157.check4
-rw-r--r--test/files/neg/t8157.scala4
3 files changed, 9 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 95f2620061..4ba8d56da0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -132,11 +132,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
defaultMethodNames.toList.distinct foreach { name =>
val methods = clazz.info.findMember(name, 0L, requiredFlags = METHOD, stableOnly = false).alternatives
- def hasDefaultParam(tpe: Type): Boolean = tpe match {
- case MethodType(params, restpe) => (params exists (_.hasDefault)) || hasDefaultParam(restpe)
- case _ => false
- }
- val haveDefaults = methods filter (sym => hasDefaultParam(sym.info) && !nme.isProtectedAccessorName(sym.name))
+ val haveDefaults = methods filter (sym => mexists(sym.info.paramss)(_.hasDefault) && !nme.isProtectedAccessorName(sym.name))
if (haveDefaults.lengthCompare(1) > 0) {
val owners = haveDefaults map (_.owner)
diff --git a/test/files/neg/t8157.check b/test/files/neg/t8157.check
new file mode 100644
index 0000000000..9a21a49a07
--- /dev/null
+++ b/test/files/neg/t8157.check
@@ -0,0 +1,4 @@
+t8157.scala:1: error: in object Test, multiple overloaded alternatives of method foo define default arguments.
+object Test {
+ ^
+one error found
diff --git a/test/files/neg/t8157.scala b/test/files/neg/t8157.scala
new file mode 100644
index 0000000000..462d4fa3f1
--- /dev/null
+++ b/test/files/neg/t8157.scala
@@ -0,0 +1,4 @@
+object Test {
+ def foo(printer: Any, question: => String, show: Boolean = false)(op: => Any): Any = ???
+ def foo[T](question: => String, show: Boolean)(op: => Any = ()): Any = ???
+}