Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Boemer <sbomer@gmail.com>2022-02-24 23:23:41 +0300
committerGitHub <noreply@github.com>2022-02-24 23:23:41 +0300
commite9cfb5413a6a7a7b5bfc3b9a73671be2b18642cf (patch)
treed586fc27196a0d8ddf916cab704f74ccc55dae03
parent74d69676a9b4fa7022f8bdaf5a574e7063d8c9a1 (diff)
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs6
2 files changed, 7 insertions, 3 deletions
diff --git a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
index d52bc04bd..aff22c907 100644
--- a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
+++ b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
@@ -172,10 +172,10 @@ namespace ILLink.RoslynAnalyzer
for (int i = 0; i < typeParams.Length; i++) {
var typeParam = typeParams[i];
var typeArg = typeArgs[i];
- if (!typeParam.HasConstructorConstraint)
+ if (!typeParam.HasConstructorConstraint ||
+ typeArg is not INamedTypeSymbol { InstanceConstructors: { } typeArgCtors })
continue;
- var typeArgCtors = ((INamedTypeSymbol) typeArg).InstanceConstructors;
foreach (var instanceCtor in typeArgCtors) {
if (instanceCtor.Arity > 0)
continue;
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
index 482ff2de1..cc5f3b373 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
@@ -748,9 +748,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
var _ = new Action (GenericWithStaticMethod<TestType>.GenericTypeWithStaticMethodWhichRequires);
}
+ static T MakeNew<T> () where T : new() => new T ();
+ static T MakeNew2<T> () where T : new() => MakeNew<T> ();
+
public static void Test ()
{
GenericTypeWithStaticMethodViaLdftn ();
+ MakeNew2<TestType> ();
}
}