Skip to content

Fix gettype unbound generics #1165#1230

Closed
GrahamTheCoder wants to merge 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:fix-gettype-unbound-generics-1958760587701317988
Closed

Fix gettype unbound generics #1165#1230
GrahamTheCoder wants to merge 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:fix-gettype-unbound-generics-1958760587701317988

Conversation

@GrahamTheCoder
Copy link
Member

Fixes issue #1165 where GetType(Nullable(Of)) incorrectly translates to typeof(object) instead of typeof(Nullable<>).
There seems to be an upstream bug in the roslyn expander that turns Nullable(Of) into Nullable(Of Object). We'll work around it here.


PR created from Jules task 1958760587701317988 started by @GrahamTheCoder and a follow up claude code session

google-labs-jules bot and others added 2 commits March 11, 2026 23:36
VB open generics like `Nullable(Of )` generate `IErrorTypeSymbol` when using Roslyn's semantic model which previously forced `TypeConversionAnalyzer` and equality comparisons to fall back to `object` instead of preserving the syntax tree representing `typeof(X<>)`.

This patch correctly yields `OmittedTypeArgumentSyntax` and bypasses the `System.Object` coercion fallback for equality testing.

Co-authored-by: GrahamTheCoder <2490482+GrahamTheCoder@users.noreply.github.com>
…e(Of))

Roslyn's Simplifier.Expand replaces missing type arguments (open generics like
Nullable(Of)) with an error type fallback (Object), causing GetType(Nullable(Of))
to incorrectly convert to typeof(object) instead of typeof(Nullable<>).

Guard against this in NameCanBeExpanded by detecting GenericNameSyntax nodes with
missing type arguments and skipping expansion, preserving the open generic form so
the conversion visitors can correctly emit OmittedTypeArgument.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GrahamTheCoder GrahamTheCoder force-pushed the fix-gettype-unbound-generics-1958760587701317988 branch from 37ef51a to 8e57b67 Compare March 13, 2026 14:55
@GrahamTheCoder GrahamTheCoder force-pushed the fix-gettype-unbound-generics-1958760587701317988 branch from 8e57b67 to 2bdaa9f Compare March 13, 2026 15:16
@GrahamTheCoder GrahamTheCoder changed the title Fix gettype unbound generics 1958760587701317988 Fix gettype unbound generics #1165 Mar 13, 2026
@GrahamTheCoder GrahamTheCoder marked this pull request as ready for review March 13, 2026 15:16
@GrahamTheCoder GrahamTheCoder closed this by deleting the head repository Mar 13, 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.

1 participant