https://pantsbuild.org/ logo
#development
Title
# development
f

fast-nail-55400

08/11/2021, 2:04 PM
is the engine able to convert from a
Target
subclass to some other non-target type if there is a rule defined for that conversion? can it do so if the rule is defined to take an applicable FieldSet as input and returns the destination type?
w

witty-crayon-22786

08/11/2021, 4:06 PM
is the engine able to convert from a 
Target
 subclass to some other non-target type if there is a rule defined for that conversion?
yes: if you have a rule
convert_my_target(…: MyTarget) -> NonTargetType
it would be invoked.
can it do so if the rule is defined to take an applicable FieldSet as input and returns the destination type?
i don’t see why not.
maybe your question is rooted in the subtyping bit though?
Target
subtypes are not provided by any rule in the graph currently, so you’d have to actually do the cast yourself and then
await Get (NonTargetType, MyTarget(..))
h

hundreds-father-404

08/11/2021, 4:49 PM
maybe your question is rooted in the subtyping bit though?
Maybe what you mean: @fast-nail-55400 one thing to be aware of is how the engine uses exact type IDs and does not respect subclassing. A rule that takes
Target
won't work because nothing in the repo has the type ID of
Target
. This is why we have
WrappedTarget
and field sets etc