Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions source/mir/internal/meta.d
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,22 @@ template getUDAs(alias symbol, alias attribute)
static if (AliasSeq!symbol.length != 1)
alias getUDAs = AliasSeq!();
else
static if (__traits(compiles, __traits(getAttributes, symbol)))
static if (__traits(compiles, __traits(getOverloads, symbol)))
{
alias overloads = __traits(getOverloads, symbol);
static if (overloads.length > 0)
{
alias getUDAsImpl(alias overload) = Filter!(isDesiredUDA!attribute, __traits(getAttributes, overload));
alias getUDAs = AliasSeq!(staticMap!(getUDAsImpl, overloads));
}
Comment on lines +119 to +126

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

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

New behavior for overload sets is introduced here, but the file’s unittests don’t cover overloaded symbols (multiple overloads with/without the target UDA). Adding a dedicated unittest for an overloaded function name would help prevent regressions and confirm the intended aggregation semantics across overloads.

Copilot uses AI. Check for mistakes.
else static if (__traits(compiles, __traits(getAttributes, symbol)))
{
alias getUDAs = Filter!(isDesiredUDA!attribute, __traits(getAttributes, symbol));
}
else
alias getUDAs = AliasSeq!();
}
Comment on lines +119 to +133

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

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

The overload-handling logic in getUDAs largely duplicates the overload-handling logic added to autoGetUDAs below. Consider centralizing this by having getUDAs filter over a single helper that returns the flattened attributes (e.g., autoGetUDAs!symbol), so the overload detection rules stay consistent and future changes only need to be made once.

Copilot uses AI. Check for mistakes.
else static if (__traits(compiles, __traits(getAttributes, symbol)))
alias getUDAs = Filter!(isDesiredUDA!attribute, __traits(getAttributes, symbol));
else
alias getUDAs = AliasSeq!();
Expand Down Expand Up @@ -243,8 +258,23 @@ private template isFunction(T, string member)

private template autoGetUDAs(alias symbol)
{
import std.meta : AliasSeq;
static if (__traits(compiles, __traits(getAttributes, symbol)))
import std.meta : AliasSeq, staticMap;
static if (__traits(compiles, __traits(getOverloads, symbol)))
{
alias overloads = __traits(getOverloads, symbol);
static if (overloads.length > 0)
{
alias autoGetUDAsImpl(alias overload) = __traits(getAttributes, overload);
alias autoGetUDAs = AliasSeq!(staticMap!(autoGetUDAsImpl, overloads));
}
else static if (__traits(compiles, __traits(getAttributes, symbol)))
{
alias autoGetUDAs = __traits(getAttributes, symbol);
}
else
alias autoGetUDAs = AliasSeq!();
}
else static if (__traits(compiles, __traits(getAttributes, symbol)))
alias autoGetUDAs = __traits(getAttributes, symbol);
else
alias autoGetUDAs = AliasSeq!();
Expand Down
Loading