-
Notifications
You must be signed in to change notification settings - Fork 128
Re-add static interface trimming with more testing #2791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
f704291
68c530d
97cd617
8190bf7
9a5fe0f
3a560d4
733bf90
47104d9
c2f4fd1
3d577ce
8ac16bb
cccca4c
c380027
4813047
332e79f
9f64a32
9d27c3b
7f1064d
15db395
1751697
b10cd5f
e3fbf12
098cb24
7467d82
4efa5f2
c3a26ca
62e3cc8
4359792
060345e
a050fdf
95df541
2b7a7cc
c00e1d1
358b010
5672f0f
432375d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -575,6 +575,10 @@ void ProcessVirtualMethods () | |
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Does extra handling of marked types that have interfaces when it's necessary to know what types are marked or instantiated. | ||
| /// e.g. Marks the "implements interface" annotations and removes override annotations for static interface methods. | ||
| /// </summary> | ||
| void ProcessMarkedTypesWithInterfaces () | ||
| { | ||
| // We may mark an interface type later on. Which means we need to reprocess any time with one or more interface implementations that have not been marked | ||
|
|
@@ -3017,8 +3021,18 @@ protected virtual void ProcessMethod (MethodDefinition method, in DependencyInfo | |
| } | ||
| } | ||
|
|
||
| // Mark overridden methods except for static interface methods | ||
| if (method.HasOverrides) { | ||
| foreach (MethodReference ov in method.Overrides) { | ||
| // Method implementing a static interface method will have an override to it - note nonstatic methods usually don't unless they're explicit. | ||
| // Calling the implementation method directly has no impact on the interface, and as such it should not mark the interface or its method. | ||
| // Only if the interface method is referenced, then all the methods which implemented must be kept, but not the other way round. | ||
| if (Context.Resolve (ov)?.IsStatic == true | ||
| && Context.Resolve (ov.DeclaringType)?.IsInterface == true | ||
| // Public methods can be called directly on the type. If it non-public it is an explicit implementation and if the method is marked we need to mark the override. | ||
| && method.IsPublic) { | ||
|
||
| continue; | ||
| } | ||
| MarkMethod (ov, new DependencyInfo (DependencyKind.MethodImplOverride, method), ScopeStack.CurrentScope.Origin); | ||
| MarkExplicitInterfaceImplementation (method, ov); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using System; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace ILLink.RoslynAnalyzer.Tests.Inheritance.Interfaces | ||
| { | ||
| public sealed partial class StaticInterfaceMethodsTests : LinkerTestBase | ||
| { | ||
|
|
||
| protected override string TestSuiteName => "Inheritance.Interfaces.StaticInterfaceMethods"; | ||
|
|
||
| [Fact] | ||
| public Task StaticAbstractInterfaceMethods () | ||
| { | ||
| return RunTest (allowMissingWarnings: true); | ||
jtschuster marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| [Fact] | ||
| public Task StaticAbstractInterfaceMethodsLibrary () | ||
| { | ||
| return RunTest (allowMissingWarnings: true); | ||
| } | ||
|
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.