Skip to content

Commit 2c0914c

Browse files
committed
Revert "conformance location" back to what it was
We moved some diagnostics around, which ended up breaking some downstream tests that we don't want to break. Restore the location.
1 parent 5a0e70a commit 2c0914c

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

include/swift/AST/ProtocolConformance.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,9 @@ class NormalProtocolConformance : public RootProtocolConformance,
530530
/// The location of this protocol conformance in the source.
531531
SourceLoc Loc;
532532

533+
/// The location of the protocol name within the conformance.
534+
SourceLoc ProtocolNameLoc;
535+
533536
/// The location of the `@preconcurrency` attribute, if any.
534537
SourceLoc PreconcurrencyLoc;
535538

@@ -569,7 +572,8 @@ class NormalProtocolConformance : public RootProtocolConformance,
569572
SourceLoc preconcurrencyLoc)
570573
: RootProtocolConformance(ProtocolConformanceKind::Normal,
571574
conformingType),
572-
Protocol(protocol), Loc(loc), PreconcurrencyLoc(preconcurrencyLoc),
575+
Protocol(protocol), Loc(extractNearestSourceLoc(dc)),
576+
ProtocolNameLoc(loc), PreconcurrencyLoc(preconcurrencyLoc),
573577
Context(dc) {
574578
assert(!conformingType->hasArchetype() &&
575579
"ProtocolConformances should store interface types");
@@ -590,6 +594,9 @@ class NormalProtocolConformance : public RootProtocolConformance,
590594
/// Retrieve the location of this conformance.
591595
SourceLoc getLoc() const { return Loc; }
592596

597+
/// Retrieve the name of the protocol location.
598+
SourceLoc getProtocolNameLoc() const { return ProtocolNameLoc; }
599+
593600
/// Get the declaration context that contains the conforming extension or
594601
/// nominal type declaration.
595602
DeclContext *getDeclContext() const { return Context; }

lib/Sema/TypeCheckProtocol.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3313,10 +3313,10 @@ ConformanceChecker::checkActorIsolation(ValueDecl *requirement,
33133313
!Conformance->isPreconcurrency() &&
33143314
!suggestedPreconcurrency &&
33153315
!requirementIsolation.isActorIsolated()) {
3316-
Context.Diags.diagnose(Conformance->getLoc(),
3316+
Context.Diags.diagnose(Conformance->getProtocolNameLoc(),
33173317
diag::add_preconcurrency_to_conformance,
33183318
Proto->getName())
3319-
.fixItInsert(Conformance->getLoc(), "@preconcurrency ");
3319+
.fixItInsert(Conformance->getProtocolNameLoc(), "@preconcurrency ");
33203320
suggestedPreconcurrency = true;
33213321
}
33223322
}

test/APINotes/versioned-objc.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import APINotesFrameworkTest
99

1010
// CHECK-DIAGS-5-NOT: versioned-objc.swift:[[@LINE-1]]:
1111
class ProtoWithVersionedUnavailableMemberImpl: ProtoWithVersionedUnavailableMember {
12-
// CHECK-DIAGS-4: versioned-objc.swift:[[@LINE-1]]:48: error: type 'ProtoWithVersionedUnavailableMemberImpl' cannot conform to protocol 'ProtoWithVersionedUnavailableMember' because it has requirements that cannot be satisfied
12+
// CHECK-DIAGS-4: versioned-objc.swift:[[@LINE-1]]:7: error: type 'ProtoWithVersionedUnavailableMemberImpl' cannot conform to protocol 'ProtoWithVersionedUnavailableMember' because it has requirements that cannot be satisfied
1313
func requirement() -> Any? { return nil }
1414
}
1515

test/decl/protocol/req/missing_conformance.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ struct CountSteps1<T> : Collection {
144144
subscript(i: Int) -> Int { return i }
145145
}
146146

147-
extension CountSteps1 // expected-error {{type 'CountSteps1<T>' does not conform to protocol 'BidirectionalCollection'}}
147+
extension CountSteps1 // expected-error {{type 'CountSteps1<T>' does not conform to protocol 'RandomAccessCollection'}}
148148
// expected-error@-1 {{conditional conformance of type 'CountSteps1<T>' to protocol 'RandomAccessCollection' does not imply conformance to inherited protocol 'BidirectionalCollection'}}
149149
// expected-note@-2 {{did you mean to explicitly state the conformance like 'extension CountSteps1: BidirectionalCollection where ...'?}}
150-
// expected-error@+1 {{type 'CountSteps1<T>' does not conform to protocol 'RandomAccessCollection'}}
150+
// expected-error@-3 {{type 'CountSteps1<T>' does not conform to protocol 'BidirectionalCollection'}}
151151
: RandomAccessCollection
152152
where T : Equatable
153153
{

0 commit comments

Comments
 (0)