Skip to content

Conversation

csyonghe
Copy link
Collaborator

Closes #7451.

Given:

public interface IDataTrait {
    public associatedtype InputType;
}

public interface IBar {
    public void eval<Di : IDataTrait>(Di.InputType interface_input);
}

struct Impl : IBar
{
    public void eval<Dx : IDataTrait>(Dx.InputType impl_input);
}

The default declref to Impl.eval.Dx.InputType is LookupDeclRef(InputType, Dx, witness = DeclaredSubtypeWitness(declRef = DirectDeclRef(Impl.eval.Dx_is_IDataTrait)).

However when we try to match the implementation signature to interface signature, we will form a declref to IBar.eval.Di using substition Di = Dx, witness(Di:IDataTrait) = DeclaredSubtypeWitness(MemberDeclRef(GenericAppDeclRef(Impl.eval,DeclRefType(Dx)), Dx_is_IDataTrait), causing the pointer identity of the specialized declref to mismatch.

The fix is to exclude any default substitutions when forming a declref to the declared witness in the generic signature matching step.

@csyonghe csyonghe requested a review from a team as a code owner July 10, 2025 22:57
@csyonghe csyonghe added the pr: non-breaking PRs without breaking changes label Jul 10, 2025
Copy link
Contributor

@gtong-nv gtong-nv left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@csyonghe csyonghe added this pull request to the merge queue Jul 11, 2025
Merged via the queue into shader-slang:master with commit 7764b83 Jul 11, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic interface with generic method not recognized as implemented
2 participants