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

Unspecified wrong behavior with annotations and extractor vals

4 replies
Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Dear Scalars,

consider the following:

scala> class Test {
     | def f1(implicit i: Int) = println(i)
     | def f2(implicit s: String) = println(s)
     | implicit val(a,b) = (1,"foo")
     |
     | def testF1 = f1
     | def testF2 = f2
     | }
defined class Test

scala> val t = new Test
t: Test = Test@4b48f7e0

scala> t.testF1
1

scala> t.testF2
foo

So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:

doing this doesn't yield transient implicit vals:

@transient implicit val(a,b) = (1,"foo")

Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.

I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".

WDYT?

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Unspecified wrong behavior with annotations and extractor v
Seems like a bug/feature request to me.   Certainly You could work around the issue, but it would be ugly.

- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:

Dear Scalars,

consider the following:

scala> class Test {
     | def f1(implicit i: Int) = println(i)
     | def f2(implicit s: String) = println(s)
     | implicit val(a,b) = (1,"foo")
     |
     | def testF1 = f1
     | def testF2 = f2
     | }
defined class Test

scala> val t = new Test
t: Test = Test@4b48f7e0

scala> t.testF1
1

scala> t.testF2
foo

So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:

doing this doesn't yield transient implicit vals:

@transient implicit val(a,b) = (1,"foo")

Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.

I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".

WDYT?

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Unspecified wrong behavior with annotations and extractor v
Seems like a bug/feature request to me.   Certainly You could work around the issue, but it would be ugly.

- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:

Dear Scalars,

consider the following:

scala> class Test {
     | def f1(implicit i: Int) = println(i)
     | def f2(implicit s: String) = println(s)
     | implicit val(a,b) = (1,"foo")
     |
     | def testF1 = f1
     | def testF2 = f2
     | }
defined class Test

scala> val t = new Test
t: Test = Test@4b48f7e0

scala> t.testF1
1

scala> t.testF2
foo

So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:

doing this doesn't yield transient implicit vals:

@transient implicit val(a,b) = (1,"foo")

Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.

I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".

WDYT?

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: Unspecified wrong behavior with annotations and extractor
So what's the next step? Trac?

On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
Seems like a bug/feature request to me.   Certainly You could work around the issue, but it would be ugly.

- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:

Dear Scalars,

consider the following:

scala> class Test {
     | def f1(implicit i: Int) = println(i)
     | def f2(implicit s: String) = println(s)
     | implicit val(a,b) = (1,"foo")
     |
     | def testF1 = f1
     | def testF2 = f2
     | }
defined class Test

scala> val t = new Test
t: Test = Test@4b48f7e0

scala> t.testF1
1

scala> t.testF2
foo

So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:

doing this doesn't yield transient implicit vals:

@transient implicit val(a,b) = (1,"foo")

Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.

I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".

WDYT?

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang



--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: Unspecified wrong behavior with annotations and extractor
So what's the next step? Trac?

On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
Seems like a bug/feature request to me.   Certainly You could work around the issue, but it would be ugly.

- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:

Dear Scalars,

consider the following:

scala> class Test {
     | def f1(implicit i: Int) = println(i)
     | def f2(implicit s: String) = println(s)
     | implicit val(a,b) = (1,"foo")
     |
     | def testF1 = f1
     | def testF2 = f2
     | }
defined class Test

scala> val t = new Test
t: Test = Test@4b48f7e0

scala> t.testF1
1

scala> t.testF2
foo

So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:

doing this doesn't yield transient implicit vals:

@transient implicit val(a,b) = (1,"foo")

Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.

I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".

WDYT?

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang



--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang

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