@@ -22,7 +22,17 @@ Each entry should include a short description of the break, followed by either a
```
Due to this the `OpenParenToken` and `CloseParenToken` fields of a `SwitchStatementSyntax` node may now sometimes be empty.
4. https://github.com/dotnet/roslyn/issues/26098 In C# 8, we give a warning when an is-type expression is always `false` because the input type is an open class type and the type it is tested against is a value type:
4. In an *is-pattern-expression*, a warning is now issued when a constant expression does not match the provided pattern because of its value. Such code was previously accepted but gave no warning. For example
``` c#
if(3is4)// warning: the given expression never matches the provided pattern.
```
We also issue a warning when a constant expression *always* matches a constant pattern in an *is-pattern-expression*. For example
``` c#
if(3is3)// warning: the given expression always matches the provided constant.
```
Other cases of the pattern always matching (e.g. `e is var t`) do not trigger a warning, even when they are known by the compiler to produce an invariant result.
5. https://github.com/dotnet/roslyn/issues/26098 In C# 8, we give a warning when an is-type expression is always `false` because the input type is an open class type and the type it is tested against is a value type:
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
/// Looks up a localized string similar to Defining an alias named 'global' is ill-advised since 'global::' always references the global namespace and not an alias.
Debug.Assert(expression != null, "Field 'expression' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
Debug.Assert(!innerLocals.IsDefault, "Field 'innerLocals' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
Debug.Assert(!innerLocalFunctions.IsDefault, "Field 'innerLocalFunctions' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
Debug.Assert(!switchSections.IsDefault, "Field 'switchSections' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
Debug.Assert(decisionDag != null, "Field 'decisionDag' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
Debug.Assert(breakLabel != null, "Field 'breakLabel' cannot be null (use Null=\"allow\" in BoundNodes.xml to remove this check)");
this.Expression = expression;
this.InnerLocals = innerLocals;
this.InnerLocalFunctions = innerLocalFunctions;
this.SwitchSections = switchSections;
this.DecisionDag = decisionDag;
this.DefaultLabel = defaultLabel;
this.BreakLabel = breakLabel;
}
...
...
@@ -2870,6 +2872,8 @@ public BoundPatternSwitchStatement(SyntaxNode syntax, BoundExpression expression
public ImmutableArray<BoundPatternSwitchSection> SwitchSections { get; }
public BoundDecisionDag DecisionDag { get; }
public BoundPatternSwitchLabel DefaultLabel { get; }
public GeneratedLabelSymbol BreakLabel { get; }
...
...
@@ -2879,11 +2883,11 @@ public override BoundNode Accept(BoundTreeVisitor visitor)
var result = new BoundPatternSwitchStatement(this.Syntax, expression, innerLocals, innerLocalFunctions, switchSections, defaultLabel, breakLabel, this.HasErrors);
var result = new BoundPatternSwitchStatement(this.Syntax, expression, innerLocals, innerLocalFunctions, switchSections, decisionDag, defaultLabel, breakLabel, this.HasErrors);