File tree 2 files changed +38
-0
lines changed
csharp/ql/test/library-tests
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -575,3 +575,33 @@ void Run<T>(T c) where T : I3<T>
575
575
c . M13 ( ) ;
576
576
}
577
577
}
578
+
579
+ public class C21
580
+ {
581
+ public interface I
582
+ {
583
+ void M ( ) ;
584
+ }
585
+
586
+ public class A1 : I
587
+ {
588
+ public void M ( ) { }
589
+ }
590
+
591
+ public ref struct A2 : I
592
+ {
593
+ public void M ( ) { }
594
+ }
595
+
596
+ public void Run1 < T > ( T t ) where T : I
597
+ {
598
+ // Viable callable: A1.M() [also reports A2.M(); false positive]
599
+ t . M ( ) ;
600
+ }
601
+
602
+ public void Run2 < T > ( T t ) where T : I , allows ref struct
603
+ {
604
+ // Viable callable: {A1, A2}.M()
605
+ t . M ( ) ;
606
+ }
607
+ }
Original file line number Diff line number Diff line change @@ -48,3 +48,11 @@ public class NestedC<T12> { }
48
48
Nested < int > . NestedB . NestedC < bool > x5 ;
49
49
Nested < string > . NestedB . NestedC < decimal > x6 ;
50
50
}
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