File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
csharp/ql/test/library-tests Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -588,3 +588,33 @@ void Run<T>(T c) where T : I3<T>
588588 c . M13 ( ) ;
589589 }
590590}
591+
592+ public class C21
593+ {
594+ public interface I
595+ {
596+ void M ( ) ;
597+ }
598+
599+ public class A1 : I
600+ {
601+ public void M ( ) { }
602+ }
603+
604+ public ref struct A2 : I
605+ {
606+ public void M ( ) { }
607+ }
608+
609+ public void Run1 < T > ( T t ) where T : I
610+ {
611+ // Viable callable: A1.M() [also reports A2.M(); false positive]
612+ t . M ( ) ;
613+ }
614+
615+ public void Run2 < T > ( T t ) where T : I , allows ref struct
616+ {
617+ // Viable callable: {A1, A2}.M()
618+ t . M ( ) ;
619+ }
620+ }
Original file line number Diff line number Diff line change @@ -48,3 +48,11 @@ public class NestedC<T12> { }
4848 Nested < int > . NestedB . NestedC < bool > x5 ;
4949 Nested < string > . NestedB . NestedC < decimal > x6 ;
5050}
51+
52+ interface I2 { }
53+ struct S3 : I2 { }
54+ ref struct RS : I2 { }
55+ class C7 : I2 { }
56+
57+ class NormalConstraint < T > where T : I2 { } // False positive: Allows T to be `RS`.
58+ class NegativeConstraint < T > where T : I2 , allows ref struct { }
You can’t perform that action at this time.
0 commit comments