From d7cc24bf7857ffe9e8dd51e2ac7f6254013c03b6 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 1 Sep 2010 14:12:42 +0000 Subject: Merged revisions 22682,22685,22687,22693-22694 ... Merged revisions 22682,22685,22687,22693-22694 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r22682 | rytz | 2010-08-05 10:20:47 +0200 (Thu, 05 Aug 2010) | 1 line close #3685. review by moors. ........ r22685 | rytz | 2010-08-05 17:43:46 +0200 (Thu, 05 Aug 2010) | 22 lines close #3667. all companion objects are now serializable. note that you can reproduce the error without default arguments: scala> def ser(o: AnyRef) = new java.io.ObjectOutputStream(new java.io.ByteArrayOutputStream()).writeObject(o) ser: (o: AnyRef)Unit scala> @serializable class Outer { | case class Inner(x: Int) | } defined class Outer scala> val o = new Outer o: Outer = Outer@34469729 scala> ser(new o.Inner(1)) scala> o.Inner // initialize the Inner$module field of o res1: o.Inner.type = Inner scala> ser(new o.Inner(1)) java.io.NotSerializableException: Outer$Inner$ review by extempore. ........ r22687 | rytz | 2010-08-05 22:17:38 +0200 (Thu, 05 Aug 2010) | 1 line fixes names/defaults when using :_* for specifying repeated parameters. close #3697, no review. ........ r22693 | rytz | 2010-08-06 17:58:44 +0200 (Fri, 06 Aug 2010) | 1 line close #3403. BeanProperty cannot be used when renamed. no review. ........ r22694 | rytz | 2010-08-06 17:58:47 +0200 (Fri, 06 Aug 2010) | 1 line close #2799. companion objects of deprecated classes are also marked as deprecated. review by extempore. ........ --- test/files/neg/names-defaults-neg.check | 28 ++++++++++++++++- test/files/neg/names-defaults-neg.scala | 47 +++++++++++++++++++++++++++++ test/files/neg/t3403.check | 4 +++ test/files/neg/t3403.scala | 2 ++ test/files/pos/t2799.flags | 1 + test/files/pos/t2799.scala | 1 + test/files/run/names-defaults.check | 10 ++++++ test/files/run/names-defaults.scala | 17 +++++++++++ test/files/run/t3667.check | 3 ++ test/files/run/t3667.scala | 45 +++++++++++++++++++++++++++ test/files/scalap/packageObject/result.test | 1 + test/files/scalap/traitObject/result.test | 1 + 12 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t3403.check create mode 100644 test/files/neg/t3403.scala create mode 100644 test/files/pos/t2799.flags create mode 100644 test/files/pos/t2799.scala create mode 100644 test/files/run/t3667.check create mode 100644 test/files/run/t3667.scala (limited to 'test/files') diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index b2b00b7050..5d8f2e2e5d 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -120,4 +120,30 @@ names-defaults-neg.scala:124: error: parameter specified twice: a names-defaults-neg.scala:125: error: wrong number of parameters; expected = 2 val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -29 errors found +names-defaults-neg.scala:133: error: variable definition needs type because the name is used as named argument the definition. + def t3 { var x = t.f(x = 1) } + ^ +names-defaults-neg.scala:136: error: variable definition needs type because the name is used as named argument the definition. + object t6 { var x = t.f(x = 1) } + ^ +names-defaults-neg.scala:139: error: variable definition needs type because the name is used as named argument the definition. + class t9 { var x = t.f(x = 1) } + ^ +names-defaults-neg.scala:153: error: variable definition needs type because the name is used as named argument the definition. + def u3 { var x = u.f(x = 1) } + ^ +names-defaults-neg.scala:156: error: variable definition needs type because the name is used as named argument the definition. + def u6 { var x = u.f(x = "32") } + ^ +names-defaults-neg.scala:159: error: reference to x is ambiguous; it is both, a parameter +name of the method and the name of a variable currently in scope. + def u9 { var x: Int = u.f(x = 1) } + ^ +names-defaults-neg.scala:166: error: variable definition needs type because the name is used as named argument the definition. + class u15 { var x = u.f(x = 1) } + ^ +names-defaults-neg.scala:169: error: reference to x is ambiguous; it is both, a parameter +name of the method and the name of a variable currently in scope. + class u18 { var x: Int = u.f(x = 1) } + ^ +37 errors found diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala index 43883540a0..daa97a8638 100644 --- a/test/files/neg/names-defaults-neg.scala +++ b/test/files/neg/names-defaults-neg.scala @@ -124,3 +124,50 @@ object anfun { val taf3 = testAnnFun(b = _: String, a = get(8)) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) } + +object t3685 { + object t { def f(x: Int) = x } + + def t1 { def x = t.f(x = 1) } + def t2 { val x = t.f(x = 1) } + def t3 { var x = t.f(x = 1) } + object t4 { def x = t.f(x = 1) } + object t5 { val x = t.f(x = 1) } + object t6 { var x = t.f(x = 1) } + class t7 { def x = t.f(x = 1) } + class t8 { val x = t.f(x = 1) } + class t9 { var x = t.f(x = 1) } + + def t10 { def x: Int = t.f(x = 1) } + def t11 { val x: Int = t.f(x = 1) } + def t12 { var x: Int = t.f(x = 1) } + class t13 { def x: Int = t.f(x = 1) } + class t14 { val x: Int = t.f(x = 1) } + class t15 { var x: Int = t.f(x = 1) } + + + object u { def f[T](x: T) = 100 } + + def u1 { def x = u.f(x = 1) } + def u2 { val x = u.f(x = 1) } + def u3 { var x = u.f(x = 1) } + def u4 { def x = u.f(x = "23") } + def u5 { val x = u.f(x = "32") } + def u6 { var x = u.f(x = "32") } + def u7 { def x: Int = u.f(x = 1) } + def u8 { val x: Int = u.f(x = 1) } + def u9 { var x: Int = u.f(x = 1) } + def u10 { def x: Int = u.f(x = "32") } + def u11 { val x: Int = u.f(x = "32") } + def u12 { var x: Int = u.f(x = "32") } + + class u13 { def x = u.f(x = 1) } + class u14 { val x = u.f(x = 1) } + class u15 { var x = u.f(x = 1) } + class u16 { def x: Int = u.f(x = 1) } + class u17 { val x: Int = u.f(x = 1) } + class u18 { var x: Int = u.f(x = 1) } + class u19 { def x: Int = u.f(x = "32") } + class u20 { val x: Int = u.f(x = "32") } + class u21 { var x: Int = u.f(x = "32") } +} diff --git a/test/files/neg/t3403.check b/test/files/neg/t3403.check new file mode 100644 index 0000000000..e52d140e6a --- /dev/null +++ b/test/files/neg/t3403.check @@ -0,0 +1,4 @@ +t3403.scala:2: error: implementation limitation: the BeanProperty annotation cannot be used in a type alias or renamed import +class Foo { @bp var bar: Int = 1 } + ^ +one error found diff --git a/test/files/neg/t3403.scala b/test/files/neg/t3403.scala new file mode 100644 index 0000000000..8be6ab2a31 --- /dev/null +++ b/test/files/neg/t3403.scala @@ -0,0 +1,2 @@ +import scala.reflect.{BeanProperty => bp} +class Foo { @bp var bar: Int = 1 } diff --git a/test/files/pos/t2799.flags b/test/files/pos/t2799.flags new file mode 100644 index 0000000000..d1b831ea87 --- /dev/null +++ b/test/files/pos/t2799.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings \ No newline at end of file diff --git a/test/files/pos/t2799.scala b/test/files/pos/t2799.scala new file mode 100644 index 0000000000..fe93c0e301 --- /dev/null +++ b/test/files/pos/t2799.scala @@ -0,0 +1 @@ +@deprecated("hi mom") case class Bob () diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index b4effa26d2..d31e98be32 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -106,3 +106,13 @@ blublu1 my text List(1, 2) 3 +3 +3 +3 +3 +3 +3 +3 +3 +3 +3 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 8ddfcd950d..ee0862558a 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -351,6 +351,23 @@ object Test extends Application { (new DBLAH()) + // #3697 + object t3697 { + def a(x: Int*)(s: Int = 3) = s + def b(a: Int, b: Int, c: Int*) = a + b + } + println(t3697.a(Seq(3): _*)()) + println(t3697.a(3)()) + println(t3697.a()()) + println(t3697.a(2,3,1)()) + println(t3697.b(a = 1, b = 2)) + println(t3697.b(a = 1, b = 2, 3)) + println(t3697.b(b = 1, a = 2, c = 3)) + println(t3697.b(a = 1, b = 2, 3, 4)) + println(t3697.b(a = 1, b = 2, Seq(3, 4): _*)) + println(t3697.b(b = 1, a = 2, c = Seq(3, 4): _*)) + + // 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)) diff --git a/test/files/run/t3667.check b/test/files/run/t3667.check new file mode 100644 index 0000000000..01e79c32a8 --- /dev/null +++ b/test/files/run/t3667.check @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/test/files/run/t3667.scala b/test/files/run/t3667.scala new file mode 100644 index 0000000000..804432c516 --- /dev/null +++ b/test/files/run/t3667.scala @@ -0,0 +1,45 @@ +object Test { + def main(args: Array[String]) { + val o1 = new Outer1 + val o2 = new Outer2 + val o3 = new Outer3 + + println(1) + ser(new o1.Inner(1)) + o1.Inner // make sure the Inner$module field of the Outer1 instance is initialized! + ser(new o1.Inner(1)) + + println(2) + ser(new o2.Inner(1)) + o2.Inner + ser(new o2.Inner(1)) + + println(3) + ser(new o3.Inner(1)) + o3.Inner + ser(new o3.Inner(1)) + } + + def ser(o: AnyRef) { + val oos = new java.io.ObjectOutputStream(new java.io.ByteArrayOutputStream()) + oos.writeObject(o) + oos.close() + } + +} + +@serializable +class Outer1 { + @serializable + class Inner(x: Int = 1) +} + +@serializable +class Outer2 { + case class Inner(x: Int = 1) +} + +@serializable +class Outer3 { + case class Inner(x: Int) +} diff --git a/test/files/scalap/packageObject/result.test b/test/files/scalap/packageObject/result.test index 6a8d6ae1d5..324992aae1 100644 --- a/test/files/scalap/packageObject/result.test +++ b/test/files/scalap/packageObject/result.test @@ -2,4 +2,5 @@ package object PackageObject extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } type A = scala.Predef.String def foo(i : scala.Int) : scala.Int = { /* compiled code */ } + protected def readResolve() : java.lang.Object = { /* compiled code */ } } diff --git a/test/files/scalap/traitObject/result.test b/test/files/scalap/traitObject/result.test index 0d7de1535d..8978873fc7 100644 --- a/test/files/scalap/traitObject/result.test +++ b/test/files/scalap/traitObject/result.test @@ -5,4 +5,5 @@ trait TraitObject extends java.lang.Object with scala.ScalaObject { object TraitObject extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } def bar : scala.Int = { /* compiled code */ } + protected def readResolve() : java.lang.Object = { /* compiled code */ } } -- cgit v1.2.3