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
"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
* flowanalysis.cs (VariableInfo.IsEverAssigned): New.
(VariableInfo.SetAssigned): Set it.
* statement.cs (Block.UsageWarning): Use 'IsEverAssigned' to
determine if CS0219 or CS0168 is appropriate. Don't use
flow-analysis information.
(Block.Resolve): Use ec.EndFlowBranching, not ec.DoEndFlowBranching.
* codegen.cs (EmitContext.DoEndFlowBranching): Kill. Inline into ...
(EmitContext.EndFlowBranching): ... this.
svn path=/trunk/mcs/; revision=99830
* mcs/enum.cs (EnumMember.Value): Only access 'value' if
ResolveValue says it's ok.
(EnumMember.DoResolveValue): Don't set prev_member.value.
(Enum.GetDefinition): Reverse arguments of Equals --
EnumMember.Value can return 'null'.
* errors/cs0152-3.cs: New testcase from #363791.
svn path=/trunk/mcs/; revision=96530
* Makefile (_boot_): Orchestrate the net_2_1 bootstrap.
(net_2_1_bootstrap_SUBDIRS, net_2_1_raw_SUBDIRS): New.
In build:
* profiles/net_2_1_bootstrap.make: New.
* profiles/net_2_1_raw.make: New. The untuned 2.1 profile.
* profiles/net_2_1.make: New. The tuned 2.1 profile.
* Makefile (PROFILES): Update.
In class:
* Makefile (net_3_5_dirs): Remove System.Xml.Linq, now that it's
built in the 2.0 profile.
In class/System:
* Makefile (CYCLIC_DEPS): New macro.
(CYCLIC_DEP_FILES): Use it to clean up handling of cyclic dependencies.
* net_2_1_raw_System.dll.sources: Rename from net_2_1_System.dll.sources.
* net_2_1_bootstrap_System.dll.sources: New.
In class/corlib:
* Makefile (LIBRARY_COMPILE) [net_2_1]: Remove special case.
In errors:
* Makefile: Enable testing net_2_1 profile.
In mcs:
* Makefile (GMCS_PROFILE): Remove.
(COMPILER_NAME): New helper.
In tests:
* Makefile: Enable smcs testing.
In tools:
* Makefile (net_2_1_raw_SUBDIRS): New.
In tools/compiler-tester:
* Makefile [PROFILE=net_2_1]: Copy file from net_2_1_raw profile.
* compiler-tester.cs: Work better with 'net_2_1' profiles.
In tools/tuner:
* Makefile: Improve. Update to new net_2_1 profiles. Specify
more dependencies. Do work only when necessary.
* Descriptors/smcs.xml: Add CompilerCallableEntryPoint.
svn path=/trunk/mcs/; revision=95989
byte array for unsigned "baked" assemblies.
* gcs0281.cs: Modified expected error message now that fix for bug
#315057 has been applied.
svn path=/trunk/mcs/; revision=92330
* mcs/ecore.cs (SimpleName.DoSimpleNameResolve): Handle Property and
Event accessibility checks here. Remove some bogus code that
accidently made GenericMethods work.
(PropertyExpr.IsAccessibleFrom, EventExpr.IsAccessibleFrom): New.
* tests/test-589.cs: Additional test for #328490.
* errors/cs0120-10.cs: New test based on #328490.
svn path=/trunk/mcs/; revision=86807
* doc.cs : catch other types of exception than XmlException to
report CS1570. Fixed bug #82565.
* cs1570-12.cs : new test (bug #82565).
svn path=/trunk/mcs/; revision=84780
* mcs/statement.cs (ToplevelBlock.ProcessParameters): Add parameter
names to the "known" variables list.
(Block.CheckInvariantMeaningInBlock): Handle the fact the
parameter names are also "known".
(Block.CheckError136): Remove.
(ExplicitBlock.CloneTo): New. Set 'known_variables' in target to null.
* errors/cs0135-2.cs, errors/cs0135-3.cs: New tests for parameter name
conflicts.
svn path=/trunk/mcs/; revision=78855
Revert r77431, and remove ChangeLog corruption introduced in
r77445
In errors:
Add new regression tests, and mark cs0158-5.cs as broken due
to the revert above.
I decided to break cs0158-5.cs and revert rather than fix the issues since
a correct fix will be very similar to what I'm planning to do for shadowed
variables (invariant meaning in a block).
svn path=/trunk/mcs/; revision=77549
compiling for Linq.
gmcs/cs-parser.jay: Improved grammar for object and collection
initialization.
mcs/assing.cs:
mcs/expression.cs: Improved object and collection initialization.
tests/gtest-initialize-02.cs: Added an uber-test for object and
collection initialization.
svn path=/trunk/mcs/; revision=77514
Fix regression in cs0631-3.cs
* cs-parser.jay (operator_declarator): Add opt_attributes to error
fallback. Make error fallback catch more cases.
In gmcs:
Fix regression in cs0631-3.cs
* cs-parser.jay (operator_declarator): Add opt_attributes to error
fallback. Make error fallback catch more cases.
In errors:
* cs1534-2.cs: New test. Ensure that the error handling isn't
limited to only erroneous 3-argument operators.
svn path=/trunk/mcs/; revision=76555
* mcs/statement.cs (For.Resolve): If resolution fails, use KillFlowBranching.
* errors/cs0103-5.cs: New test based on #81338.
svn path=/trunk/mcs/; revision=75536
In mcs :
* class.cs:
Added 2 MemberCoreArrayList objects, ordered_explicit_member_list and
ordered_member_list, to TypeBuilder to store members to be defined
in the order they were parsed in.
- ordered_explicit_member_list contains all properties indexers
and methods that are defined as explicit implementation of an
interface or base class.
- ordered_member_list contains all properties indexers and methods
that are not defined as explicit implementation of an interface
or base class.
Removed MethodArrayList and IndexerArrayList from TypeBuilder. The
functionality in these removed classes has been replaced with
ComputeIndexerName, EmitIndexerName, HasEqualss, HasGetHashCode, and
CheckEqualsAndGetHashCode members defined and called in the TypeBuilderClass.
Adding CheckForDuplications to PropertyBase.PropertyMethod and calls
to CheckForDuplications inside GetMethod and SetMethod Define Method
to handle method property and indexer name conflicts.
In errors :
* gcs0111-2.cs:
With the new member ordering change in class.cs, the error message
for this test has changed and now matches csc output.
Fixes#79434
All code is contributed under the MIT/X11 license.
svn path=/trunk/mcs/; revision=74749
* cs3005-15.cs
With the changes to mcs/class.cs in r74702 these test
outputs are now different. The error messages are still correct
they are simply reporting the error on the other name due to the
new order objects are processed.
svn path=/trunk/mcs/; revision=74745
Fix#80534, gtest-309.cs
* generic.cs (UnifyType): Rename from InferType. Make unification
of generic insts simpler and don't insist on inferring all generic
parameters in a single generic inst unification.
(UnifyTypes): New.
(InferGenericInstance): Remove.
Analysis and initial patch by David Mitchell <[email protected]>.
In tests:
* gtest-309.cs: Renamed from errors/gcs0411-3.cs.
* gtest-310.cs: New test from #80534.
In errors:
* gcs0411-3.cs: Rename to tests/gtest-309.cs.
svn path=/trunk/mcs/; revision=71817
* mcs/ecore.cs (PropertyExpr.InstanceResolve): Always resolve the
instance as an rvalue, even when we later resolve as an lvalue.
* errors/cs0165-13.cs: New test from #78820.
svn path=/trunk/mcs/; revision=66967
* mcs/class.cs (DefineTypeBuilder): Check circular dependencies before
setting the parent of the TypeBuilder.
(CheckRecursiveDefinition): Don't use 'BaseType', since
it may not be valid until after DefineTypeBuilder. Use
'base_type' instead.
* errors/cs0146-5.cs: New test from #79584.
svn path=/trunk/mcs/; revision=66334
Fix#79013
* convert.cs (Convert.ImplicitStandardConversionExists): Avoid infloop.
* expression.cs (EmptyExpression.Grab, EmptyExpression.Release):
Change semantics slightly. Don't insist on having only one
temporary EmptyExpression -- just throttle the creation of new ones.
In tests:
* gtest-291.cs: New test from #79013.
In errors:
* gcs1502.cs: New test from #79013.
svn path=/trunk/mcs/; revision=66062
Fix#79451
* ecore.cs (Expression.MemberLookup): Enable CS0229 errors for
non-interfaces too. If no methods are found, don't try to create
a MethodGroupExpr.
In errors:
* cs0229-3.cs, CS0229-3-lib.il: New test based on #79451.
* cs0229-4.cs, CS0229-4-lib.il: Likewise.
svn path=/trunk/mcs/; revision=66023
Fix#79067
* cs-tokenizer.cs (parse_less_than): Allow '*' to appear in a type
parameter too. This only avoids a parse error -- the semantic
error is caught elsewhere.
In errors:
* gcs0306.cs: New test based on #79067.
svn path=/trunk/mcs/; revision=63715
Fix cs0146-3.cs and cs0146-4.cs.
* class.cs (TypeManager.CheckRecursiveDefinition): Check that
enclosing types don't depend on the current type.
In errors:
* cs0146-3.cs, cs0146-4.cs: New tests for bug discovered while
fixing #77963.
svn path=/trunk/mcs/; revision=63286
* mcs/expression.cs (Binary.CheckShiftArguments): Don't overwrite original
'left' and 'right' before error-checking.
* gmcs/expression.cs: Likewise.
* errors/cs0019-16.cs: New test from #78662.
svn path=/trunk/mcs/; revision=61898
* flowanalysis.cs (UsageVector.MergeOrigins): If an origin is
unreachable, skip it.
(FlowBranchingException.Merge): Always propagate jumps, even if
the finally block renders subsequent code unreachable.
In gmcs:
* flowanalysis.cs (UsageVector.MergeOrigins): If an origin is
unreachable, skip it.
(FlowBranchingException.Merge): Always propagate jumps, even if
the finally block renders subsequent code unreachable.
In tests:
* test-519.cs: New test for compiler crash.
In errors:
* cs0139-3.cs, cs0139-4.cs, cs0139-5.cs, cs0139-6.cs: New
regression tests for 'break' and 'continue' inside a try block.
svn path=/trunk/mcs/; revision=60987
In mcs:
Fix#77869, #76148, #77755, #75255 and a host of other bugs.
This is still "wrong", but anything better would probably need a
multi-pass algorithm.
* flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
usage vector. Force current usage vector to be reachable, to
optimistically signify backward jumps.
(FlowBranchingLabeled.LookupLabel): Note if a backward jump is
detected.
(FlowBranchingLabeled.Merge): New. If no backward jump was
detected, return the original salted-away usage vector instead,
updated with appropriate changes. Print unreachable warning if
necessary.
* statement.cs (Block.Resolve): Don't print unreachable warning on
a labeled statement.
In gmcs:
Fix#77869, #76148, #77755, #75255 and a host of other bugs.
This is still "wrong", but anything better would probably need a
multi-pass algorithm.
* flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
usage vector. Force current usage vector to be reachable, to
optimistically signify backward jumps.
(FlowBranchingLabeled.LookupLabel): Note if a backward jump is
detected.
(FlowBranchingLabeled.Merge): New. If no backward jump was
detected, return the original salted-away usage vector instead,
updated with appropriate changes. Print unreachable warning if
necessary.
* statement.cs (Block.Resolve): Don't print unreachable warning on
a labeled statement.
In tests:
* test-514.cs: New test from #76148.
* test-515.cs, test-516.cs: New tests based on #77755.
* test-517.cs: New test based on #75255.
In errors:
* cs0162-6.cs, cs0162-7.cs: New tests for unreachable code.
Emitting the warning on cs0162-7.cs needs a multi-pass algorithm.
* cs0165-12.cs: New test from #77869.
svn path=/trunk/mcs/; revision=60813
* flowanalysis.cs (UsageVector.MergeJumpOrigins): Kill.
(FlowBranchingBlock.Label): Use UsageVector.MergeOrigins.
(FlowBranchingException.Label): Likewise.
In gmcs:
* flowanalysis.cs (UsageVector.MergeJumpOrigins): Kill.
(FlowBranchingBlock.Label): Use UsageVector.MergeOrigins.
(FlowBranchingException.Label): Likewise.
In tests:
* test-154.cs (test39): Move buggy testcase to errors/cs0177-7.cs.
Fix it and move ...
* test-510.cs: ... here.
In errors:
* cs0177-7.cs: Taken from erroneous sub-test in tests/test-154.cs.
svn path=/trunk/mcs/; revision=60584
Fix#78290
* statement.cs (Return.Resolve): Move error checking to ...
* flowbranching.cs (FlowBranching.AddReturnOrigin): ... this.
(FlowBranchingException): Handle return origins like break and
continue origins.
(FlowBranching.UsageVector.CheckOutParameters): Remove.
In gmcs:
Fix#78290
* statement.cs (Return.Resolve): Move error checking to ...
* flowbranching.cs (FlowBranching.AddReturnOrigin): ... this.
(FlowBranchingException): Handle return origins like break and
continue origins.
(FlowBranching.UsageVector.CheckOutParameters): Remove.
In tests:
* test-508.cs: New test -- didn't fail earlier, but include to
catch any regressions.
In errors:
* cs0177-5.cs, cs0177-6.cs: New tests based on #78290.
svn path=/trunk/mcs/; revision=60279
Fix#76471, #76665
* flowanalysis.cs (FlowBranching.BranchingType.Embedded): New.
(FlowBranching.CreateBranching): Handle it: create a
FlowBranchingContinuable.
(FlowBranching.BreakCrossesExceptionBoundary): Remove.
(FlowBranching.AddContinueOrigin): Similar to AddBreakOrigin,
except that it handles the 'continue' command.
(FlowBranching.UsageVector.MergeOrigins): Rename from
MergeBreakOrigins.
(FlowBranchingContinuable): Similar to FlowBranchingBreakable,
except that it overrides AddContinueOrigin.
(FlowBranchingException): Override AddContinueOrigin, similar to
AddBreakOrigin.
* statement.cs (While.Resolve, Foreach.ArrayForeach.Resolve):
Create a new branching around the embedded statement.
(Do.Resolve, For.Resolve): Likewise. Do reachability analysis for
control flow after the embedded statement.
(Continue.Resolve): Move all error checking to AddContinueOrigin.
In gmcs:
Fix#76471, #76665
* flowanalysis.cs (FlowBranching.BranchingType.Embedded): New.
(FlowBranching.CreateBranching): Handle it: create a
FlowBranchingContinuable.
(FlowBranching.BreakCrossesExceptionBoundary): Remove.
(FlowBranching.AddContinueOrigin): Similar to AddBreakOrigin,
except that it handles the 'continue' command.
(FlowBranching.UsageVector.MergeOrigins): Rename from
MergeBreakOrigins.
(FlowBranchingContinuable): Similar to FlowBranchingBreakable,
except that it overrides AddContinueOrigin.
(FlowBranchingException): Override AddContinueOrigin, similar to
AddBreakOrigin.
* statement.cs (While.Resolve, Foreach.ArrayForeach.Resolve):
Create a new branching around the embedded statement.
(Do.Resolve, For.Resolve): Likewise. Do reachability analysis for
control flow after the embedded statement.
(Continue.Resolve): Move all error checking to AddContinueOrigin.
In tests:
* test-504.cs: New test from #76471.
In errors:
* cs0162-5.cs: New test from #76665.
svn path=/trunk/mcs/; revision=60218
* mcs/expression.cs (Invocation.VerifyArgumentsCompat): Don't try
implicit conversions on 'out' and 'ref' arguments.
* gmcs/expression.cs: Likewise.
* errors/cs1502-7.cs: New test from #75800.
svn path=/trunk/mcs/; revision=59696
Fix#66031
* statement.cs (Block.UsageWarning): Allow VariableInfo to be null.
(Catch.Resolve): Resolve VarBlock if it exists.
In errors:
* cs0168-2.cs: New test from #66031.
svn path=/trunk/mcs/; revision=59691
Support ParameterDefaultValueAttribute in gmcs. Also applied to
mcs to keep code differences small.
* attribute.cs (Attribute.GetParameterDefaultValue): New.
* typemanager.cs (parameter_default_value_attribute_type): New.
* parameter.cs (Parameter.ApplyAttributeBuilder): Use them. Add
CS1908 check.
In mcs:
Support ParameterDefaultValueAttribute in gmcs. Also applied to
mcs to keep code differences small.
* attribute.cs (Attribute.GetParameterDefaultValue): New.
* typemanager.cs (parameter_default_value_attribute_type): New.
* parameter.cs (Parameter.ApplyAttributeBuilder): Use them. Add
CS1908 check.
In errors:
* gcs1908.cs, gcs1908-2.cs, gcs1908-3.cs, gcs1908-4.cs: New tests
for DefaultParameterValueAttribute.
In tests:
* gtest-262.cs: New test for DefaultParameterValueAttribute.
svn path=/trunk/mcs/; revision=58300