Sema: Fix infinite loop in OrderDeclarations::operator()

If the two declarations were in different source files, we would get
stuck in the while loop at the end.

Fixes rdar://164519548.
This commit is contained in:
Slava Pestov
2025-11-21 20:22:43 -05:00
parent fa55b2520d
commit 140bfd6b2f
3 changed files with 24 additions and 0 deletions

View File

@@ -2542,6 +2542,9 @@ namespace {
auto opposite = (*this)(rightDecl, leftDecl);
if (normal != opposite)
return normal;
leftContext = leftContext->getParent();
rightContext = rightContext->getParent();
}
// Final tiebreaker: Kind

View File

@@ -0,0 +1,8 @@
import Foundation
extension EmitTest {
@objc static func emit(_ number : Int) -> Int {
// expected-note@-1 {{'emit' previously declared here}}
return 0
}
}

View File

@@ -0,0 +1,13 @@
// RUN: %target-typecheck-verify-swift %S/Inputs/objc_selector_conflict_multifile_other.swift
// REQUIRES: objc_interop
import Foundation
class EmitTest {}
extension EmitTest {
@objc static func emit(_ string : String) -> String {
// expected-error@-1 {{method 'emit' with Objective-C selector 'emit:' conflicts with previous declaration with the same Objective-C selector}}
return ""
}
}