#2504 Type does not conform to @Serializable rules

SlimerDude Sat 23 Jan 2016

Hi,

sys::Type is declared with the following:

@Serializable { simple = true }
const class Type { ... }

The docs for @Serializable.simple say:

Must declare a static method called fromStr which takes one Str parameter and returns an instance of the declaring type.

Obviously Type has the find() method which is semantically the same, but should it not also have a fromStr() method?

I was doing some generic @Serializable handling for simple objects when Type threw me this curve ball.

Note that Slots also don't have a fromStr() method.

jay_t55 Sat 23 Jan 2016

.

brian Sat 23 Jan 2016

Types and Slots have built-in serialization which matches their special literal syntax in Fantom:

fansh> Env.cur.out.writeObj(Str#).printLine
sys::Str#
fan.sys.SysOutStream@357a2d32
fansh> Env.cur.out.writeObj(Str#replace).printLine
sys::Str#replace
fan.sys.SysOutStream@357a2d32

SlimerDude Sat 23 Jan 2016

Thanks Brian, I was aware that Types and Slots can be serialised via Streams.

For what I was doing, it was easier and far less overhead to just call toStr() and fromStr() via reflection. So I was just pointing out that Types and Slots, although being annotated with @Serializable { simple = true }, don't actually conform to the Simple Serialisation Specification.

brian Sat 6 Feb 2016

Yes that is an over sight, I pushed a fix

brian Mon 8 Feb 2016

Also fixed Field and Method

Login or Signup to reply.