Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework lookup of sub-elements with regard to special accepted elements #7436

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

ogoffart
Copy link
Member

@ogoffart ogoffart commented Jan 23, 2025

Consider

// Some code in the wild actually have made their own menubar before
component MenuBar { /* ... */ }

component Row { /* ... */ }

export component Main inherits Window {
  // This should find the declared component and not the builtin component
  MenuBar { }

  GridLayout {
     Row {}
  }
}

Previously, MenuBar and Row were first resolved against additional_accepted_child_types and so it would always find the builtin one.
But this patch changes that to find the builtin one only if it hasn't been replaced by another component with the name name. (So we'd use the cusom MenuBar and the custom Row)

Another change is that we also lookup the
additional_accepted_child_types if they are in a @children.

component MyGrid {
   GridLayout { @children }
}
export component Main {
   MyGrid {
      // This used to be an error but is now accepted
      Row { }
   }
}

@ogoffart ogoffart requested a review from tronical January 23, 2025 07:53
Consider
```slint
// Some code in the wild actually have made their own menubar before
component MenuBar { /* ... */ }

component Row { /* ... */ }

export component Main inherits Window {
  // This should find the declared component and not the builtin component
  MenuBar { }

  GridLayout {
     Row {}
  }
}
```

Previously, `MenuBar` and `Row` were first resolved against
`additional_accepted_child_types` and so it would always find the
builtin one.
But this patch changes that to find the builtin one only if it hasn't
been replaced by another component with the name name.
(So we'd use the cusom MenuBar and the custom Row)

Another change is that we also lookup the
additional_accepted_child_types if they are in a @children.

```slint
component MyGrid {
   GridLayout { @children }
}
export component Main {
   MyGrid {
      // This used to be an error but is now accepted
      Row { }
   }
}
```
@ogoffart ogoffart merged commit d8d0bb2 into master Jan 23, 2025
37 checks passed
@ogoffart ogoffart deleted the olivier/compiler branch January 23, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants