提交 82208aef 编写于 作者: C CyrusNajmabadi

Move diagnostic from parser to later phase.

上级 45273896
......@@ -2920,17 +2920,6 @@ private bool IsEndOfNameInExplicitInterface()
// our context again (perhaps an open brace).
}
// When a generic method overrides a generic method declared in a base
// class, or is an explicit interface member implementation of a method in
// a base interface, the method shall not specify any type-parameter-
// constraints-clauses. In these cases, the type parameters of the method
// inherit constraints from the method being overridden or implemented
if (!constraints.IsNull && constraints.Count > 0 &&
((explicitInterfaceOpt != null) || (modifiers != null && modifiers.Any((int)SyntaxKind.OverrideKeyword))))
{
constraints[0] = this.AddErrorToFirstToken(constraints[0], ErrorCode.ERR_OverrideWithConstraints);
}
_termState = saveTerm;
BlockSyntax blockBody;
......
......@@ -113,6 +113,22 @@ internal sealed class SourceMemberMethodSymbol : SourceMethodSymbol
{
diagnostics.Add(info, location);
}
// When a generic method overrides a generic method declared in a base class, or is an
// explicit interface member implementation of a method in a base interface, the method
// shall not specify any type-parameter-constraints-clauses. In these cases, the type
// parameters of the method inherit constraints from the method being overridden or
// implemented
if (syntax.ConstraintClauses.Count > 0)
{
if (syntax.ExplicitInterfaceSpecifier != null ||
syntax.Modifiers.Any(SyntaxKind.OverrideKeyword))
{
diagnostics.Add(
ErrorCode.ERR_OverrideWithConstraints,
syntax.ConstraintClauses[0].WhereKeyword.GetLocation());
}
}
}
public override bool ReturnsVoid
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册