Skip to content

Commit

Permalink
Add argument modifiers to generated base proxy when needed. Fixes #13892
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Aug 19, 2013
1 parent cbca01b commit 1269b40
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mcs/mcs/delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public static Arguments CreateDelegateMethodArguments (ResolveContext rc, AParam
Arguments delegate_arguments = new Arguments (pd.Count);
for (int i = 0; i < pd.Count; ++i) {
Argument.AType atype_modifier;
switch (pd.FixedParameters [i].ModFlags) {
switch (pd.FixedParameters [i].ModFlags & Parameter.Modifier.RefOutMask) {
case Parameter.Modifier.REF:
atype_modifier = Argument.AType.Ref;
break;
Expand Down
19 changes: 17 additions & 2 deletions mcs/mcs/statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3427,8 +3427,23 @@ public Arguments GetAllParametersArguments ()
int count = parameters.Count;
Arguments args = new Arguments (count);
for (int i = 0; i < count; ++i) {
var arg_expr = GetParameterReference (i, parameter_info[i].Location);
args.Add (new Argument (arg_expr));
var pi = parameter_info[i];
var arg_expr = GetParameterReference (i, pi.Location);

Argument.AType atype_modifier;
switch (pi.Parameter.ParameterModifier & Parameter.Modifier.RefOutMask) {
case Parameter.Modifier.REF:
atype_modifier = Argument.AType.Ref;
break;
case Parameter.Modifier.OUT:
atype_modifier = Argument.AType.Out;
break;
default:
atype_modifier = 0;
break;
}

args.Add (new Argument (arg_expr, atype_modifier));
}

return args;
Expand Down
20 changes: 19 additions & 1 deletion mcs/tests/test-anon-94.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class BaseClass
{
public int i;
public virtual void Print () { Console.WriteLine ("BaseClass.Print"); i = 90; }
public virtual void TestOut (out int arg) { arg = 4; }
}

public class Derived : BaseClass
Expand All @@ -17,6 +18,18 @@ public override void Print ()
Action a = () => base.Print ();
a ();
}

public override void TestOut (out int arg)
{
int p = 9;
Action a = () => {
base.TestOut (out p);
Console.WriteLine (p);
};

a ();
arg = p;
}
}

public class DerivedLibrary : BaseClassLibrary
Expand All @@ -35,12 +48,17 @@ public static int Main ()

if (d.i != 90)
return 1;

int arg;
d.TestOut (out arg);
if (arg != 4)
return 2;

var d2 = new DerivedLibrary ();
d2.Print (0);

if (d2.i != 30)
return 2;
return 3;

return 0;
}
Expand Down
27 changes: 25 additions & 2 deletions mcs/tests/ver-il-net_4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55148,7 +55148,7 @@
<test name="test-anon-94.cs">
<type name="Program">
<method name="Int32 Main()" attrs="150">
<size>75</size>
<size>97</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
Expand Down Expand Up @@ -55183,9 +55183,32 @@
<method name="Void &lt;Print&gt;__BaseCallProxy0(Int32)" attrs="129">
<size>8</size>
</method>
<method name="Void &lt;Print&gt;m__1()" attrs="129">
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="Program+BaseClass">
<method name="Void TestOut(Int32 ByRef)" attrs="454">
<size>5</size>
</method>
</type>
<type name="Program+Derived">
<method name="Void TestOut(Int32 ByRef)" attrs="198">
<size>50</size>
</method>
<method name="Void &lt;TestOut&gt;__BaseCallProxy1(Int32 ByRef)" attrs="129">
<size>8</size>
</method>
</type>
<type name="Program+DerivedLibrary">
<method name="Void &lt;Print&gt;m__2()" attrs="129">
<size>9</size>
</method>
</type>
<type name="Program+Derived+&lt;TestOut&gt;c__AnonStorey0">
<method name="Void &lt;&gt;m__1()" attrs="131">
<size>30</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
Expand Down

0 comments on commit 1269b40

Please sign in to comment.