-
Notifications
You must be signed in to change notification settings - Fork 4.2k
ERR_ImplBadTupleNames is now being reported in correct class #24438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
ba19c27
660b6ce
179ee37
e80dc55
9085534
9f762a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1048,11 +1048,11 @@ private static void ReportImplicitImplementationMatchDiagnostics(Symbol interfac | |
|
|
||
| if (interfaceMethodIsAccessor && !implicitImplIsAccessor && !interfaceMethod.IsIndexedPropertyAccessor()) | ||
| { | ||
| diagnostics.Add(ErrorCode.ERR_MethodImplementingAccessor, implicitImpl.Locations[0], implicitImpl, interfaceMethod, implementingType); | ||
| diagnostics.Add(ErrorCode.ERR_MethodImplementingAccessor, GetDiagnosticLocation(implicitImpl), implicitImpl, interfaceMethod, implementingType); | ||
| } | ||
| else if (!interfaceMethodIsAccessor && implicitImplIsAccessor) | ||
| { | ||
| diagnostics.Add(ErrorCode.ERR_AccessorImplementingMethod, implicitImpl.Locations[0], implicitImpl, interfaceMethod, implementingType); | ||
| diagnostics.Add(ErrorCode.ERR_AccessorImplementingMethod, GetDiagnosticLocation(implicitImpl), implicitImpl, interfaceMethod, implementingType); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -1061,7 +1061,7 @@ private static void ReportImplicitImplementationMatchDiagnostics(Symbol interfac | |
| if (implicitImplMethod.IsConditional) | ||
| { | ||
| // CS0629: Conditional member '{0}' cannot implement interface member '{1}' in type '{2}' | ||
| diagnostics.Add(ErrorCode.ERR_InterfaceImplementedByConditional, implicitImpl.Locations[0], implicitImpl, interfaceMethod, implementingType); | ||
| diagnostics.Add(ErrorCode.ERR_InterfaceImplementedByConditional, GetDiagnosticLocation(implicitImpl), implicitImpl, interfaceMethod, implementingType); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -1073,7 +1073,7 @@ private static void ReportImplicitImplementationMatchDiagnostics(Symbol interfac | |
| if (implicitImpl.ContainsTupleNames() && MemberSignatureComparer.ConsideringTupleNamesCreatesDifference(implicitImpl, interfaceMember)) | ||
| { | ||
| // it is ok to implement implicitly with no tuple names, for compatibility with C# 6, but otherwise names should match | ||
| diagnostics.Add(ErrorCode.ERR_ImplBadTupleNames, implicitImpl.Locations[0], implicitImpl, interfaceMember); | ||
| diagnostics.Add(ErrorCode.ERR_ImplBadTupleNames, GetDiagnosticLocation(implicitImpl), implicitImpl, interfaceMember); | ||
| } | ||
|
|
||
| // In constructed types, it is possible to see multiple members with the same (runtime) signature. | ||
|
|
@@ -1090,10 +1090,24 @@ private static void ReportImplicitImplementationMatchDiagnostics(Symbol interfac | |
| else if (MemberSignatureComparer.RuntimeImplicitImplementationComparer.Equals(interfaceMember, member) && !member.IsAccessor()) | ||
| { | ||
| // CONSIDER: Dev10 does not seem to report this for indexers or their accessors. | ||
| diagnostics.Add(ErrorCode.WRN_MultipleRuntimeImplementationMatches, member.Locations[0], member, interfaceMember, implementingType); | ||
| diagnostics.Add(ErrorCode.WRN_MultipleRuntimeImplementationMatches, GetDiagnosticLocation(member), member, interfaceMember, implementingType); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Location GetDiagnosticLocation(Symbol member) | ||
|
||
| { | ||
| if (member.ContainingType == implementingType) | ||
| { | ||
| return member.Locations[0]; | ||
| } | ||
| else | ||
| { | ||
| var @interface = interfaceMember.ContainingType; | ||
| SourceMemberContainerTypeSymbol snt = implementingType as SourceMemberContainerTypeSymbol; | ||
| return snt?.GetImplementsLocation(@interface) ?? implementingType.Locations[0]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -1107,7 +1121,7 @@ private static void ReportImplicitImplementationMismatchDiagnostics(Symbol inter | |
| { | ||
| var @interface = interfaceMember.ContainingType; | ||
| SourceMemberContainerTypeSymbol snt = implementingType as SourceMemberContainerTypeSymbol; | ||
| interfaceLocation = snt.GetImplementsLocation(@interface) ?? implementingType.Locations[0]; | ||
| interfaceLocation = snt?.GetImplementsLocation(@interface) ?? implementingType.Locations[0]; | ||
| } | ||
| else | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark as private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only a local function. I believe it's not possible to mark it with access modifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put it at the beginning of the method to avoid confusion.