summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala3
-rw-r--r--test/files/run/names-defaults.scala8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 3978ea263b..6288c06a67 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -440,6 +440,8 @@ trait NamesDefaults { self: Analyzer =>
case _ => super.apply(tp)
}
}
+ val reportAmbiguousErrors = typer.context.reportAmbiguousErrors
+ typer.context.reportAmbiguousErrors = false
val res = typer.silent(_.typed(arg, subst(paramtpe))) match {
case _: TypeError =>
// if the named argument is on the original parameter
@@ -457,6 +459,7 @@ trait NamesDefaults { self: Analyzer =>
errorTree(arg, "reference to "+ name +" is ambiguous; it is both, a parameter\n"+
"name of the method and the name of a variable currently in scope.")
}
+ typer.context.reportAmbiguousErrors = reportAmbiguousErrors
//@M note that we don't get here when an ambiguity was detected (during the computation of res),
// as errorTree throws an exception
typer.context.undetparams = udp
diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala
index 54a09c14f9..8557047875 100644
--- a/test/files/run/names-defaults.scala
+++ b/test/files/run/names-defaults.scala
@@ -296,6 +296,14 @@ object Test extends Application {
class C extends A
}
+ object t3178 {
+ def foo(x: String) = x
+ def foo(x: Int) = x
+ def bar(foo: Int) = foo
+ bar(foo = 1)
+ }
+
+
// DEFINITIONS
def test1(a: Int, b: String) = println(a +": "+ b)
def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v))