You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
@@ -819,7 +819,7 @@ namespace Mono.CSharp {
|
||||
if (expr_type == target_type)
|
||||
return true;
|
||||
|
||||
if (expr_type == InternalType.ThrowExpr)
|
||||
if (expr_type == InternalType.ThrowExpr || expr_type == InternalType.DefaultType)
|
||||
return target_type.Kind != MemberKind.InternalCompilerType;
|
||||
|
||||
if (target_type.IsNullableType)
|
||||
|
||||
@@ -1 +1 @@
|
||||
e2e85431d997383f904cd014a958d6d8310f1915
|
||||
b27caaa0982fd67a1d7894558a1ad7e1bc5164da
|
||||
@@ -718,8 +718,11 @@ namespace Mono.CSharp
|
||||
case Token.DEFAULT:
|
||||
switch (peek_token ()) {
|
||||
case Token.COLON:
|
||||
token ();
|
||||
res = Token.DEFAULT_COLON;
|
||||
// Special case: foo == null ? default : 1;
|
||||
if (current_token != Token.INTERR) {
|
||||
token ();
|
||||
res = Token.DEFAULT_COLON;
|
||||
}
|
||||
break;
|
||||
case Token.OPEN_PARENS:
|
||||
case Token.OPEN_PARENS_CAST:
|
||||
@@ -1402,6 +1405,7 @@ namespace Mono.CSharp
|
||||
case Token.NEW:
|
||||
case Token.INTERPOLATED_STRING:
|
||||
case Token.THROW:
|
||||
case Token.DEFAULT_COLON:
|
||||
next_token = Token.INTERR;
|
||||
break;
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
5e2e7f2436fd66421df911b794e620b8c8789969
|
||||
b6a508cffc61cadc2e4ab73e7cc62af1fc2793d6
|
||||
@@ -1 +1 @@
|
||||
74d15942be865d75be6494f7125eba6633ef6317
|
||||
cf27d94416e563d7cd096b31566b356ef3f05640
|
||||
@@ -309,7 +309,6 @@ namespace Mono.CSharp {
|
||||
//
|
||||
if (!BuiltinTypeSpec.IsPrimitiveType (dt) || dt.BuiltinType == BuiltinTypeSpec.Type.Char) {
|
||||
switch (dt.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.String:
|
||||
case BuiltinTypeSpec.Type.Delegate:
|
||||
case BuiltinTypeSpec.Type.MulticastDelegate:
|
||||
break;
|
||||
@@ -317,6 +316,9 @@ namespace Mono.CSharp {
|
||||
if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) {
|
||||
state |= StateFlags.HasConversionOperator;
|
||||
} else {
|
||||
if (dt.BuiltinType == BuiltinTypeSpec.Type.String)
|
||||
break;
|
||||
|
||||
state |= StateFlags.HasUserOperator;
|
||||
}
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ namespace Mono.CSharp
|
||||
{
|
||||
Expression source;
|
||||
List<Expression> targetExprs;
|
||||
List<LocalVariable> variablesToInfer;
|
||||
List<BlockVariable> variables;
|
||||
Expression instance;
|
||||
|
||||
public TupleDeconstruct (List<Expression> targetExprs, Expression source, Location loc)
|
||||
@@ -442,10 +442,11 @@ namespace Mono.CSharp
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public TupleDeconstruct (List<Expression> targetExprs, List<LocalVariable> variables, Expression source, Location loc)
|
||||
: this (targetExprs, source, loc)
|
||||
public TupleDeconstruct (List<BlockVariable> variables, Expression source, Location loc)
|
||||
{
|
||||
this.variablesToInfer = variables;
|
||||
this.source = source;
|
||||
this.variables = variables;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public override Expression CreateExpressionTree (ResolveContext ec)
|
||||
@@ -469,9 +470,18 @@ namespace Mono.CSharp
|
||||
var src_type = src.Type;
|
||||
|
||||
if (src_type.IsTupleType) {
|
||||
if (src_type.Arity != targetExprs.Count) {
|
||||
int target_count;
|
||||
|
||||
if (targetExprs == null) {
|
||||
target_count = variables.Count;
|
||||
targetExprs = new List<Expression> (target_count);
|
||||
} else {
|
||||
target_count = targetExprs.Count;
|
||||
}
|
||||
|
||||
if (src_type.Arity != target_count) {
|
||||
rc.Report.Error (8132, loc, "Cannot deconstruct a tuple of `{0}' elements into `{1}' variables",
|
||||
src_type.Arity.ToString (), targetExprs.Count.ToString ());
|
||||
src_type.Arity.ToString (CultureInfo.InvariantCulture), target_count.ToString (CultureInfo.InvariantCulture));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -482,27 +492,44 @@ namespace Mono.CSharp
|
||||
instance = expr_variable.CreateReferenceExpression (rc, loc);
|
||||
}
|
||||
|
||||
for (int i = 0; i < targetExprs.Count; ++i) {
|
||||
for (int i = 0; i < target_count; ++i) {
|
||||
var tle = src_type.TypeArguments [i];
|
||||
|
||||
var lv = variablesToInfer? [i];
|
||||
if (lv != null) {
|
||||
if (InternalType.HasNoType (tle)) {
|
||||
rc.Report.Error (8130, Location, "Cannot infer the type of implicitly-typed deconstruction variable `{0}'", lv.Name);
|
||||
lv.Type = InternalType.ErrorType;
|
||||
if (variables != null) {
|
||||
var variable = variables [i].Variable;
|
||||
|
||||
if (variable.Type == InternalType.Discard) {
|
||||
variables [i] = null;
|
||||
targetExprs.Add (EmptyExpressionStatement.Instance);
|
||||
continue;
|
||||
}
|
||||
|
||||
lv.Type = tle;
|
||||
lv.PrepareAssignmentAnalysis ((BlockContext) rc);
|
||||
}
|
||||
var variable_type = variables [i].TypeExpression;
|
||||
|
||||
targetExprs.Add (new LocalVariableReference (variable, variable.Location));
|
||||
|
||||
if (variable_type is VarExpr) {
|
||||
if (InternalType.HasNoType (tle)) {
|
||||
rc.Report.Error (8130, Location, "Cannot infer the type of implicitly-typed deconstruction variable `{0}'", variable.Name);
|
||||
tle = InternalType.ErrorType;
|
||||
}
|
||||
|
||||
variable.Type = tle;
|
||||
} else {
|
||||
variable.Type = variable_type.ResolveAsType (rc);
|
||||
}
|
||||
|
||||
variable.PrepareAssignmentAnalysis ((BlockContext)rc);
|
||||
}
|
||||
|
||||
var element_src = tupleLiteral == null ? new MemberAccess (instance, NamedTupleSpec.GetElementPropertyName (i)) : tupleLiteral.Elements [i].Expr;
|
||||
targetExprs [i] = new SimpleAssign (targetExprs [i], element_src).Resolve (rc);
|
||||
}
|
||||
|
||||
eclass = ExprClass.Value;
|
||||
|
||||
// TODO: The type is same only if there is no target element conversion
|
||||
// var res = (/*byte*/ b, /*short*/ s) = (2, 4);
|
||||
type = src.Type;
|
||||
return this;
|
||||
}
|
||||
@@ -527,11 +554,24 @@ namespace Mono.CSharp
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (instance != null)
|
||||
((ExpressionStatement)source).EmitStatement (ec);
|
||||
|
||||
foreach (ExpressionStatement expr in targetExprs)
|
||||
expr.Emit (ec);
|
||||
|
||||
var ctor = MemberCache.FindMember (type, MemberFilter.Constructor (null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly) as MethodSpec;
|
||||
ec.Emit (OpCodes.Newobj, ctor);
|
||||
}
|
||||
|
||||
public override void EmitStatement (EmitContext ec)
|
||||
{
|
||||
if (variables != null) {
|
||||
foreach (var lv in variables) {
|
||||
lv?.Variable.CreateBuilder (ec);
|
||||
}
|
||||
}
|
||||
|
||||
if (instance != null)
|
||||
((ExpressionStatement) source).EmitStatement (ec);
|
||||
|
||||
@@ -549,9 +589,6 @@ namespace Mono.CSharp
|
||||
if (leave_copy)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
foreach (var lv in variablesToInfer)
|
||||
lv.CreateBuilder (ec);
|
||||
|
||||
EmitStatement (ec);
|
||||
}
|
||||
|
||||
@@ -563,11 +600,11 @@ namespace Mono.CSharp
|
||||
|
||||
public void SetGeneratedFieldAssigned (FlowAnalysisContext fc)
|
||||
{
|
||||
if (variablesToInfer == null)
|
||||
if (variables == null)
|
||||
return;
|
||||
|
||||
foreach (var lv in variablesToInfer)
|
||||
fc.SetVariableAssigned (lv.VariableInfo);
|
||||
foreach (var lv in variables)
|
||||
fc.SetVariableAssigned (lv.Variable.VariableInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1463,6 +1463,29 @@ namespace Mono.CSharp
|
||||
|
||||
class InternalType : TypeSpec, ITypeDefinition
|
||||
{
|
||||
sealed class InternalTypeAssembly : IAssemblyDefinition
|
||||
{
|
||||
public static readonly InternalTypeAssembly Instance = new InternalTypeAssembly ();
|
||||
|
||||
public string FullName => throw new NotImplementedException ();
|
||||
|
||||
public bool IsCLSCompliant => false;
|
||||
|
||||
public bool IsMissing => false;
|
||||
|
||||
public string Name => throw new NotImplementedException ();
|
||||
|
||||
public byte [] GetPublicKeyToken ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public bool IsFriendAssemblyTo (IAssemblyDefinition assembly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly InternalType AnonymousMethod = new InternalType ("anonymous method");
|
||||
public static readonly InternalType Arglist = new InternalType ("__arglist");
|
||||
public static readonly InternalType MethodGroup = new InternalType ("method group");
|
||||
@@ -1473,6 +1496,7 @@ namespace Mono.CSharp
|
||||
public static readonly InternalType VarOutType = new InternalType ("var out");
|
||||
public static readonly InternalType ThrowExpr = new InternalType ("throw expression");
|
||||
public static readonly InternalType DefaultType = new InternalType ("default");
|
||||
public static readonly InternalType Discard = new InternalType ("discard");
|
||||
|
||||
readonly string name;
|
||||
|
||||
@@ -1497,7 +1521,7 @@ namespace Mono.CSharp
|
||||
|
||||
IAssemblyDefinition ITypeDefinition.DeclaringAssembly {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return InternalTypeAssembly.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user