clr array covariance?
Posted: Fri Jun 05, 2009 5:11 pm
Is this not meant to work with cobra?
the following c# sample works ok, and c# 4 supports co-contra variance
I'm not sure of the implications for other backends or implementation, but for csharp it seems to be the right thing to do
class Sample
shared
def main
Sample.foo = @[Bar(), Bar()]
print Sample.foo
var foo as IFoo*?
interface IFoo
pass
class Bar
implements IFoo
pass
the following c# sample works ok, and c# 4 supports co-contra variance
- Code: Select all
using System;
using System.Collections.Generic;
public class Sample{
public static void Main(){
foo = new[] {new Bar{}, new Bar{}};
Console.WriteLine(foo);
}
static IEnumerable<IFoo> foo;
}
interface IFoo{}
class Bar : IFoo{}
I'm not sure of the implications for other backends or implementation, but for csharp it seems to be the right thing to do