This page is no longer maintained — Please continue to the home page at www.scala-lang.org

ValDef names (in compiler plugin)

4 replies
Erkki Lindpere
Joined: 2008-12-19,
User offline. Last seen 42 years 45 weeks ago.

I haven't written compiler plugins for a while and don't know what has
changed in 2.8, so sorry if this is a stupid question, but

In a plug-in that runs after refchecks, for ValDefs that are member
variables of a class, I'm getting names (ValDef.name.toString) that end
with spaces. Why is that? Am I doing something wrong?

Erkki L

Erkki Lindpere
Joined: 2008-12-19,
User offline. Last seen 42 years 45 weeks ago.
Re: ValDef names (in compiler plugin)

Oh yeah, should have mentioned I'm using the scala-compiler and library
version 2.8.0.Beta1 (compiling with Maven).

Erkki Lindpere wrote:
> I haven't written compiler plugins for a while and don't know what has
> changed in 2.8, so sorry if this is a stupid question, but
>
> In a plug-in that runs after refchecks, for ValDefs that are member
> variables of a class, I'm getting names (ValDef.name.toString) that
> end with spaces. Why is that? Am I doing something wrong?
>
> Erkki L
>

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: ValDef names (in compiler plugin)

On Wed, Feb 10, 2010 at 10:32:11PM +0200, Erkki Lindpere wrote:
> In a plug-in that runs after refchecks, for ValDefs that are member
> variables of a class, I'm getting names (ValDef.name.toString) that
> end with spaces. Why is that? Am I doing something wrong?

Those are the local accessors created for values which are not actually
fields (or something like that.) You can probably ignore them. If you
look in StdNames you'll see "isLocalName" which will be true on those.

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: ValDef names (in compiler plugin)

On Wed, Feb 10, 2010 at 10:38 PM, Paul Phillips wrote:
> On Wed, Feb 10, 2010 at 10:32:11PM +0200, Erkki Lindpere wrote:
>> In a plug-in that runs after refchecks, for ValDefs that are member
>> variables of a class, I'm getting names (ValDef.name.toString) that
>> end with spaces. Why is that? Am I doing something wrong?
>
> Those are the local accessors created for values which are not actually
> fields (or something like that.) You can probably ignore them.  If you
> look in StdNames you'll see "isLocalName" which will be true on those.
>
More precisely, the field itself will always have a name ending in a
space. The getter has the same name w/o the space. The space will be
removed before a class file is generated. Things were like that for
all versions of Scala 2.

Cheers

Erkki Lindpere
Joined: 2008-12-19,
User offline. Last seen 42 years 45 weeks ago.
Re: ValDef names (in compiler plugin)

Oh, I guess I just didn't notice because the previous plug-in I was
working on for 2.7.x only looked at methods.

Erkki L
> removed before a class file is generated. Things were like that for
> all versions of Scala 2.
>
>
> Cheers
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland