File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
src/ILLink.RoslynAnalyzer
test/Mono.Linker.Tests.Cases/RequiresCapability Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -172,10 +172,10 @@ public override void Initialize (AnalysisContext context)
172172 for ( int i = 0 ; i < typeParams . Length ; i ++ ) {
173173 var typeParam = typeParams [ i ] ;
174174 var typeArg = typeArgs [ i ] ;
175- if ( ! typeParam . HasConstructorConstraint )
175+ if ( ! typeParam . HasConstructorConstraint ||
176+ typeArg is not INamedTypeSymbol { InstanceConstructors : { } typeArgCtors } )
176177 continue ;
177178
178- var typeArgCtors = ( ( INamedTypeSymbol ) typeArg ) . InstanceConstructors ;
179179 foreach ( var instanceCtor in typeArgCtors ) {
180180 if ( instanceCtor . Arity > 0 )
181181 continue ;
Original file line number Diff line number Diff line change 1- // Licensed to the .NET Foundation under one or more agreements.
1+ // Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
44using System ;
@@ -748,9 +748,13 @@ public static void GenericTypeWithStaticMethodViaLdftn ()
748748 var _ = new Action ( GenericWithStaticMethod < TestType > . GenericTypeWithStaticMethodWhichRequires ) ;
749749 }
750750
751+ static T MakeNew < T > ( ) where T : new ( ) => new T ( ) ;
752+ static T MakeNew2 < T > ( ) where T : new ( ) => MakeNew < T > ( ) ;
753+
751754 public static void Test ( )
752755 {
753756 GenericTypeWithStaticMethodViaLdftn ( ) ;
757+ MakeNew2 < TestType > ( ) ;
754758 }
755759 }
756760
You can’t perform that action at this time.
0 commit comments