We can probably define an inlineparent() for use in codegen so that the erasure is transparent.
This should be easy for categories without params. The main issue will be that we'll need to get the type every time we need it. Maybe we can change CreateType_Foo to return const S<const Type_Foo>& so that it doesn't update reference counts when we're not storing a reference.
For categories with params, we can't return const S<const Type_Foo>& because the reference count could go to zero during the return process. (For categories without params, the reference is static.)
But, assuming that problem is solved, we'd need to add a flag to CompiledData to indicate if the generated @value code ever refers to the @type parent. (We should still be able to eliminate the @category parent in @type instances.)
Note that this could still be a bad idea, since it would potentially require constructing and then destructing a Type_Foo every time a @value is created. So, I think we'd actually need to update the constructor for Value_Foo to not require a parent arg.
We'd potentially need to treat extensions differently, e.g., skip removing parent if it has params.
We can probably define an
inline
parent()
for use in codegen so that the erasure is transparent.This should be easy for categories without params. The main issue will be that we'll need to get the type every time we need it. Maybe we can change
CreateType_Foo
to returnconst S<const Type_Foo>&
so that it doesn't update reference counts when we're not storing a reference.For categories with params, we can't return
const S<const Type_Foo>&
because the reference count could go to zero during the return process. (For categories without params, the reference is static.)But, assuming that problem is solved, we'd need to add a flag to
CompiledData
to indicate if the generated@value
code ever refers to the@type
parent. (We should still be able to eliminate the@category
parent in@type
instances.)Note that this could still be a bad idea, since it would potentially require constructing and then destructing a
Type_Foo
every time a@value
is created. So, I think we'd actually need to update the constructor forValue_Foo
to not require a parent arg.We'd potentially need to treat extensions differently, e.g., skip removing
parent
if it has params.