diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-10-12 16:06:40 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-10-12 16:08:18 -0700 |
commit | b2b459115a7a0e1767bece648c1fdaf84533dce2 (patch) | |
tree | 0363dfc16fce3b107949790ce843666af56f3f95 /test | |
parent | 1e81a09a896a0d7497687b5df1b8220172eaec92 (diff) | |
download | scala-b2b459115a7a0e1767bece648c1fdaf84533dce2.tar.gz scala-b2b459115a7a0e1767bece648c1fdaf84533dce2.tar.bz2 scala-b2b459115a7a0e1767bece648c1fdaf84533dce2.zip |
Detect clash of mixedin val and existing member.
Before, we looked only at the result type, which was silly.
This was originally motivated by a hack to get to the error
about conflicting paramaccessors. The error detection for that
can now be formulated more directly.
Fixes scala/scala-dev#244
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t1960.check | 11 | ||||
-rw-r--r-- | test/files/neg/t1960.scala | 7 | ||||
-rw-r--r-- | test/files/pos/issue244.scala | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/test/files/neg/t1960.check b/test/files/neg/t1960.check index de0907b4a9..bb6d3d3548 100644 --- a/test/files/neg/t1960.check +++ b/test/files/neg/t1960.check @@ -1,4 +1,7 @@ -t1960.scala:5: error: parameter 'p' requires field but conflicts with variable p in trait TBase -class Aclass (p: Int) extends TBase { def g() { f(p) } } - ^ -one error found +t1960.scala:2: error: parameter 'vr' requires field but conflicts with variable vr in trait T +class C(vr: Int, vl: Int) extends T { def ref = vr + vl } + ^ +t1960.scala:2: error: parameter 'vl' requires field but conflicts with value vl in trait T +class C(vr: Int, vl: Int) extends T { def ref = vr + vl } + ^ +two errors found diff --git a/test/files/neg/t1960.scala b/test/files/neg/t1960.scala index 5311940b5a..f4fdb341c6 100644 --- a/test/files/neg/t1960.scala +++ b/test/files/neg/t1960.scala @@ -1,5 +1,2 @@ -object ClassFormatErrorExample extends App { new Aclass(1) } - -trait TBase { var p:Int = 0; def f(p1: Int) {} } - -class Aclass (p: Int) extends TBase { def g() { f(p) } } +trait T { var vr: Int = 0 ; val vl: Int = 0 } +class C(vr: Int, vl: Int) extends T { def ref = vr + vl } diff --git a/test/files/pos/issue244.scala b/test/files/pos/issue244.scala new file mode 100644 index 0000000000..f9189c9313 --- /dev/null +++ b/test/files/pos/issue244.scala @@ -0,0 +1,2 @@ +trait T { lazy val overloaded: String = "a" } +class C extends T { def overloaded(a: String): String = "b" } |