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

protected[qual] members have their name mangled

2 replies
dubochet
Joined: 2008-06-30,
User offline. Last seen 1 year 36 weeks ago.

Hello.

I just noticed that "protected[qual]" symbols have their names mangled, like private symbols.

Other protected symbols keep their original names.

Is this intended, and if so, why?

Cheers,
Gilles.

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: protected[qual] members have their name mangled


On Sat, Apr 3, 2010 at 8:46 PM, Gilles Dubochet <gilles.dubochet@epfl.ch> wrote:
Hello.

I just noticed that "protected[qual]" symbols have their names mangled, like private symbols.

Other protected symbols keep their original names.

Is this intended, and if so, why?

I'm pretty sure it is intended, but I'd have to dig a  bit why. AFAIK it was Sean who was demanding that.

Cheers
 
 -- Martin

dubochet
Joined: 2008-06-30,
User offline. Last seen 1 year 36 weeks ago.
Re: protected[qual] members have their name mangled

>> I just noticed that "protected[qual]" symbols have their names mangled, like private symbols.
>>
>> Other protected symbols keep their original names.
>>
>> Is this intended, and if so, why?
>
> I'm pretty sure it is intended, but I'd have to dig a bit why. AFAIK it was Sean who was demanding that.

I see. I usually assume that a behaviour I do not understand is intended. But in that case, it really seemed suspicious to me.

Firstly, protected[this], which restricts access more, is not name mangled.

Secondly, I find the design of how protected[qual] is encoded in symbols to be error prone. It seems natural to write a test to check if a symbol is private like this:

(sym.isPrivate) || (privateWithin != NoSymbol)

But this is wrong because privateWithin is actually also used for protected symbols. Strangely, for protected symbols, flag PROTECTED is set in addition to setting privateWithin, but for private symbols, privateWithin is set without a PRIVATE flag. Therefore, a correct test is something like:

(sym.isPrivate) || !((sym.isProtected) || (privateWithin == NoSymbol))

Maybe this clarifies why I asked this question. It's not urgent or anything; I was just checking.

Good night,
Gilles.

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