[Mono-dev] Covariance, contravariance and name hiding

east_dude sakno at technovation.ru
Mon Feb 21 04:04:39 EST 2011


Hi!
I have the following code:
===begin source code===
interface InterfaceWithCovariance<out TException>
where TException: Exception
{
	TException Error { get; }
}
interface InterfaceWithContravariance<in TException>:
InterfaceWithCovariance<Exception>
where TException : Exception
{
	new TException Error{set;}
}
===end source code===
Microsoft csc.exe compiles this code successfully, because Error  property
from InterfaceWithCovariance is get_Error method, and Error property from
InterfaceWithContravariance is set_Error method. But Mono compiler emits the
following error:
The contravariant type parameter `TException' must be covariantly valid on
`ClassLibrary1.InterfaceWithContravariance<TException>.Error' (CS1961)
I think, this error is occured because compiler use property name when
analyze covariance/contravariance instead of property accessor method.

Thanks.
-- 
View this message in context: http://mono.1490590.n4.nabble.com/Covariance-contravariance-and-name-hiding-tp3317012p3317012.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list