Imported Upstream version 4.4.0.40

Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
Xamarin Public Jenkins
2016-03-16 12:38:19 -04:00
parent f3e3aab35a
commit a632333cc7
110 changed files with 1496 additions and 556 deletions

View File

@@ -90,6 +90,11 @@ namespace Mono.CSharp
if (!stmt.Resolve (bc))
return null;
if (rc.HasSet (ResolveContext.Options.FinallyScope) && rc.CurrentAnonymousMethod != null) {
var ats = (AsyncTaskStorey)rc.CurrentAnonymousMethod.Storey;
ats.HasAwaitInsideFinally = true;
}
type = stmt.ResultType;
eclass = ExprClass.Variable;
return this;
@@ -344,7 +349,11 @@ namespace Mono.CSharp
var errors_printer = new SessionReportPrinter ();
var old = bc.Report.SetPrinter (errors_printer);
ama = new Invocation (ama, args).Resolve (bc);
//
// The expression await t is classified the same way as the expression (t).GetAwaiter().GetResult().
//
ama = new Invocation (new ParenthesizedExpression (ama, Location.Null), args).Resolve (bc);
bc.Report.SetPrinter (old);
if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression (ama.Type)) {
@@ -536,6 +545,8 @@ namespace Mono.CSharp
#region Properties
public bool HasAwaitInsideFinally { get; set; }
public Expression HoistedReturnValue { get; set; }
public TypeSpec ReturnType {
@@ -689,6 +700,18 @@ namespace Mono.CSharp
builder = AddCompilerGeneratedField ("$builder", new TypeExpression (bt, Location));
Field rfield;
if (has_task_return_type && HasAwaitInsideFinally) {
//
// Special case async block with return value from finally clause. In such case
// we rewrite all return expresison stores to stfld to $return. Instead of treating
// returns outside of finally and inside of finally differently.
//
rfield = AddCompilerGeneratedField ("$return", new TypeExpression (bt.TypeArguments [0], Location));
} else {
rfield = null;
}
var set_state_machine = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN | Modifiers.PUBLIC,
new MemberName ("SetStateMachine"),
@@ -726,7 +749,13 @@ namespace Mono.CSharp
set_state_machine.Block.AddStatement (new StatementExpression (new Invocation (mg, args)));
if (has_task_return_type) {
HoistedReturnValue = TemporaryVariableReference.Create (bt.TypeArguments [0], StateMachineMethod.Block, Location);
if (rfield != null) {
HoistedReturnValue = new FieldExpr (rfield, Location) {
InstanceExpression = new CompilerGeneratedThis (CurrentType, Location.Null)
};
} else {
HoistedReturnValue = TemporaryVariableReference.Create (bt.TypeArguments [0], StateMachineMethod.Block, Location);
}
}
return true;

View File

@@ -2179,8 +2179,11 @@ namespace Mono.CSharp {
var ma = expr as MemberAccess;
if (ma != null) {
var lexpr = ma.LeftExpression;
Expression res;
var res = ma.LookupNameExpression (rc, MemberLookupRestrictions.IgnoreAmbiguity);
using (rc.Set (ResolveContext.Options.NameOfScope)) {
res = ma.LookupNameExpression (rc, MemberLookupRestrictions.IgnoreAmbiguity);
}
if (res == null) {
return false;
@@ -2194,11 +2197,6 @@ namespace Mono.CSharp {
return false;
}
if (!IsLeftExpressionValid (lexpr)) {
rc.Report.Error (8082, lexpr.Location, "An argument to nameof operator cannot include sub-expression");
return false;
}
var mg = res as MethodGroupExpr;
if (mg != null) {
var emg = res as ExtensionMethodGroupExpr;
@@ -2215,6 +2213,14 @@ namespace Mono.CSharp {
}
}
//
// LAMESPEC: Why is conditional access not allowed?
//
if (!IsLeftResolvedExpressionValid (ma.LeftExpression) || ma.HasConditionalAccess ()) {
rc.Report.Error (8082, lexpr.Location, "An argument to nameof operator cannot include sub-expression");
return false;
}
Value = ma.Name;
return true;
}
@@ -2223,26 +2229,25 @@ namespace Mono.CSharp {
return false;
}
static bool IsLeftExpressionValid (Expression expr)
static bool IsLeftResolvedExpressionValid (Expression expr)
{
if (expr is SimpleName)
return true;
if (expr is This)
return true;
if (expr is NamespaceExpression)
return true;
if (expr is TypeExpr)
return true;
var ma = expr as MemberAccess;
if (ma != null) {
// TODO: Will conditional access be allowed?
return IsLeftExpressionValid (ma.LeftExpression);
var fe = expr as FieldExpr;
if (fe != null) {
return fe.InstanceExpression == null || IsLeftResolvedExpressionValid (fe.InstanceExpression);
}
var pe = expr as PropertyExpr;
if (pe != null)
return pe.InstanceExpression == null || IsLeftResolvedExpressionValid (pe.InstanceExpression);
var dmb = expr as DynamicMemberBinder;
if (dmb != null) {
return IsLeftResolvedExpressionValid (dmb.Arguments [0].Expr);
}
if (expr is ConstantExpr || expr is TypeExpr || expr is NamespaceExpression || expr is This)
return true;
return false;
}

View File

@@ -191,6 +191,8 @@ namespace Mono.CSharp
DontSetConditionalAccessReceiver = 1 << 16,
NameOfScope = 1 << 17,
///
/// Indicates the current context is in probing mode, no errors are reported.
///

View File

@@ -4058,6 +4058,9 @@ namespace Mono.CSharp
--braces;
break;
case '\\':
if (parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Peek ())
break;
++col;
int surrogate;
ch = escape (ch, out surrogate);

View File

@@ -1 +1 @@
52da19a1b970748d49991d1a2b47a7bbef11a061
a581906d3e9b82d7ffd04ab74c4c1f8275e7efa5

View File

@@ -1 +1 @@
c5139d57f673c5d02f003618a9d64ccc09dcc2a1
bfba44fbb8c656079254fc346737ea8a4af5fd3e

View File

@@ -897,6 +897,18 @@ namespace Mono.CSharp.Nullable
ec.MarkLabel (is_null_label);
LiftedNull.Create (type, loc).Emit (ec);
} else if (Left.IsNull && UnwrapRight != null) {
UnwrapRight.Emit (ec);
ec.Emit (or ? OpCodes.Brtrue_S : OpCodes.Brfalse_S, load_right);
LiftedNull.Create (type, loc).Emit (ec);
ec.Emit (OpCodes.Br_S, end_label);
ec.MarkLabel (load_right);
UnwrapRight.Load (ec);
} else {
Right.Emit (ec);
ec.Emit (or ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, load_left);

View File

@@ -1210,6 +1210,16 @@ namespace Mono.CSharp {
settings.RuntimeMetadataVersion = value;
return ParseResult.Success;
// csc options that we don't support
case "/utf8output":
case "/subsystemversion":
case "/highentropyva":
case "/highentropyva+":
case "/highentropyva-":
case "/win32manifest":
case "/nowin32manifest":
return ParseResult.Success;
default:
return ParseResult.UnknownOption;
}

View File

@@ -1 +1 @@
e5c8bb4316c6b5af4ce075f1b939559bf7efd40f
3fbb360debcdacf3146092c1a7adddf7f20f3fde