Skip to content

Conversation

@vitek-karas
Copy link
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)

Copy link
Member

@sbomer sbomer left a comment

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
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
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
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
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 join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants