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

Regression (source incompatibility) between 2.8.x and 2.9

4 replies
Chris Marshall
Joined: 2009-06-17,
User offline. Last seen 44 weeks 3 days ago.
There seem to have been changes made to visibility rules between 2.8 and 2.9
In 2.8:
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_18).Type in expressions to have them evaluated.Type :help for more information.
scala> abstract class Top(val id : String)defined class Top
scala> abstract class Middle(id : String) extends Top(id)defined class Middle
scala> trait T { self : Middle =>     | def foo = println(id)     | }defined trait T

In 2.9
Welcome to Scala version 2.9.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_18).Type in expressions to have them evaluated.Type :help for more information.
scala> abstract class Top(val id : String)defined class Top
scala> abstract class Middle(id : String) extends Top(id)defined class Middle
scala> trait T { self : Middle =>     | def foo = println(id)     | }<console>:10: error: value id in class Middle cannot be accessed in T with Middle       def foo = println(id)                         ^

Chris

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Regression (source incompatibility) between 2.8.x and 2.9

Constructor members not tagget with "val" or "var" are private. They
would not be visible from a inheriting class, so should they be
visible from a self type? Personally, I think that would be a break of
encapsulation, and so should be avoided.

On Thu, May 19, 2011 at 07:11, Chris Marshall wrote:
> There seem to have been changes made to visibility rules between 2.8 and 2.9
> In 2.8:
>
> Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM,
> Java 1.6.0_18).
> Type in expressions to have them evaluated.
> Type :help for more information.
> scala> abstract class Top(val id : String)
> defined class Top
> scala> abstract class Middle(id : String) extends Top(id)
> defined class Middle
> scala> trait T { self : Middle =>
>      | def foo = println(id)
>      | }
> defined trait T
>
> In 2.9
>
> Welcome to Scala version 2.9.0.final (Java HotSpot(TM) 64-Bit Server VM,
> Java 1.6.0_18).
> Type in expressions to have them evaluated.
> Type :help for more information.
> scala> abstract class Top(val id : String)
> defined class Top
> scala> abstract class Middle(id : String) extends Top(id)
> defined class Middle
> scala> trait T { self : Middle =>
>      | def foo = println(id)
>      | }
> :10: error: value id in class Middle cannot be accessed in T with
> Middle
>        def foo = println(id)
>                          ^
>
> Chris
>
>

sjrd
Joined: 2011-04-09,
User offline. Last seen 51 weeks 2 days ago.
Re: Regression (source incompatibility) between 2.8.x and 2.9

Sure, but in the given example, Middle extends Top, whose constructor
parameter id *is* tagged with val, and hence public.
So trait T should be able to access the id defined in Top, shouldn't
it?

Sébastien

On 19 mai, 14:00, Daniel Sobral wrote:
> Constructor members not tagget with "val" or "var" are private. They
> would not be visible from a inheriting class, so should they be
> visible from a self type? Personally, I think that would be a break of
> encapsulation, and so should be avoided.
>
>
>
> On Thu, May 19, 2011 at 07:11, Chris Marshall wrote:
> > There seem to have been changes made to visibility rules between 2.8 and 2.9
> > In 2.8:
>
> > Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM,
> > Java 1.6.0_18).
> > Type in expressions to have them evaluated.
> > Type :help for more information.
> > scala> abstract class Top(val id : String)
> > defined class Top
> > scala> abstract class Middle(id : String) extends Top(id)
> > defined class Middle
> > scala> trait T { self : Middle =>
> >      | def foo = println(id)
> >      | }
> > defined trait T
>
> > In 2.9
>
> > Welcome to Scala version 2.9.0.final (Java HotSpot(TM) 64-Bit Server VM,
> > Java 1.6.0_18).
> > Type in expressions to have them evaluated.
> > Type :help for more information.
> > scala> abstract class Top(val id : String)
> > defined class Top
> > scala> abstract class Middle(id : String) extends Top(id)
> > defined class Middle
> > scala> trait T { self : Middle =>
> >      | def foo = println(id)
> >      | }
> > :10: error: value id in class Middle cannot be accessed in T with
> > Middle
> >        def foo = println(id)
> >                          ^
>
> > Chris
>
> --
> Daniel C. Sobral
>
> I travel to the future all the time.

Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: Regression (source incompatibility) between 2.8.x and 2

https://issues.scala-lang.org/browse/SI-4606

On Fri, May 20, 2011 at 11:02 AM, Sébastien Doeraene aka sjrd
wrote:
> Sure, but in the given example, Middle extends Top, whose constructor
> parameter id *is* tagged with val, and hence public.
> So trait T should be able to access the id defined in Top, shouldn't
> it?
>
> Sébastien

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: Regression (source incompatibility) between 2.8.x and 2

On Fri, May 20, 2011 at 06:02, Sébastien Doeraene aka sjrd
wrote:
> Sure, but in the given example, Middle extends Top, whose constructor
> parameter id *is* tagged with val, and hence public.
> So trait T should be able to access the id defined in Top, shouldn't
> it?

Oh... yeah, right. Missed that.

>
> Sébastien
>
> On 19 mai, 14:00, Daniel Sobral wrote:
>> Constructor members not tagget with "val" or "var" are private. They
>> would not be visible from a inheriting class, so should they be
>> visible from a self type? Personally, I think that would be a break of
>> encapsulation, and so should be avoided.
>>
>>
>>
>> On Thu, May 19, 2011 at 07:11, Chris Marshall wrote:
>> > There seem to have been changes made to visibility rules between 2.8 and 2.9
>> > In 2.8:
>>
>> > Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM,
>> > Java 1.6.0_18).
>> > Type in expressions to have them evaluated.
>> > Type :help for more information.
>> > scala> abstract class Top(val id : String)
>> > defined class Top
>> > scala> abstract class Middle(id : String) extends Top(id)
>> > defined class Middle
>> > scala> trait T { self : Middle =>
>> >      | def foo = println(id)
>> >      | }
>> > defined trait T
>>
>> > In 2.9
>>
>> > Welcome to Scala version 2.9.0.final (Java HotSpot(TM) 64-Bit Server VM,
>> > Java 1.6.0_18).
>> > Type in expressions to have them evaluated.
>> > Type :help for more information.
>> > scala> abstract class Top(val id : String)
>> > defined class Top
>> > scala> abstract class Middle(id : String) extends Top(id)
>> > defined class Middle
>> > scala> trait T { self : Middle =>
>> >      | def foo = println(id)
>> >      | }
>> > :10: error: value id in class Middle cannot be accessed in T with
>> > Middle
>> >        def foo = println(id)
>> >                          ^
>>
>> > Chris
>>
>> --
>> Daniel C. Sobral
>>
>> I travel to the future all the time.

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