ceylon / ceylon.language

DEPRECATED
Apache License 2.0
153 stars 57 forks source link

Specialized type tests #688

Open tombentley opened 9 years ago

tombentley commented 9 years ago

While working on serialization I've come across the need to know about the types of instances at runtime which our existing metamodel APIs don't satisfy very well.

tombentley commented 9 years ago

Oh, and another related thing, as the above examples demonstrate, I end up going type(instance).declaration a lot. This requires construction of a ClassModel just to obtain it's ClassDeclaration. Having a ClassDeclaration classDeclaration(Anything instance) we could avoid that.

gavinking commented 9 years ago

@tombentley why can't you use is Array<out Anything> array ??

gavinking commented 9 years ago

Having a ClassDeclaration classDeclaration(Anything instance) we could avoid that.

That would be nice, I agree.

tombentley commented 9 years ago

@tombentley why can't you use is Array<out Anything> array ??

Because I keep forgetting we have use-site variance I suppose.

tombentley commented 9 years ago

@gavinking is there a reason why Span and Measure can't be shared? I know we don't want people to instantiate them directly (but use span() and measure()), but we could make them sealed. That way at least we can refer to their type.

gavinking commented 9 years ago

Well, so we can change that design later. I mean there's not really a huge difference between a "span" and a "measure", they are much the same thing.

FroMage commented 9 years ago

Moving to 1.3.