Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Share MakeGeneric.. and Expression.Call - #2758

Merged
vitek-karas merged 6 commits into
dotnet:mainfrom
vitek-karas:ShareMakeGeneric
Apr 25, 2022
Merged

vitek-karas merged 6 commits into
dotnet:mainfrom
vitek-karas:ShareMakeGeneric

Conversation

@vitek-karas

Copy link
Copy Markdown
Member

Moves the intrinsic handling of MakeGenericType, MakeGenericMethod and Expression.Call into the shared code.

Other changes:

  • Some small refactorings on the shared type system and value system.
  • Expose generic parameters on type system proxies
  • Fix a bug in analyzer when we're recording patterns, the values must be cloned (as they can mutate during analysis after the record is taken)
  • Fix some problems in Nullable handling in MakeGenericType - specifically if we don't know what the T is going to be, we now return just Nullable<> known type (but unknown T).
  • Add couple new tests - update existing ones (mainly due to limitation in the analyzer)

@sbomer sbomer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

}

[ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod))]
// https://github.com/dotnet/linker/issues/2158 - analyzer doesn't work the same as linker, it simply doesn't handle refs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this actually be #2680?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kind of both - I think we need ref tracking in order to implement array reset in this case.

}
// We haven't found any generic parameters with annotations, so there's nothing to validate.
} else if (value == NullValue.Instance) {
// Do nothing - null value is valid and should not cause warnings nor marking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like the null case will effectively return null, should that be fixed to return TopValue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right. The end result is the same since any reflection API will ignore the null on input anyway, but it's better to track it as empty here.
And the comment is wrong. MakeGenericType throws if "this" is null - obviously :-)

@vitek-karas
vitek-karas merged commit bf4d43b into dotnet:main Apr 25, 2022
@vitek-karas
vitek-karas deleted the ShareMakeGeneric branch April 25, 2022 11:23
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
Moves the intrinsic handling of `MakeGenericType`, `MakeGenericMethod` and `Expression.Call` into the shared code.

Other changes:
* Some small refactorings on the shared type system and value system.
* Expose generic parameters on type system proxies
* Fix a bug in analyzer when we're recording patterns, the values must be cloned (as they can mutate during analysis after the record is taken)
* Fix some problems in Nullable<T> handling in MakeGenericType - specifically if we don't know what the T is going to be, we now return just Nullable<> known type (but unknown T).
* Add couple new tests - update existing ones (mainly due to limitation in the analyzer)

Co-authored-by: Sven Boemer <[email protected]>

Commit migrated from dotnet/linker@bf4d43b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants