Skip to content

Complete generic parameter support for windows-rdl - #3906

Merged
Kenny Kerr (kennykerr) merged 2 commits into
masterfrom
rdl-generic-params
Feb 25, 2026
Merged

Complete generic parameter support for windows-rdl#3906
Kenny Kerr (kennykerr) merged 2 commits into
masterfrom
rdl-generic-params

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

Building on #3861, this completes support for not only generic types (#3902) but also generic parameters which require special handling as per the spec. This update allows the following:

#[winrt]
mod Test {
    delegate fn Handler<Arg, Result>(arg: Arg) -> Result;

    interface IMap<K, V> {
        fn Lookup(&self, key: K) -> V;
        fn Handler(&self, handler: Handler<K, V>);
        fn Generic(&self, map: IMap<K, V>);
        fn Special(&self, map: IMap<i32, u64>);
    }
}

Notice how thew handler and map parameters can both inherit the generics of the enclosing type or be specialized directly. And here is the result IL:

.class interface public auto ansi abstract windowsruntime Test.IMap`2<K, V>
{
	.method public hidebysig newslot abstract virtual 
		instance !V Lookup (
			[in] !K key
		) cil managed 
	{
	}

	.method public hidebysig newslot abstract virtual 
		instance void Handler (
			[in] class [Test]Test.Handler`2<!K, !V> 'handler'
		) cil managed 
	{
	}

	.method public hidebysig newslot abstract virtual 
		instance void Generic (
			[in] class [Test]Test.IMap`2<!K, !V> map
		) cil managed 
	{
	}

	.method public hidebysig newslot abstract virtual 
		instance void Special (
			[in] class [Test]Test.IMap`2<int32, uint64> map
		) cil managed 
	{
	}
}

Next up I need to work on required interfaces (that can also be generic).

@kennykerr
Kenny Kerr (kennykerr) merged commit f8d2aea into master Feb 25, 2026
32 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the rdl-generic-params branch February 25, 2026 18:14
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.

1 participant