2020-08-04 10:30:25 -07:00
#pragma warning disable 168
2020-06-21 07:50:37 -07:00
using System ;
2021-01-20 06:42:44 -08:00
using System.Collections ;
2020-06-21 07:50:37 -07:00
2020-08-04 10:30:25 -07:00
namespace System
{
extension Array1 < T >
{
2021-01-04 13:57:28 -08:00
public static Self operator + ( Self lhs , Self rhs ) where T : IDisposable
2020-08-04 10:30:25 -07:00
{
2021-01-04 13:57:28 -08:00
return lhs ;
2020-08-04 10:30:25 -07:00
}
}
}
2020-06-21 07:50:37 -07:00
namespace IDETest
{
class Generics
{
public void Method1 < T > ( T val ) where T : Array
{
}
public void Method2 < T , T2 > ( T val , T2 val2 )
{
Method1 ( val2 ) ; //FAIL 'T', declared to be 'T2'
}
2020-08-04 10:30:25 -07:00
public void Method3 < TFoo > ( ref TFoo [ ] val )
{
2021-01-04 13:57:28 -08:00
var res = val + val ; //FAIL
2020-08-04 10:30:25 -07:00
}
2021-01-04 13:57:28 -08:00
public void Method4 < TFoo > ( ref TFoo [ ] val ) where TFoo : IDisposable
2020-08-04 10:30:25 -07:00
{
2021-01-04 13:57:28 -08:00
var res = val + val ;
2020-08-04 10:30:25 -07:00
}
2020-09-19 05:12:15 -07:00
interface IFaceA < T >
{
public void MethodA < M1 > ( T val , M1 val2 , delegate T ( M1 arg ) val3 ) ;
}
class ClassA < T1 , T2 > : IFaceA < ( T1 , T2 ) > //FAIL 'IDETest.Generics.ClassA<T1, T2>' does not implement interface member 'IDETest.Generics.IFaceA<(T1, T2)>.MethodA<M1>((T1, T2) val, M1 val2, delegate (T1, T2)(M1 arg) val3)'
{
void MethodA < M > ( int a )
{
}
void MethodB ( )
{
2021-12-15 17:06:43 -05:00
function void ( ) f = = > MethodA < T2 > ; //FAIL Method 'void IDETest.Generics.ClassA<T1, T2>.MethodA<T2>(int a)' does not match function 'function void()'
2020-09-19 05:12:15 -07:00
}
}
2021-01-20 06:42:44 -08:00
static void Method5 < A , B > ( ) where A : IEnumerable < B >
{
}
static void Method6 < C , D , E , F > ( )
{
Method5 < E , F > ( ) ; //FAIL Generic argument 'A', declared to be 'E' for 'IDETest.Generics.Method5<E, F>()', must implement 'System.Collections.IEnumerable<F>'
}
2021-01-20 14:47:29 -08:00
interface IFaceB < T >
{
void MethodA0 ( ) ;
}
extension IFaceB < T >
{
void MethodA1 ( ) ;
}
class ClassB < T > : IFaceB < T > //FAIL 'IDETest.Generics.ClassB<T>' does not implement interface member 'IDETest.Generics.IFaceB<T>.MethodA0()'
{
}
extension ClassB < T >
{
}
2021-06-25 06:04:48 -07:00
public static void TestGen < T , TItem > ( T val )
where T : IEnumerator < TItem >
where TItem : var
{
Console . WriteLine ( typeof ( decltype ( val ) ) . ToString ( . . scope . ( ) ) ) ;
}
public static void TestPreGen < T > ( )
{
T a = default ;
TestGen ( a ) ; //FAIL Unable to determine generic argument 'TItem'
}
2022-02-12 15:37:57 -05:00
static void Method7 < T > ( ) where T : var where comptype ( typeof ( T ) ) : class
{
}
2021-06-25 06:04:48 -07:00
public static void TestGenBug ( )
{
TestPreGen < List < int > > ( ) ;
2022-02-12 15:37:57 -05:00
Method7 < int > ( ) ; //FAIL The type 'int' must be a reference type in order to use it as parameter 'comptype(typeof(T))' for 'IDETest.Generics.Method7<int>()'
2021-06-25 06:04:48 -07:00
}
2022-04-25 17:53:54 -07:00
public static void CircDepMethod < T , T2 > ( ) where T : T2 where T2 : T //FAIL
{
}
class CircDep < T > where T : T //FAIL
{
}
2022-06-23 13:55:34 -07:00
public class TestExt < T > where T : struct
{
public struct InnerA
{
}
public struct InnerB < T2 > where T2 : struct
{
}
}
extension TestExt < T >
where T : Int
{
public int a = 0 ;
public struct InnerC
{
}
}
static void TestExtMethod ( )
{
TestExt < String > . InnerA a ; //FAIL
TestExt < String > . InnerB < int > b ; //FAIL
TestExt < int > . InnerB < int > c ;
TestExt < int > . InnerC d ;
TestExt < float > . InnerC e ; //FAIL
}
2020-06-21 07:50:37 -07:00
}
}
2022-04-25 17:53:54 -07:00
namespace System.Collections
{
extension List < T > //FAIL
where T : T
{
}
}