diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-07-09 09:51:06 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-07-09 09:51:06 +0000 |
commit | c66898e5be37d88efd75af76f5a078820ae6c4e0 (patch) | |
tree | 448cfcfe93116b9ff2e2620234bb6813276d9b00 | |
parent | ba975223e8854db866a55f7207ad889327c4100d (diff) | |
download | scala-c66898e5be37d88efd75af76f5a078820ae6c4e0.tar.gz scala-c66898e5be37d88efd75af76f5a078820ae6c4e0.tar.bz2 scala-c66898e5be37d88efd75af76f5a078820ae6c4e0.zip |
close #3648.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala | 2 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 5 | ||||
-rw-r--r-- | test/files/run/t3648.check | 1 | ||||
-rw-r--r-- | test/files/run/t3648.scala | 10 |
5 files changed, 20 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 756863f8f9..ca188099c7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1035,9 +1035,11 @@ trait Namers { self: Analyzer => })) val defRhs = copyUntyped(vparam.rhs) + val staticFlag = if (isConstr) STATIC else 0 + val defaultTree = atPos(vparam.pos.focus) { DefDef( - Modifiers(meth.flags & (PRIVATE | PROTECTED | FINAL)) | SYNTHETIC | DEFAULTPARAM | oflag, + Modifiers(meth.flags & (PRIVATE | PROTECTED | FINAL)) | SYNTHETIC | DEFAULTPARAM | oflag | staticFlag, name, deftParams, defvParamss, defTpt, defRhs) } if (!isConstr) diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index f1d0537f46..91fe113019 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -341,7 +341,7 @@ trait NamesDefaults { self: Analyzer => * * Example: given * def foo(x: Int = 2, y: String = "def") - * foo(1) + * foo(y = "lt") * the argument list (y = "lt") is transformed to (y = "lt", x = foo$default$1()) */ def addDefaults(givenArgs: List[Tree], qual: Option[Tree], targs: List[Tree], diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index f197d2ff11..8ddfcd950d 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -345,6 +345,11 @@ object Test extends Application { (new t3338.Test).a + // subclassing and defaults in both class constructors + class CBLAH(val x: Int = 1) + class DBLAH(val y: String = "2") extends CBLAH() + (new DBLAH()) + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) diff --git a/test/files/run/t3648.check b/test/files/run/t3648.check new file mode 100644 index 0000000000..5f7559f647 --- /dev/null +++ b/test/files/run/t3648.check @@ -0,0 +1 @@ +kult diff --git a/test/files/run/t3648.scala b/test/files/run/t3648.scala new file mode 100644 index 0000000000..91927d6d6d --- /dev/null +++ b/test/files/run/t3648.scala @@ -0,0 +1,10 @@ +object Test { + class C(val s: String = "") + object C extends C() { + override def toString() = "kult" + } + + def main(args: Array[String]) { + println(C) + } +} |