diff options
author | François Garillot <francois@garillot.net> | 2014-04-25 15:52:50 +0200 |
---|---|---|
committer | François Garillot <francois@garillot.net> | 2014-04-25 15:52:50 +0200 |
commit | 8317266f34dce29078dc7c4447605701ba82e82a (patch) | |
tree | a12e512a8445ec6bf379359dcdfebb670483cef1 | |
parent | 57b6b90af6218e96cb554e9563199d7889c0004a (diff) | |
download | scala-8317266f34dce29078dc7c4447605701ba82e82a.tar.gz scala-8317266f34dce29078dc7c4447605701ba82e82a.tar.bz2 scala-8317266f34dce29078dc7c4447605701ba82e82a.zip |
SI-8537 Puts SI-8157 fix under Xsource
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t8157-2.10.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8157-2.10.scala | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index b166bf988d..4540017b62 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -132,7 +132,16 @@ 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 - val haveDefaults = methods filter (sym => mexists(sym.info.paramss)(_.hasDefault) && !nme.isProtectedAccessorName(sym.name)) + def hasDefaultParam(tpe: Type): Boolean = tpe match { + case MethodType(params, restpe) => (params exists (_.hasDefault)) || hasDefaultParam(restpe) + case _ => false + } + val haveDefaults = methods filter ( + if (settings.isScala211) + (sym => mexists(sym.info.paramss)(_.hasDefault) && !nme.isProtectedAccessorName(sym.name)) + else + (sym => hasDefaultParam(sym.info) && !nme.isProtectedAccessorName(sym.name)) + ) if (haveDefaults.lengthCompare(1) > 0) { val owners = haveDefaults map (_.owner) diff --git a/test/files/pos/t8157-2.10.flags b/test/files/pos/t8157-2.10.flags new file mode 100644 index 0000000000..94c8056747 --- /dev/null +++ b/test/files/pos/t8157-2.10.flags @@ -0,0 +1 @@ +-Xsource:2.10 diff --git a/test/files/pos/t8157-2.10.scala b/test/files/pos/t8157-2.10.scala new file mode 100644 index 0000000000..597585a96d --- /dev/null +++ b/test/files/pos/t8157-2.10.scala @@ -0,0 +1,5 @@ +object Test { // PolyTYped function default arg unicity check, + // fails in 2.11, authorized under -Xsource:2.10 + def foo(printer: Any, question: => String, show: Boolean = false)(op: => Any): Any = ??? + def foo[T](question: => String, show: Boolean)(op: => Any = ()): Any = ??? +} |