diff options
author | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2014-01-31 19:43:08 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-10-01 21:01:11 +1000 |
commit | 0d8ca1f5fe335565f861ce2c58f7f684f15a4064 (patch) | |
tree | d36ec77b840f24e164dc6e5436431318bae7d1d4 /test/files/neg | |
parent | 7b591540fd46f4e8d6e4f589efe7abe468d69ca4 (diff) | |
download | scala-0d8ca1f5fe335565f861ce2c58f7f684f15a4064.tar.gz scala-0d8ca1f5fe335565f861ce2c58f7f684f15a4064.tar.bz2 scala-0d8ca1f5fe335565f861ce2c58f7f684f15a4064.zip |
SI-8217 allow abstract type members in objects
Previously, abstract type members were allowed in objects only when inherited,
but not when declared directly. This inconsistency was not intended. In dotty,
abstract type members are allowed in values and represent existentials; so upon
discussion, it was decided to fix things to conform to dotty and allow such type
members. Adriaan also asked to keep rejecting abstract type members in methods
even though they would conceivably make sense.
Discussions happened on #3407, scala/scala-dist#127.
This code is improved from #3442, keeps closer to the current logic, and passes tests.
Existing tests that have been converted to `pos` tests show that
this works, and a new test has been added to show that local
aliases (ie term-owned) without a RHS are still rejected.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/t3240.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3240.scala | 8 | ||||
-rw-r--r-- | test/files/neg/t8217-local-alias-requires-rhs.check | 10 | ||||
-rw-r--r-- | test/files/neg/t8217-local-alias-requires-rhs.scala | 15 | ||||
-rw-r--r-- | test/files/neg/t845.check | 4 | ||||
-rw-r--r-- | test/files/neg/t845.scala | 16 |
6 files changed, 25 insertions, 32 deletions
diff --git a/test/files/neg/t3240.check b/test/files/neg/t3240.check deleted file mode 100644 index efae682c66..0000000000 --- a/test/files/neg/t3240.check +++ /dev/null @@ -1,4 +0,0 @@ -t3240.scala:3: error: only classes can have declared but undefined members - type t - ^ -one error found diff --git a/test/files/neg/t3240.scala b/test/files/neg/t3240.scala deleted file mode 100644 index cf197a406d..0000000000 --- a/test/files/neg/t3240.scala +++ /dev/null @@ -1,8 +0,0 @@ -class A { - val foo = new { - type t - def apply(a: Option[t], defVal: Any) = { - a.getOrElse(defVal).asInstanceOf[t] - } - } -}
\ No newline at end of file diff --git a/test/files/neg/t8217-local-alias-requires-rhs.check b/test/files/neg/t8217-local-alias-requires-rhs.check new file mode 100644 index 0000000000..0d4f0864ba --- /dev/null +++ b/test/files/neg/t8217-local-alias-requires-rhs.check @@ -0,0 +1,10 @@ +t8217-local-alias-requires-rhs.scala:6: error: only classes can have declared but undefined members + type B + ^ +t8217-local-alias-requires-rhs.scala:3: error: only classes can have declared but undefined members + type A + ^ +t8217-local-alias-requires-rhs.scala:14: error: only classes can have declared but undefined members + def this(a: Any) = { this(); type C } + ^ +three errors found diff --git a/test/files/neg/t8217-local-alias-requires-rhs.scala b/test/files/neg/t8217-local-alias-requires-rhs.scala new file mode 100644 index 0000000000..12b7976835 --- /dev/null +++ b/test/files/neg/t8217-local-alias-requires-rhs.scala @@ -0,0 +1,15 @@ +trait Alias { + def foo = { + type A + } + val bar = { + type B + object O { + type OK + } + } +} + +class C { + def this(a: Any) = { this(); type C } +} diff --git a/test/files/neg/t845.check b/test/files/neg/t845.check deleted file mode 100644 index 07ed7e417b..0000000000 --- a/test/files/neg/t845.check +++ /dev/null @@ -1,4 +0,0 @@ -t845.scala:4: error: only classes can have declared but undefined members - type Bar; - ^ -one error found diff --git a/test/files/neg/t845.scala b/test/files/neg/t845.scala deleted file mode 100644 index ddf6a16f32..0000000000 --- a/test/files/neg/t845.scala +++ /dev/null @@ -1,16 +0,0 @@ -package test; - -object Test extends App { - type Bar; - trait FooImpl; - - trait Bob { - def bar : Bar with FooImpl; - } - def ifn[A,B](a : A)(f : A => B) = - if (a != null) f(a) else null; - - val bob : Bob = null; - val bar = ifn(bob)(_.bar); - assert(bar == null); -} |