diff options
author | Vitek Karas <10670590+vitek-karas@users.noreply.github.com> | 2022-08-08 17:19:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 17:19:25 +0300 |
commit | b6920a953e03ed6e01c159730c699bf228615f4d (patch) | |
tree | 8ffa39e0943bfd426da2bf5ea8c069879f3cf15d | |
parent | 4d524405b20345fb269e46ef2078e27acf26a127 (diff) |
Aot to linker sync (#2944)
Sync tweaks necessary for the linker/AOT integration
11 files changed, 39 insertions, 17 deletions
diff --git a/src/ILLink.Shared/DataFlow/MaybeLattice.cs b/src/ILLink.Shared/DataFlow/MaybeLattice.cs index 30d279054..f2b43d9de 100644 --- a/src/ILLink.Shared/DataFlow/MaybeLattice.cs +++ b/src/ILLink.Shared/DataFlow/MaybeLattice.cs @@ -2,6 +2,9 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +// This is needed due to NativeAOT which doesn't enable nullable globally yet +#nullable enable + namespace ILLink.Shared.DataFlow { // Wrapper for Nullable<T> which implements IEquatable so that this may diff --git a/src/ILLink.Shared/TrimAnalysis/HandleCallAction.cs b/src/ILLink.Shared/TrimAnalysis/HandleCallAction.cs index 12d43c74f..b8f360782 100644 --- a/src/ILLink.Shared/TrimAnalysis/HandleCallAction.cs +++ b/src/ILLink.Shared/TrimAnalysis/HandleCallAction.cs @@ -783,7 +783,7 @@ namespace ILLink.Shared.TrimAnalysis // Nothing to do - this throws at runtime AddReturnValue (MultiValueLattice.Top); } else if (typeNameValue is ValueWithDynamicallyAccessedMembers valueWithDynamicallyAccessedMembers && valueWithDynamicallyAccessedMembers.DynamicallyAccessedMemberTypes != 0) { - // Propagate the annotation from the type name to the return value. Annotation on a string value will be fullfilled whenever a value is assigned to the string with annotation. + // Propagate the annotation from the type name to the return value. Annotation on a string value will be fulfilled whenever a value is assigned to the string with annotation. // So while we don't know which type it is, we can guarantee that it will fulfill the annotation. AddReturnValue (_annotations.GetMethodReturnValue (calledMethod, valueWithDynamicallyAccessedMembers.DynamicallyAccessedMemberTypes)); } else { @@ -1178,7 +1178,7 @@ namespace ILLink.Shared.TrimAnalysis if (!methodReturnValueWithMemberTypes.DynamicallyAccessedMemberTypes.HasFlag (annotatedMethodReturnValue.DynamicallyAccessedMemberTypes)) throw new InvalidOperationException ($"Internal linker error: in {GetContainingSymbolDisplayName ()} processing call to {calledMethod.GetDisplayName ()} returned value which is not correctly annotated with the expected dynamic member access kinds."); } else if (uniqueValue is SystemTypeValue) { - // SystemTypeValue can fullfill any requirement, so it's always valid + // SystemTypeValue can fulfill any requirement, so it's always valid // The requirements will be applied at the point where it's consumed (passed as a method parameter, set as field value, returned from the method) } else if (uniqueValue == NullValue.Instance) { // NullValue can fulfill any requirements because reflection access to it will typically throw. diff --git a/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs b/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs index 02a512806..56d554989 100644 --- a/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs +++ b/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs @@ -227,7 +227,7 @@ namespace Mono.Linker.Dataflow case IntrinsicId.Type_GetNestedType: case IntrinsicId.Nullable_GetUnderlyingType: case IntrinsicId.Expression_Property when calledMethod.HasParameterOfType (1, "System.Reflection.MethodInfo"): - case var fieldOrPropertyInstrinsic when fieldOrPropertyInstrinsic == IntrinsicId.Expression_Field || fieldOrPropertyInstrinsic == IntrinsicId.Expression_Property: + case var fieldOrPropertyIntrinsic when fieldOrPropertyIntrinsic == IntrinsicId.Expression_Field || fieldOrPropertyIntrinsic == IntrinsicId.Expression_Property: case IntrinsicId.Type_get_BaseType: case IntrinsicId.Type_GetConstructor: case IntrinsicId.MethodBase_GetMethodFromHandle: @@ -354,7 +354,7 @@ namespace Mono.Linker.Dataflow // For all other cases, the linker would have already produced a warning. default: - throw new NotImplementedException ("Unhandled instrinsic"); + throw new NotImplementedException ("Unhandled intrinsic"); } // If we get here, we handled this as an intrinsic. As a convenience, if the code above @@ -372,7 +372,7 @@ namespace Mono.Linker.Dataflow if (!methodReturnValueWithMemberTypes.DynamicallyAccessedMemberTypes.HasFlag (annotatedMethodReturnValue.DynamicallyAccessedMemberTypes)) throw new InvalidOperationException ($"Internal linker error: processing of call from {callingMethodDefinition.GetDisplayName ()} to {calledMethod.GetDisplayName ()} returned value which is not correctly annotated with the expected dynamic member access kinds."); } else if (uniqueValue is SystemTypeValue) { - // SystemTypeValue can fullfill any requirement, so it's always valid + // SystemTypeValue can fulfill any requirement, so it's always valid // The requirements will be applied at the point where it's consumed (passed as a method parameter, set as field value, returned from the method) } else { throw new InvalidOperationException ($"Internal linker error: processing of call from {callingMethodDefinition.GetDisplayName ()} to {calledMethod.GetDisplayName ()} returned value which is not correctly annotated with the expected dynamic member access kinds."); diff --git a/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Inheritance.Interfaces.StaticInterfaceMethodsTests.g.cs b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Inheritance.Interfaces.StaticInterfaceMethodsTests.g.cs new file mode 100644 index 000000000..472da5e89 --- /dev/null +++ b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Inheritance.Interfaces.StaticInterfaceMethodsTests.g.cs @@ -0,0 +1,17 @@ +using System; +using System.Threading.Tasks; +using Xunit; + +namespace ILLink.RoslynAnalyzer.Tests.Inheritance.Interfaces +{ + public sealed partial class StaticInterfaceMethodsTests : LinkerTestBase + { + + [Fact] + public Task BaseProvidesInterfaceMethod () + { + return RunTest (allowMissingWarnings: true); + } + + } +}
\ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AttributeConstructorDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AttributeConstructorDataflow.cs index f6747be82..866af4714 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/AttributeConstructorDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/AttributeConstructorDataflow.cs @@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [KeepsPublicFields (null, null)] [TypeArray (new Type[] { typeof (AttributeConstructorDataflow) })] // Trimmer only for now - https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Main () { typeof (AttributeConstructorDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorAttribute)); diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AttributeFieldDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AttributeFieldDataflow.cs index 01fa19c20..80d182b03 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/AttributeFieldDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/AttributeFieldDataflow.cs @@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [KeepsPublicFields (Type = null, TypeName = null)] [TypeArray (Types = new Type[] { typeof (AttributeFieldDataflow) })] // Trimmer only for now - https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Main () { typeof (AttributeFieldDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index a944bb742..4df62b350 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [KeepsPublicFields (Type = null, TypeName = null)] [TypeArray (Types = new Type[] { typeof (AttributePropertyDataflow) })] // Trimmer only for now - https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Main () { typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs index f5df5af81..348fea697 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs @@ -180,8 +180,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow [Kept] // https://github.com/dotnet/linker/issues/2874 - [ExpectedWarning ("IL2069", ProducedBy = ProducedBy.Trimmer)] - [ExpectedWarning ("IL2069", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2069", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] + [ExpectedWarning ("IL2069", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Test () { TwoOutRefs (out _publicMethodsField, out _publicPropertiesField); diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedCodeDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedCodeDataflow.cs index 6a3549c7e..abed4646c 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedCodeDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedCodeDataflow.cs @@ -95,7 +95,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow public static void Test () { - FlowAcrossYieldReturn (); + FlowAcrossYieldReturn ().GetEnumerator ().MoveNext (); // Has to call MoveNext otherwise AOT will actually remove it NoFlowAcrossYieldReturn (); NoFlowAcrossYieldReturn (); UseParameterBeforeYieldReturn (); diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedTypes.cs b/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedTypes.cs index b6958827a..f99a80b20 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedTypes.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedTypes.cs @@ -10,6 +10,8 @@ using Mono.Linker.Tests.Cases.Expectations.Assertions; namespace Mono.Linker.Tests.Cases.DataFlow { +#pragma warning disable CS4014 // async call is not awaited + [ExpectedNoWarnings] [SkipKeptItemsValidation] public class CompilerGeneratedTypes diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs index ef58eac31..4e2998d23 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs @@ -91,7 +91,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [ExpectedWarning ("IL2057", nameof (GetType))] static void TestUnknownType () { - Type type = Type.GetType (GetStringUnkownType ()); + Type type = Type.GetType (GetStringUnknownType ()); } [ExpectedWarning ("IL2072", nameof (DataFlowTypeExtensions.RequiresPublicConstructors))] @@ -155,7 +155,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow typeName = "Mono.Linker.Tests.Cases.DataFlow.GetTypeDataFlow"; break; case 3: - typeName = GetStringUnkownType (); + typeName = GetStringUnknownType (); break; } @@ -171,8 +171,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow public void Method2 () { } // https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2026", "--Method1--", ProducedBy = ProducedBy.Trimmer)] - [ExpectedWarning ("IL2026", "--Method2--", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2026", "--Method1--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] + [ExpectedWarning ("IL2026", "--Method2--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Test () { Type.GetType ("Mono.Linker.Tests.Cases.DataFlow." + nameof (GetTypeDataFlow) + "+" + nameof (TypeWithWarnings)).RequiresPublicMethods (); @@ -187,7 +187,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow public void Method1 () { } // https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2026", "--Method1--", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2026", "--Method1--", ProducedBy = ProducedBy.Trimmer | ProducedBy.NativeAot)] public static void Test () { Type.GetType (s_ConstTypeName).RequiresPublicMethods (); @@ -212,7 +212,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow return null; } - private static string GetStringUnkownType () + private static string GetStringUnknownType () { return null; } |