Skip to content

fix(restrict-template-expressions): allow inherited types in allow list#804

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list
Mar 17, 2026
Merged

fix(restrict-template-expressions): allow inherited types in allow list#804
graphite-app[bot] merged 1 commit intomainfrom
c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 16, 2026

No description provided.

Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 16, 2026


How to use the Graphite Merge Queue

Add the label 0-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camc314 camc314 marked this pull request as ready for review March 16, 2026 19:37
Copilot AI review requested due to automatic review settings March 16, 2026 19:37
@graphite-app graphite-app Bot changed the base branch from c/03-16-refactor_move_matchestypeorbasetype_function_to_utils_package to graphite-base/804 March 16, 2026 19:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the restrict-template-expressions rule to allow types that inherit from types listed in the allow option. Previously, only an exact type match was checked against the allow list; now the rule walks the inheritance chain using MatchesTypeOrBaseType, so a derived class or interface is accepted if any of its base types match a specifier in the allow list.

Changes:

  • Wrapped the TypeMatchesSomeSpecifier call with MatchesTypeOrBaseType to recursively check base types against the allow list.
  • Added three valid test cases covering single-level class inheritance, multi-level class inheritance, and interface inheritance.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/rules/restrict_template_expressions/restrict_template_expressions.go Wraps the allow-list type check with MatchesTypeOrBaseType to match inherited types
internal/rules/restrict_template_expressions/restrict_template_expressions_test.go Adds three valid test cases for class and interface inheritance scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@camc314 camc314 force-pushed the c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list branch from 93080ba to 49289b5 Compare March 16, 2026 19:47
@camc314 camc314 force-pushed the graphite-base/804 branch from fe97c74 to e04113f Compare March 16, 2026 19:47
@camc314 camc314 marked this pull request as draft March 16, 2026 19:48
@graphite-app graphite-app Bot force-pushed the graphite-base/804 branch from e04113f to 16b3b4e Compare March 16, 2026 21:32
@graphite-app graphite-app Bot force-pushed the c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list branch from 49289b5 to 89fca42 Compare March 16, 2026 21:32
@graphite-app graphite-app Bot changed the base branch from graphite-base/804 to main March 16, 2026 21:33
@graphite-app graphite-app Bot force-pushed the c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list branch from 89fca42 to f96d5e9 Compare March 16, 2026 21:33
@camc314 camc314 marked this pull request as ready for review March 17, 2026 10:45
@camc314 camc314 self-assigned this Mar 17, 2026
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Mar 17, 2026

Merge activity

@graphite-app graphite-app Bot force-pushed the c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list branch from f96d5e9 to 2617074 Compare March 17, 2026 10:46
@graphite-app graphite-app Bot merged commit 2617074 into main Mar 17, 2026
8 checks passed
@graphite-app graphite-app Bot deleted the c/03-16-fix_restrict-template-expressions_allow_inherited_types_in_allow_list branch March 17, 2026 10:54
@graphite-app graphite-app Bot removed the 0-merge label Mar 17, 2026
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