diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-07 19:06:17 +0200 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-05-20 13:38:49 +0200 |
commit | fb3dba1bac13a755d2304928cbd49e7dde6f1bf9 (patch) | |
tree | a4e712103779decdebc439e33aa2c3f8f16890e8 /tests/neg/blockescapesNeg.scala | |
parent | f7910005038c188e573e8d1a42ff3e31c69c90c1 (diff) | |
download | dotty-fb3dba1bac13a755d2304928cbd49e7dde6f1bf9.tar.gz dotty-fb3dba1bac13a755d2304928cbd49e7dde6f1bf9.tar.bz2 dotty-fb3dba1bac13a755d2304928cbd49e7dde6f1bf9.zip |
Avoid hoisting of local classes out of method bodies.
Doing so is unsound. We instead approximate local classes by their parents, but
only if the expected type is not fully defined.
This makes the test t2421_delitedsl1.scala in the commit pass. The oter test,
blockEscapesNeg.scala is modified to fail. Previously it failed outright but with the
new rules the nested class Bar is approximated to Object. That means that the block
containing `Foo.Bar` typechecks, but with type `Object` instead of the unreachable `Bar`.
Diffstat (limited to 'tests/neg/blockescapesNeg.scala')
-rw-r--r-- | tests/neg/blockescapesNeg.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/neg/blockescapesNeg.scala b/tests/neg/blockescapesNeg.scala index 028ef5162..7b448ad23 100644 --- a/tests/neg/blockescapesNeg.scala +++ b/tests/neg/blockescapesNeg.scala @@ -1,5 +1,6 @@ object blockescapesNeg { - def m0 = { object Foo { class Bar } ; new Foo.Bar } + def m0 = { object Foo { class Bar { val field = 2 }} ; new Foo.Bar } + m0.field class A[T] def m1 = { val x = 1; new A[x.type]} -}
\ No newline at end of file +} |