Use SuperInto and correct Owner for props defaults (#3959)

This commit is contained in:
pandarrr authored and GitHub committed 2025-05-07 13:34:05 -07:00
1 parent 04b14c5abc
commit 0c0f0e96df
2 files changed
+50 -1

No files matched your search

+8 -1
View File
@@ -1416,10 +1416,15 @@ Finally, call `.build()` to create the instance of `{name}`.
// If field has `into`, apply it to the default value.
// Ignore any blank defaults as it causes type inference errors.
let is_default = *default == parse_quote!(::core::default::Default::default());
// If this is a signal type, we use super_into and the props struct as the owner
let is_child_owned_type = child_owned_type(field.ty);
let mut into = quote!{};
if !is_default {
if field.builder_attr.auto_into {
if is_child_owned_type {
into = quote!{ .super_into() }
} else if field.builder_attr.auto_into {
into = quote!{ .into() }
} else if field.builder_attr.auto_to_string {
into = quote!{ .to_string() }
@@ -1428,6 +1433,8 @@ Finally, call `.build()` to create the instance of `{name}`.
if field.builder_attr.skip {
quote!(let #name = #default #into;)
} else if is_child_owned_type {
quote!(let #name = #helper_trait_name::into_value(#name, || with_owner(self.owner.clone(), move || (#default) #into));)
} else {
quote!(let #name = #helper_trait_name::into_value(#name, || #default #into);)
}