Skip to content

Commit

Permalink
Merge branch 'features/patterns' of https://github.com/dotnet/roslyn
Browse files Browse the repository at this point in the history
…into features/patterns
  • Loading branch information
gafter committed Mar 2, 2016
2 parents df649b5 + 598e851 commit 0de6840
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 80 deletions.
58 changes: 29 additions & 29 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,10 @@ protected BoundExpression BindInferredVariableInitializer(DiagnosticBag diagnost
}

protected bool IsInitializerRefKindValid(
EqualsValueClauseSyntax initializer,
CSharpSyntaxNode node,
RefKind variableRefKind,
DiagnosticBag diagnostics,
EqualsValueClauseSyntax initializer,
CSharpSyntaxNode node,
RefKind variableRefKind,
DiagnosticBag diagnostics,
out BindValueKind valueKind)
{
if (variableRefKind == RefKind.None)
Expand Down Expand Up @@ -1219,7 +1219,7 @@ private static bool CheckLocalVariable(CSharpSyntaxNode tree, LocalSymbol local,
{
ErrorCode.ERR_RefReadonlyLocalCause,
// impossible since readonly locals are never byref, but would be a reasonable error otherwise
ErrorCode.ERR_RefReadonlyLocalCause,
ErrorCode.ERR_RefReadonlyLocalCause,
ErrorCode.ERR_AssgReadonlyLocalCause,

ErrorCode.ERR_RefReadonlyLocal2Cause,
Expand All @@ -1236,7 +1236,7 @@ private static bool CheckLocalVariable(CSharpSyntaxNode tree, LocalSymbol local,
}

private bool CheckIsCallVariable(BoundCall call, CSharpSyntaxNode node, BindValueKind kind, bool checkingReceiver, DiagnosticBag diagnostics)
{
{
// A call can only be a variable if it returns by reference. If this is the case,
// whether or not it is a valid variable depends on whether or not the call is the
// RHS of a return or an assign by reference:
Expand All @@ -1261,7 +1261,7 @@ private bool CheckIsCallVariable(BoundCall call, CSharpSyntaxNode node, BindValu
var parameterName = methodSymbol.Parameters[parameterIndex].Name;
Error(diagnostics, errorCode, call.Syntax, methodSymbol, parameterName);
return false;
}
}
}
}
}
Expand Down Expand Up @@ -1650,7 +1650,7 @@ private bool CheckIsVariable(CSharpSyntaxNode node, BoundExpression expr, BindVa
return false;
}

if (fieldSymbol.ContainingType.IsValueType &&
if (fieldSymbol.ContainingType.IsValueType &&
!fieldIsStatic &&
!CheckIsValidReceiverForVariable(node, fieldAccess.ReceiverOpt, kind, diagnostics))
{
Expand Down Expand Up @@ -2046,8 +2046,8 @@ private bool CheckEventValueKind(BoundEventAccess boundEvent, BindValueKind valu
}
else if (!CheckIsValidReceiverForVariable(eventSyntax, receiver, BindValueKind.Assignment, diagnostics))
{
return false;
}
return false;
}
}
else if (RequiresSettingValue(valueKind))
{
Expand Down Expand Up @@ -2155,11 +2155,11 @@ private bool CheckPropertyValueKind(BoundExpression expr, BindValueKind valueKin
ReportDiagnosticsIfObsolete(diagnostics, setMethod, node, receiver?.Kind == BoundKind.BaseReference);

if (RequiresVariableReceiver(receiver, setMethod) && !CheckIsValidReceiverForVariable(node, receiver, BindValueKind.Assignment, diagnostics))
{
return false;
}
{
return false;
}
}
}

var isIndirectSet = RequiresSettingValue(valueKind) && propertySymbol.RefKind != RefKind.None;
if (RequiresGettingValue(valueKind) || isIndirectSet)
Expand Down Expand Up @@ -2394,7 +2394,7 @@ internal BoundExpression GenerateConversionForAssignment(TypeSymbol targetType,
if (refKind != RefKind.None)
{
if (conversion.Kind != ConversionKind.Identity)
{
{
Error(diagnostics, ErrorCode.ERR_RefAssignmentMustHaveIdentityConversion, expression.Syntax, targetType);
}
}
Expand Down Expand Up @@ -3106,7 +3106,7 @@ protected virtual TypeSymbol GetCurrentReturnType(out RefKind refKind)
{
var symbol = this.ContainingMemberOrLambda as MethodSymbol;
if ((object)symbol != null)
{
{
refKind = symbol.RefKind;
return symbol.ReturnType;
}
Expand Down Expand Up @@ -3278,31 +3278,31 @@ internal BoundExpression CreateReturnConversion(
if (returnRefKind != RefKind.None)
{
if (conversion.Kind != ConversionKind.Identity)
{
{
Error(diagnostics, ErrorCode.ERR_RefReturnMustHaveIdentityConversion, argument.Syntax, returnType);
}
}
else if (!conversion.IsImplicit || !conversion.IsValid)
{
if (!badAsyncReturnAlreadyReported)
{
if (!badAsyncReturnAlreadyReported)
{
RefKind unusedRefKind;
if (IsGenericTaskReturningAsyncMethod() && argument.Type == this.GetCurrentReturnType(out unusedRefKind))
{
// Since this is an async method, the return expression must be of type '{0}' rather than 'Task<{0}>'
Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, argument.Syntax, returnType);
}
else
{
GenerateImplicitConversionError(diagnostics, argument.Syntax, conversion, argument, returnType);
if (this.ContainingMemberOrLambda is LambdaSymbol)
{
ReportCantConvertLambdaReturn(argument.Syntax, diagnostics);
// Since this is an async method, the return expression must be of type '{0}' rather than 'Task<{0}>'
Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, argument.Syntax, returnType);
}
else
{
GenerateImplicitConversionError(diagnostics, argument.Syntax, conversion, argument, returnType);
if (this.ContainingMemberOrLambda is LambdaSymbol)
{
ReportCantConvertLambdaReturn(argument.Syntax, diagnostics);
}
}
}
}
}
}

return CreateConversion(argument.Syntax, argument, conversion, false, returnType, diagnostics);
}
Expand Down Expand Up @@ -3522,7 +3522,7 @@ internal BoundBlock CreateBlockFromExpression(CSharpSyntaxNode node, ImmutableAr
else if ((object)returnType != null)
{
if ((refKind != RefKind.None) != (returnRefKind != RefKind.None))
{
{
var errorCode = refKind != RefKind.None
? ErrorCode.ERR_MustNotHaveRefReturn
: ErrorCode.ERR_MustHaveRefReturn;
Expand Down
18 changes: 9 additions & 9 deletions src/Compilers/CSharp/Portable/BoundTree/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2763,21 +2763,21 @@ partial class BoundIsPatternExpression
public override void Accept(OperationVisitor visitor)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
visitor.VisitNoneOperation(this);
}

public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return visitor.VisitNoneOperation(this, argument);
}

protected override OperationKind ExpressionKind
{
get
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return OperationKind.None;
}
}
}
Expand All @@ -2787,21 +2787,21 @@ partial class BoundMatchExpression
public override void Accept(OperationVisitor visitor)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
visitor.VisitNoneOperation(this);
}

public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return visitor.VisitNoneOperation(this, argument);
}

protected override OperationKind ExpressionKind
{
get
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return OperationKind.None;
}
}
}
Expand All @@ -2811,21 +2811,21 @@ partial class BoundThrowExpression
public override void Accept(OperationVisitor visitor)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
visitor.VisitNoneOperation(this);
}

public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return visitor.VisitNoneOperation(this, argument);
}

protected override OperationKind ExpressionKind
{
get
{
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
throw new NotImplementedException();
return OperationKind.None;
}
}
}
Expand Down
Loading

0 comments on commit 0de6840

Please sign in to comment.