@travisbrown any ideas? stackoverflow.com/questions/3357…
2015-11-07 00:50:01@jco @travisbrown def hey(t: Thing): Thing#Out = Wrapper(t).get compiles, but have't checked if that's the fix :)
2015-11-07 00:56:29@gclaramunt That doesn't give you a useful static type, though. You're not willing to put a type parameter on `Wrapper`, @jco?
2015-11-07 01:01:05@travisbrown @gclaramunt I might be able to swing that...still don't get why it can't tell the two are equal?
2015-11-07 01:14:45@econlon @travisbrown the real example this is mined from becomes much nastier if it has to have that
2015-11-07 01:15:07@econlon @jco @travisbrown Like Eric said, you need to parametrize your class on the type it holds.
2015-11-07 01:15:43@jco @travisbrown burn it all, just get rid of inheritance and cast to Any everywhere
2015-11-07 01:15:50@econlon @jco @travisbrown Contrary to what you think your example code is not safe
2015-11-07 01:16:57@GabrielG439 @econlon @jco It's possible to make it work without a type parameter—you just have to be careful not to lose the refinement.
2015-11-07 01:17:07@GabrielG439 @econlon @travisbrown this is highly undesirable b/c of type inference though, and in many cases you know that Out is fixed
2015-11-07 01:21:07@jco @econlon @travisbrown The type of your "hey" function is basically equivalent to: forall a. Thing => a
2015-11-07 01:21:08@jco @GabrielG439 @econlon You just need a `Wrapper.apply` that returns a refined `Wrapper`: stackoverflow.com/a/33571157/334…
2015-11-07 01:22:42@jco @econlon @travisbrown If Out really is fixed then you need to prove that by actually fixing it at the point of definition
2015-11-07 01:23:15@GabrielG439 @econlon @travisbrown how is this unsafe? just because it doesn't seem useful doesn't make it unsafe?
2015-11-07 01:24:13@jco @econlon @travisbrown Parametrizing it on the wrapped type should improve type inference
2015-11-07 01:24:25@GabrielG439 @econlon @travisbrown it is fixed by t.Out, no?
2015-11-07 01:24:30@jco @econlon @travisbrown t.Out is existentially quantified, which means that you can use it, but only in a restricted way
2015-11-07 01:26:37@jco @econlon @travisbrown This is hard to explain in one tweet, so tweet storm incoming...
2015-11-07 01:28:29@GabrielG439 @jco @econlon Not exactly true, thanks to Scala's path-dependent types (assuming the compiler statically knows `t`'s `Out`).
2015-11-07 01:29:02@jco @econlon @travisbrown For an existentially quantified type you can only confirm it's consistent with other fields of the same class
2015-11-07 01:31:11@travisbrown @jco @econlon Right, this is the same thing as existential quantification. You can know the type within a pattern match
2015-11-07 01:33:03@GabrielG439 @jco @travisbrown the classes end up being huge modules in that case, so probably not too bad
2015-11-07 01:33:05@travisbrown @jco @econlon But the type cannot leak from that scope without a type error
2015-11-07 01:33:27