Commit Graph
48 Commits
Author SHA1 Message Date
Scott Thomas a8b8e5b253 Contributed under the MIT/X11 license. This patch cleans up some
generic variance code and fixes the variance rules. The spec,
SURPRISE SURPRISE, is totally wrong about variance rules. Luckily,
we figured out how it really ought to be. Also added some new
error tests and three new regular tests which are on the ignore
list for now until VM support lands.


svn path=/trunk/mcs/; revision=126062
2009-02-06 16:20:09 +00:00
Scott Thomas b254c9e9e9 This commit adds generic variance support under the new
"future" langversion. Variance is allowed in interface
and delegate types. Covariant type parameters are denoted
with the "out" keyword like so:

interface IFoo<out T> {
    T Bar { get; }
}

And contravariant type parameters are dentoed with the
"in" keyword, like so:

delegate void Bar<in T> (T input);

Covariant type parameters can only be used as method
return types and type arguments for inherited
interfaces. Contravariant type parameters can only be
used as by-value method parameter types.

Only reference type are variant.

!!!IT SHOULD BE NOTED!!!
That the Mono VM does not yet fully support generic
type variance, so variant code compiled with this
feature will not run on Mono until variance support
is complete. Code compiled with this feature will run
on the .NET 2.0 virtual machine.

This patch is contributed under the MIT/X11 license.


svn path=/trunk/mcs/; revision=125647
2009-02-04 04:22:19 +00:00
Miguel de Icaza 210e65acef Add
svn path=/trunk/mcs/; revision=83913
2007-08-12 15:59:15 +00:00
Marek Safar 99ad213831 Revert some Miguel's weirdness
svn path=/trunk/mcs/; revision=81935
2007-07-13 10:24:52 +00:00
Miguel de Icaza 9391ca5349 Add new test csae for bug 82080
svn path=/trunk/mcs/; revision=81926
2007-07-13 06:16:38 +00:00
Raja R Harinath 1b63b6b974 In mcs:
* typemanager.cs (IsOverride, RegisterNonOverride): New.
	* decl.cs (MemberCache.AddMethod): Register "non-override" methods
	that used to trigger warning -28.  Remove warning -28.
	* expression.cs (Invocation.OverloadResolve): Use
	TypeManager.IsOverride to distinguish override methods.

In errors:
	* errors.txt (warning -28): Remove.

svn path=/trunk/mcs/; revision=43921
2005-05-03 11:39:55 +00:00
Miguel de Icaza b017fdde76 This was a duplicated error test with 368, update to test something new
svn path=/trunk/mcs/; revision=43303
2005-04-19 23:53:17 +00:00
Miguel de Icaza 6cae4e5b52 Add new negative test case
svn path=/trunk/mcs/; revision=43125
2005-04-16 19:28:59 +00:00
Raja R Harinath 22c7174256 In mcs:
Fix #47991.  Remove a TODO.
	* statement.cs (Block.Toplevel): Make into a field.
	(Block.Parameters): Move into ToplevelBlock.
	(Block.known_variables): Rename from child_variable_names.
	(Block.Block): Remove variants that take Parameters.  Initialize
	'Toplevel' with the immediately surrounding toplevel block.
	(Block.AddKnownVariable): Rename from AddChildVariableName.  Add a
	LocalInfo parameter.
	(Block.GetKnownVariableInfo): New.
	(Block.IsVariableNameUsedInChildBlock): Update.
	(Block.IsVariableNameUsedInBlock): New.  Checks if a name is used in
	the block, even though it may not be in scope.
	(Block.AddVariable): Remove Parameters parameter.  Use
	Toplevel.Parameters instead.
	(Block.AddConstant): Remove Parameters parameter.
	(Block.GetParameterReference): Update to use Toplevel.Parameters.
	(Block.IsParamaterReference): Likewise.
	(Block.IsLocalParameter): Likewise.  Simplify a lot.
	(ToplevelBlock.Parameters): New.  Moved from Block.
	(ToplevelBlock.ToplevelBlock): Update to changes.  Always
	initialize Parameters to a non-null value.
	* cs-parser.jay: Update to changes.
	* ecore.cs (SimpleName.SimpleNameResolve): Emit cs0136 error for
	simple names that mean different things in the same block.  Use
	Block.IsVariableNameUsedInBlock.

In errors:
	* cs0136-3.cs, cs0136-4.cs: New tests from #47991.

svn path=/trunk/mcs/; revision=42330
2005-03-29 12:27:05 +00:00
Raja R Harinath 0a24c89f13 Misc. 'make distcheck' fixes.
In tools:
	* Makefile (run-test-ondotnet-local, uninstall-local): New.

In tests:
	* Makefile (DISTFILES): Distribute *.inc files too.
	(with_mono_path): New.
	(casts.cs, boot-casts.out, mcs-casts.out): Use it.

In jay:
	* Makefile (uninstall-local): Remove $(prefix)/man/man1/jay.1.

In build:
	* executable.make (uninstall-local): Remove .config file too.
	* library.make (uninstall-local): Don't error out if GACUTIL fails.

In errors:
	* Makefile (DISTFILES): Add expected error and ignored test lists.

svn path=/trunk/mcs/; revision=37308
2004-12-07 10:29:43 +00:00
Miguel de Icaza d37940b471 Flush
svn path=/trunk/mcs/; revision=31874
2004-08-04 16:59:58 +00:00
Miguel de Icaza 4181b234fd Update error list
svn path=/trunk/mcs/; revision=22631
2004-01-31 03:49:33 +00:00
Martin Baulig 6be85f7860 Added "-220 Cannot resolve constructed type".
svn path=/trunk/mcs/; revision=19381
2003-10-25 15:02:35 +00:00
Martin Baulig 2a2f5be822 2003-09-22 Martin Baulig <[email protected]>
* errors.txt: Added -219.

svn path=/trunk/mcs/; revision=18253
2003-09-22 00:10:14 +00:00
Martin Baulig 8a719f24be Added -218 invalid contraints clause.
svn path=/trunk/mcs/; revision=18112
2003-09-15 19:27:45 +00:00
Martin Baulig 1596d9b64f Added error -217.
svn path=/trunk/mcs/; revision=17974
2003-09-07 16:09:16 +00:00
Martin Baulig 8add181d95 2003-09-06 Martin Baulig <[email protected]>
* errors.txt: Added -216.

svn path=/trunk/mcs/; revision=17946
2003-09-06 18:15:29 +00:00
Miguel de Icaza efb4c1c4e8 Update errors
svn path=/trunk/mcs/; revision=17819
2003-09-02 01:51:41 +00:00
Miguel de Icaza 0b607733bd Add more errors
svn path=/trunk/mcs/; revision=16452
2003-07-20 19:03:14 +00:00
Miguel de Icaza 14b9548f8a update
svn path=/trunk/mcs/; revision=15035
2003-05-31 19:13:17 +00:00
Miguel de Icaza 4a6f5ee0ee Flush
svn path=/trunk/mcs/; revision=14134
2003-04-30 04:15:07 +00:00
Miguel de Icaza 176b8768a9 Archive these files from my generics tree
svn path=/trunk/mcs/; revision=13905
2003-04-22 21:30:45 +00:00
Miguel de Icaza c3d9e2920e Add new error
svn path=/trunk/mcs/; revision=13840
2003-04-21 06:16:36 +00:00
Miguel de Icaza 20a2b89c9a Add another test file
svn path=/trunk/mcs/; revision=11707
2003-02-18 23:26:15 +00:00
Miguel de Icaza 2a1ea43f4f Flush
svn path=/trunk/mcs/; revision=10434
2003-01-12 19:08:20 +00:00
Ravi Pratap M 01714dfb49 2002-12-18 Ravi Pratap <[email protected]>
* errors.txt : Update for error # -24.

svn path=/trunk/mcs/; revision=9753
2002-12-19 00:23:25 +00:00
Miguel de Icaza 76f71ea43b Add decimal to MakeByteBlob
svn path=/trunk/mcs/; revision=7564
2002-09-17 18:16:08 +00:00
Miguel de Icaza 51853f78b0 Update errors
svn path=/trunk/mcs/; revision=7343
2002-09-09 21:46:41 +00:00
Miguel de Icaza e4a0c81e0a Document error
svn path=/trunk/mcs/; revision=4939
2002-05-26 01:48:01 +00:00
Miguel de Icaza accf672c09 New error test
svn path=/trunk/mcs/; revision=4922
2002-05-24 21:43:18 +00:00
Miguel de Icaza 3cd86625e7 2002-05-17 Miguel de Icaza <[email protected]>
* ecore.cs (ExplicitReferenceConversionExists): Made public.
	(ImplicitReferenceConversionExists): Split out from
	StandardConversionExists.

	* expression.cs (As): We were only implementing one of the three
	cases for the as operator.  We now implement them all.
	(Is): Implement the various other cases for Is as well.

	* typemanager.cs (CACHE): New define used to control if we want or
	not the FindMembers cache.  Seems to have a negative impact on
	performance currently

	(MemberLookup): Nested types have full acess to
	enclosing type members

	Remove code that coped with instance/static returns for events, we
	now catch this in RealFindMembers.

	(RealFindMembers): only perform static lookup if the instance
	lookup did not return a type or an event.

svn path=/trunk/mcs/; revision=4724
2002-05-17 20:13:44 +00:00
Ravi Pratap M 8ea6a01db9 Add
svn path=/trunk/mcs/; revision=3788
2002-04-12 18:25:13 +00:00
Miguel de Icaza fb55f6cfdf 2002-03-25 Miguel de Icaza <[email protected]>
* IntPtr.cs: Temporary work-around until I fix the assembly
	attributes bug.

	* String.cs (System): Removed enumeration, because it is pretty
	hard to support enumerations in /nostdlib mode for the core types.

2002-03-25  Miguel de Icaza  <[email protected]>

	* interface.cs: Implement the same search algorithm for types in
	the interface code.

	* delegate.cs: Do not allow multiple definition.

svn path=/trunk/mcs/; revision=3335
2002-03-25 22:17:41 +00:00
Miguel de Icaza ce9115323c Updated errors
svn path=/trunk/mcs/; revision=3319
2002-03-25 03:04:43 +00:00
Miguel de Icaza 147f363081 Update error listing
svn path=/trunk/mcs/; revision=3172
2002-03-17 17:17:38 +00:00
Miguel de Icaza 961f0c0a1c Add new bug file to check; New test to excercise the enum bug that I just
fixed, plus:

2002-02-26  Miguel de Icaza  <[email protected]>

	* ecore.cs (Expression.ConvertExplicit): Bug fix, thanks for
	spotting this Paolo.

	(Expression.ImplicitNumericConversion): Perform comparissions of
	the type using the underlying type in the case of an enumeration
	rather than using the enumeration type for the compare.

	Cope with the underlying == type case, which is not possible to
	catch before.

	(Expression.ConvertNumericExplicit): Perform comparissions of
	the type using the underlying type in the case of an enumeration
	rather than using the enumeration type for the compare.

svn path=/trunk/mcs/; revision=2696
2002-02-26 21:12:07 +00:00
Miguel de Icaza a992519b96 Add indirection support, it was missing.
2002-02-20  Miguel de Icaza  <[email protected]>

	* expression.cs (Indirection): Implement EmitAssign and set the
	ExprClass to Variable.  This allows pointer dereferences to be
	treated as variables, and to have values assigned to them.

	* ecore.cs (Expression.StoreFromPtr): New utility function to
	store values dereferencing.

2002-02-20  Miguel de Icaza  <[email protected]>

	* unsafe-1.cs: Extend test.

svn path=/trunk/mcs/; revision=2549
2002-02-21 00:10:13 +00:00
Miguel de Icaza d43407f421 2002-02-17 Miguel de Icaza <[email protected]>
* expression.cs (Indirection): New helper class.  Unary will
	create Indirection classes to be able to implement the
	IMemoryLocation interface on it.

2002-02-16  Miguel de Icaza  <[email protected]>

	* cs-parser.jay (fixed_statement): reference the right statement.

	* statement.cs (Fixed.Emit): Finish implementing the fixed
	statement for the &x case.

svn path=/trunk/mcs/; revision=2517
2002-02-19 17:14:03 +00:00
Miguel de Icaza 177e4fbfaa 2002-01-16 Miguel de Icaza <[email protected]>
* statement.cs (For.Emit): If the test is null, then report that
	we do `return', as we wont reach anything afterwards.

	(Switch.SwitchGoverningType): Track the expression that matched
	the conversion.

	* driver.cs: Allow negative numbers as an error code to flag.

svn path=/trunk/mcs/; revision=2011
2002-01-16 22:26:59 +00:00
Miguel de Icaza 01f5ed5569 Add more error tests
svn path=/trunk/mcs/; revision=1462
2001-11-28 18:15:16 +00:00
Ravi Pratap M 8192342a2b Add files for delegate related errors.
svn path=/trunk/mcs/; revision=1173
2001-10-17 09:20:07 +00:00
Ravi Pratap M 85e3817a2f Update errors.txt for the new errors that only we catch.
svn path=/trunk/mcs/; revision=1040
2001-10-01 12:56:17 +00:00
Miguel de Icaza 66c78971d7 2001-09-27 Miguel de Icaza <[email protected]>
* expression.cs (LValue): Add new method AddressOf to be used by
	the `&' operator.

	Change the argument of Store to take an EmitContext instead of an
	ILGenerator, because things like FieldExpr need to be able to call
	their children expression to generate the instance code.

	(Expression::Error, Expression::Warning): Sugar functions for
	reporting errors.

	(Expression::MemberLookup): Accept a TypeContainer instead of a
	Report as the first argument.

	(Expression::ResolvePrimary): Killed.  I still want to improve
	this as currently the code is just not right.

	(Expression::ResolveMemberAccess): Simplify, but it is still
	wrong.

	(Unary::Resolve): Catch errors in AddressOf operators.

	(LocalVariableReference::Emit, ::Store, ::AddressOf): typecast
	index to a byte for the short-version, or the compiler will choose
	the wrong Emit call, which generates the wrong data.

	(ParameterReference::Emit, ::Store): same.

	(FieldExpr::AddressOf): Implement.

	* typemanager.cs: TypeManager: made public variable instead of
	property.

	* driver.cs: document --fatal.

	* report.cs (ErrorMessage, WarningMessage): new names for the old
	Error and Warning classes.

	* cs-parser.jay (member_access): Turn built-in access to types
	into a normal simplename

svn path=/trunk/mcs/; revision=1009
2001-09-27 17:36:55 +00:00
Miguel de Icaza 10ec700ce6 Update errors file
svn path=/trunk/mcs/; revision=761
2001-09-07 21:19:21 +00:00
Ravi Pratap M 3f3a2a5036 2001-09-02 Ravi Pratap <[email protected]>
* class.cs (Operator::CheckUnaryOperator): Correct error number used
	to make it coincide with MS' number.
	(Operator::CheckBinaryOperator): Ditto.

	* ../errors/errors.txt : Remove error numbers added earlier.

	* ../errors/cs1019.cs : Test case for error # 1019

	* ../errros/cs1020.cs : Test case for error # 1020

	* cs-parser.jay : Clean out commented cruft.
	(dimension_separators, dimension_separator): Comment out. Ostensibly not
	used anywhere - non-reducing rule.
	(namespace_declarations): Non-reducing rule - comment out.

	* enum.cs (Enum::AddEnum): Rename to AddEnumMember as I was getting confused
	with TypeContainer::AddEnum.

	* delegate.cs : New file for delegate handling classes.
	(Delegate): Class for declaring delegates.

	* makefile : Update.

	* cs-parser.jay (delegate_declaration): Implement.

svn path=/trunk/mcs/; revision=696
2001-09-02 15:37:11 +00:00
Ravi Pratap M 6b8008cfd9 2001-08-31 Ravi Pratap <[email protected]>
* cs-parser.jay (overloadable_operator): The semantic value is an
	enum of the Operator class.
	(operator_declarator): Implement actions.
	(operator_declaration): Implement.

	* class.cs (Operator::CheckUnaryOperator): New static method to help in checking
	validity of definitions.
	(Operator::CheckBinaryOperator): Static method to check for binary operators
	(TypeContainer::AddOperator): New method to add an operator to a type.

	* cs-parser.jay (indexer_declaration): Added line to actually call the
	AddIndexer method so it gets added ;-)

	* ../errors/errors.txt : Update to include new error numbers. Are these numbers
	already taken care of by the MS compiler ?

2001-08-29  Ravi Pratap  <[email protected]>

	* class.cs (Operator): New class for operator declarations.
	(Operator::OpType): Enum for the various operators.

svn path=/trunk/mcs/; revision=688
2001-08-31 03:35:11 +00:00
Miguel de Icaza 5c19abc1c6 Update errors listing
svn path=/trunk/mcs/; revision=481
2001-08-16 13:57:05 +00:00
Miguel de Icaza 773a66abc5 Initial revision
svn path=/trunk/mcs/; revision=2
2001-06-08 18:45:34 +00:00