- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
auto-completion in the REPL
Mon, 2009-07-20, 22:10
Spotted a bug in the REPL...
It looks as though auto-completion against a variable is incorrectly working against the concrete implementation that the variable points to, instead of working with the defined type .
Demo:
---
Welcome to Scala version 2.8.0.r18341-b20090718154540 (Java HotSpot(TM) Client VM, Java 1.6.0_10). Type in expressions to have them evaluated.Type :help for more information.
scala> abstract class Foo { | def fooMethod = 1 | }defined class Foo
scala> class Bar extends Foo { | def barMethod = 2 | }defined class Bar
scala> val x : Foo = new Barx: Foo = Bar@1afc0f5
scala> x. [tab]
asInstanceOf barMethod fooMethod getClass isInstanceOf toString
scala> x.barMethod<console>:8: error: value barMethod is not a member of Foo x.barMethod ^
---
With the [tab] indicating auto-completion.
It looks as though auto-completion against a variable is incorrectly working against the concrete implementation that the variable points to, instead of working with the defined type .
Demo:
---
Welcome to Scala version 2.8.0.r18341-b20090718154540 (Java HotSpot(TM) Client VM, Java 1.6.0_10). Type in expressions to have them evaluated.Type :help for more information.
scala> abstract class Foo { | def fooMethod = 1 | }defined class Foo
scala> class Bar extends Foo { | def barMethod = 2 | }defined class Bar
scala> val x : Foo = new Barx: Foo = Bar@1afc0f5
scala> x. [tab]
asInstanceOf barMethod fooMethod getClass isInstanceOf toString
scala> x.barMethod<console>:8: error: value barMethod is not a member of Foo x.barMethod ^
---
With the [tab] indicating auto-completion.
Mon, 2009-07-20, 22:37
#2
Re: auto-completion in the REPL
On Mon, Jul 20, 2009 at 10:10:23PM +0100, Kevin Wright wrote:
> It looks as though auto-completion against a variable is incorrectly
> working against the concrete implementation that the variable points
> to, instead of working with the defined type .
This is not so much a bug as it is an unimplemented feature. I am aware
of it, but it is not a big priority compared to most of the bugs on my
radar. It happens because completion uses reflection to find things
out, so you see what's really inside (at the JVM level) not what the
scala type system might think is inside.
Mon, 2009-07-20, 22:47
#3
Re: auto-completion in the REPL
I suspected as much :)
It's not a big problem for me at the moment, but I imagine it could be if I were working with larger 3rd party libraries and being offered methods that aren't valid in context
On Mon, Jul 20, 2009 at 10:21 PM, Paul Phillips <paulp@improving.org> wrote:
It's not a big problem for me at the moment, but I imagine it could be if I were working with larger 3rd party libraries and being offered methods that aren't valid in context
On Mon, Jul 20, 2009 at 10:21 PM, Paul Phillips <paulp@improving.org> wrote:
On Mon, Jul 20, 2009 at 10:10:23PM +0100, Kevin Wright wrote:
> It looks as though auto-completion against a variable is incorrectly
> working against the concrete implementation that the variable points
> to, instead of working with the defined type .
This is not so much a bug as it is an unimplemented feature. I am aware
of it, but it is not a big priority compared to most of the bugs on my
radar. It happens because completion uses reflection to find things
out, so you see what's really inside (at the JVM level) not what the
scala type system might think is inside.
--
Paul Phillips | If this is raisin, make toast with it.
Vivid |
Empiricist |
i'll ship a pulp |----------* http://www.improving.org/paulp/ *----------
On Mon, Jul 20, 2009 at 6:10 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
--
Daniel C. Sobral
Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.