Repository navigation
Trim static interface methods - #2
Closed
jtschuster wants to merge 28 commits into
Closed
jtschuster wants to merge 28 commits into
jtschuster wants to merge 28 commits into
Conversation
…0401.3 (dotnet#2720) [main] Update dependencies from dotnet/runtime
* Add tests for nested functions called from nested state machines The existing algorithm to recursively discover calls to local functions from a user method was incorrect for the case where a local function was called from a state machine local function's MoveNext method. These methods were being treated as roots for the discovery, as if they were user code, which caused a failure downstream when we assumed that each local function belongs to a unique user method - since a local function might be called from a user method _and_ a nested state machine local function. The existing behavior also had the issue that a local function state machine's attributes could suppress warnings from nested local functions, going against the behavior for normal nested functions in the linker. * Don't fail on multiple user methods for same nested function * Correctly handle iterator local functions calling nested functions This fixes the issues shown in the tests by letting the state machine types participate in the call graph discovery instead of being considered as roots. Now any local functions called from state machine local functions will be associated with the user method, not with the state machine MoveNext method. * Fix test for analyzer * Update src/linker/Linker/CompilerGeneratedState.cs Co-authored-by: Vitek Karas <[email protected]> * Adjust comments and docs * Fix docs Co-authored-by: Vitek Karas <[email protected]>
The main change is sharing of the GetConstructor intrinsic and related tests.
To make those tests work this also implements Type.EmptyTypes and String.Empty and Array.Empty intrinsics.
These are all treated as special cases:
* Type.EmptyTypes and String.Empty are actually field accesses, so we don't have infra to share these yet, no need to add one for now
* Array.Empty is a generic method where we need to know the generic instantiation. The current sharing doesn't propagate this information
so this forced the implementation to NOT be shared but instead done as a fallback which the shared one doesn't handle.
The rest of the changes are all about fixing how the shared intrinsic handling propagates return value from intrinsics.
Lot of small subtle bugs around null or emtpy inputs and forgetting to add return value and so on. The main changes are in GetMethod and GetNestedType intrinsics which had lot of issues.
Added tests for all of the corner cases.
NestedTypesUsedViaReflection test has been reworked as previously it didn't work correctly. Lot of the [Kept] attributes were fulfilled by some of the negative tests and thus the positive tests didn't have coverage (for example calling GetNestedType(unknownName) will mark all nested types on the type, so a subsequent call to GetNestedType("knownname") will not have an observable effect).
Add check for cref in generic parameter dataflow to avoid failing with a nullreference exception Refactor code to reuse the while loop for both INamedType and Method symbols Add tests Fixes dotnet#2724
…0408.8 (dotnet#2734) [main] Update dependencies from dotnet/runtime
This comment was marked as outdated.
This comment was marked as outdated.
This will make sure that we keep all interfaces and all interface method implementations on such type. * Change the solution to rely on the optimization setting only * wip * Add implicit interface implementation case * Edit tests to remove issue-specific code and names * Mark members of CollectedType as kept * Add private interface test and simplify external interface example * Replace early exit for non-interfaces * License headers and use IsMethodNeededByTypeDueToPreservedScope instead of Interface specific version * Add check for static methods before skipping virtual marking Check for optimization before skipping marking interface methods for PreservedScope Add doc comments * Add more clarifying comments, move static method check, rename method Rename IsVirtualNeededByInstantiatedTypeDueToPreservedScope to IsOverrideNeededByInstantiatedTypeDueToPreservedScope Added more comments describing purpose of methods Moved the static interface method check to the method that is called on all types regardless of instantiation * Renames and comment cleanup + tests This doesn't change product behavior, only renamed methods and improved comments. Added new tests for the RootLibrary: - Added a dependency to an "copy" assembly (mainly because I can define a static interface in it) - Added more combinations to the interfaces/classes in the test - Since this uses static interface methods I had to enable "preview" language features for the test project and for the test infra. * More tests for interface behavior Co-authored-by: vitek-karas <[email protected]> Co-authored-by: vitek-karas <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This removes a static interface method from the list of
Overridesof the implementation method. Since the interface method is removed as an override, it will not mark the interface method by default. However, if the interface method is called through the interface on a constrained type parameter (T.StaticInterfaceMethodImplementation() where T: IInterfaceWithStaticMethod).Note we have to completely remove the interface method from the list of overrides. If we only skip the override from the marking, Cecil will fail to write the assembly because the overridden method can't be found anywhere.