return this;
}
+ public override void EmitSideEffect (EmitContext ec)
+ {
+ expr.EmitSideEffect (ec);
+ }
+
public override void FlowAnalysis (FlowAnalysisContext fc)
{
expr.FlowAnalysis (fc);
}
ec.Emit (on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target);
}
-
- Expression CreateConstantResult (ResolveContext ec, bool result)
+
+ Expression CreateConstantResult (ResolveContext rc, bool result)
{
if (result)
- ec.Report.Warning (183, 1, loc, "The given expression is always of the provided (`{0}') type",
+ rc.Report.Warning (183, 1, loc, "The given expression is always of the provided (`{0}') type",
probe_type_expr.GetSignatureForError ());
else
- ec.Report.Warning (184, 1, loc, "The given expression is never of the provided (`{0}') type",
+ rc.Report.Warning (184, 1, loc, "The given expression is never of the provided (`{0}') type",
probe_type_expr.GetSignatureForError ());
- return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, result, loc), this);
+ var c = new BoolConstant (rc.BuiltinTypes, result, loc);
+ return expr.IsSideEffectFree ?
+ ReducedExpression.Create (c, this) :
+ new SideEffectConstant (c, this, loc);
}
protected override Expression DoResolve (ResolveContext ec)
--- /dev/null
+using System;
+
+class X
+{
+ static int Foo ()
+ {
+ throw new ApplicationException ();
+ }
+
+ public static int Main ()
+ {
+ try {
+ var b = Foo () is object;
+ return 1;
+ } catch (ApplicationException) {
+ }
+
+ try {
+ var b = Foo () as object;
+ return 2;
+ } catch (ApplicationException) {
+ }
+
+ return 0;
+ }
+}
\ No newline at end of file
</method>\r
</type>\r
</test>\r
+ <test name="test-897.cs">\r
+ <type name="X">\r
+ <method name="Int32 Foo()" attrs="145">\r
+ <size>7</size>\r
+ </method>\r
+ <method name="Int32 Main()" attrs="150">\r
+ <size>61</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="test-9.cs">\r
<type name="X">\r
<method name="Int32 Main(System.String[])" attrs="150">\r