Skip to content

Fix gettype unbound generics 1958760587701317988#1230

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

Fix gettype unbound generics 1958760587701317988#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 3 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>
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