diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-04-01 08:39:11 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-04-01 08:39:11 +0000 |
commit | 7b43c30aa1746cb37ee65f2871e4e92e82896a10 (patch) | |
tree | bd12553e5f7d84e8910c678b401afb68c1cef98e | |
parent | f32f87226959f9def3e3e14725898bd3c39840f8 (diff) | |
download | scala-7b43c30aa1746cb37ee65f2871e4e92e82896a10.tar.gz scala-7b43c30aa1746cb37ee65f2871e4e92e82896a10.tar.bz2 scala-7b43c30aa1746cb37ee65f2871e4e92e82896a10.zip |
close #3178. review by community
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala | 3 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 8 |
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)) |