Migrate to calling interfaceType and remove SelfParam

Migrate more tests
This commit is contained in:
Kathy Gray
2025-09-17 18:27:29 +01:00
parent 3eee15f1cb
commit 84ef25afbc
26 changed files with 100 additions and 89 deletions

View File

@@ -2047,13 +2047,13 @@ static Type getWitnessTypeForMatching(NormalProtocolConformance *conformance,
} }
/// Remove the 'self' type from the given type, if it's a method type. /// Remove the 'self' type from the given type, if it's a method type.
static Type removeSelfParam(ValueDecl *value, Type type) { /*Type removeSelfParam(ValueDecl *value, Type type) {
if (value->hasCurriedSelf()) { if (value->hasCurriedSelf()) {
return type->castTo<AnyFunctionType>()->getResult(); return type->castTo<AnyFunctionType>()->getResult();
} }
return type; return type;
} }*/
InferredAssociatedTypesByWitnesses InferredAssociatedTypesByWitnesses
AssociatedTypeInference::inferTypeWitnessesViaAssociatedType( AssociatedTypeInference::inferTypeWitnessesViaAssociatedType(
@@ -2227,7 +2227,7 @@ AssociatedTypeInference::getPotentialTypeWitnessesByMatchingTypes(ValueDecl *req
InferredAssociatedTypesByWitness inferred; InferredAssociatedTypesByWitness inferred;
inferred.Witness = witness; inferred.Witness = witness;
auto reqType = removeSelfParam(req, req->getInterfaceType()); auto reqType = swift::TypeChecker::removeSelfParam(req, req->getInterfaceType());
Type witnessType; Type witnessType;
if (witness->isRecursiveValidation()) { if (witness->isRecursiveValidation()) {
@@ -2249,7 +2249,7 @@ AssociatedTypeInference::getPotentialTypeWitnessesByMatchingTypes(ValueDecl *req
LLVM_DEBUG(llvm::dbgs() << "Witness type for matching is " LLVM_DEBUG(llvm::dbgs() << "Witness type for matching is "
<< witnessType << "\n";); << witnessType << "\n";);
witnessType = removeSelfParam(witness, witnessType); witnessType = swift::TypeChecker::removeSelfParam(witness, witnessType);
Type reqThrownError; Type reqThrownError;
Type witnessThrownError; Type witnessThrownError;

View File

@@ -16,6 +16,7 @@
#include "CSDiagnostics.h" #include "CSDiagnostics.h"
#include "MiscDiagnostics.h" #include "MiscDiagnostics.h"
#include "TypeChecker.h"
#include "TypeCheckConcurrency.h" #include "TypeCheckConcurrency.h"
#include "TypeCheckProtocol.h" #include "TypeCheckProtocol.h"
#include "TypeCheckType.h" #include "TypeCheckType.h"
@@ -4100,7 +4101,7 @@ bool SubscriptMisuseFailure::diagnoseAsError() {
bool SubscriptMisuseFailure::diagnoseAsNote() { bool SubscriptMisuseFailure::diagnoseAsNote() {
if (auto overload = getOverloadChoiceIfAvailable(getLocator())) { if (auto overload = getOverloadChoiceIfAvailable(getLocator())) {
auto decl = overload->choice.getDecl(); auto decl = overload->choice.getDecl();
emitDiagnosticAt(decl, diag::found_candidate_type, decl->getOverloadSignatureType()); emitDiagnosticAt(decl, diag::found_candidate_type, swift::TypeChecker::removeSelfParam(decl,decl->getInterfaceType()));
return true; return true;
} }
return false; return false;

View File

@@ -3385,10 +3385,10 @@ bool ConstraintSystem::diagnoseAmbiguity(ArrayRef<Solution> solutions) {
if (EmittedDecls.insert(decl).second) { if (EmittedDecls.insert(decl).second) {
auto declModule = decl->getDeclContext()->getParentModule(); auto declModule = decl->getDeclContext()->getParentModule();
bool printModuleName = declModule != DC->getParentModule(); bool printModuleName = declModule != DC->getParentModule();
auto overloadType = decl->getOverloadSignatureType(); auto diagnoseType = swift::TypeChecker::removeSelfParam(decl, decl->getInterfaceType());
DE.diagnose(decl, diag::found_candidate_in_module, DE.diagnose(decl, diag::found_candidate_in_module,
printModuleName, declModule, overloadType); printModuleName, declModule, diagnoseType);
} }
break; break;
} }

View File

@@ -765,6 +765,13 @@ bool TypeChecker::diagnoseInvalidFunctionType(
return hadAnyError; return hadAnyError;
} }
Type swift::TypeChecker::removeSelfParam(ValueDecl *value, Type type){
if (value->hasCurriedSelf()) {
return type->castTo<AnyFunctionType>()->getResult();
}
return type;
}
extern "C" intptr_t swift_ASTGen_evaluatePoundIfCondition( extern "C" intptr_t swift_ASTGen_evaluatePoundIfCondition(
BridgedASTContext astContext, BridgedASTContext astContext,
void *_Nonnull diagEngine, void *_Nonnull diagEngine,

View File

@@ -1147,6 +1147,9 @@ std::optional<DeclName> omitNeedlessWords(AbstractFunctionDecl *afd);
/// Attempt to omit needless words from the name of the given declaration. /// Attempt to omit needless words from the name of the given declaration.
std::optional<Identifier> omitNeedlessWords(VarDecl *var); std::optional<Identifier> omitNeedlessWords(VarDecl *var);
/// Method to strip Self parameter from types for diagnostics
Type removeSelfParam(ValueDecl *value, Type type);
/// Calculate edit distance between declaration names. /// Calculate edit distance between declaration names.
unsigned getCallEditDistance(DeclNameRef writtenName, DeclName correctedName, unsigned getCallEditDistance(DeclNameRef writtenName, DeclName correctedName,
unsigned maxEditDistance); unsigned maxEditDistance);

View File

@@ -18,8 +18,8 @@ func referencesAsyncOverloadAsync() async {
_ = asyncOverload // we prefer the async overload _ = asyncOverload // we prefer the async overload
} }
func reasyncOverload(_: () async -> (), _: Int) reasync {} // expected-note {{found this candidate}} func reasyncOverload(_: () async -> (), _: Int) reasync {} // expected-note {{found candidate with type '(() -> (), Int) async -> ()}}
func reasyncOverload(_: () -> (), _: String) {} // expected-note {{found this candidate}} func reasyncOverload(_: () -> (), _: String) {} // expected-note {{found candidate with type '(() -> (), String) -> ()'}}
func referencesReasyncOverload() { func referencesReasyncOverload() {
_ = reasyncOverload // expected-error {{ambiguous use of 'reasyncOverload'}} _ = reasyncOverload // expected-error {{ambiguous use of 'reasyncOverload'}}

View File

@@ -792,8 +792,8 @@ func f20371273() {
// rdar://problem/42337247 // rdar://problem/42337247
func overloaded(_ handler: () -> Int) {} // expected-note {{found this candidate}} func overloaded(_ handler: () -> Int) {} // expected-note {{found candidate with type '(() -> Int) -> ()'}}
func overloaded(_ handler: () -> Void) {} // expected-note {{found this candidate}} func overloaded(_ handler: () -> Void) {} // expected-note {{found candidate with type '(() -> ()) -> ()'}}
overloaded { } // empty body => inferred as returning () overloaded { } // empty body => inferred as returning ()
@@ -1045,8 +1045,8 @@ func rdar52204414() {
// Note that this was accepted prior to Swift 5.3. SE-0286 changed the // Note that this was accepted prior to Swift 5.3. SE-0286 changed the
// order of argument resolution and made it ambiguous. // order of argument resolution and made it ambiguous.
func overloaded_with_default(a: () -> Int, b: Int = 0, c: Int = 0) {} // expected-note{{found this candidate}} func overloaded_with_default(a: () -> Int, b: Int = 0, c: Int = 0) {} // expected-note{{found candidate with type '(() -> Int, Int, Int) -> ()'}}
func overloaded_with_default(b: Int = 0, c: Int = 0, a: () -> Int) {} // expected-note{{found this candidate}} func overloaded_with_default(b: Int = 0, c: Int = 0, a: () -> Int) {} // expected-note{{found candidate with type '(() -> Int, Int, Int) -> ()'}}
overloaded_with_default { 0 } // expected-error{{ambiguous use of 'overloaded_with_default'}} overloaded_with_default { 0 } // expected-error{{ambiguous use of 'overloaded_with_default'}}

View File

@@ -5,15 +5,15 @@ func f0(_ d: Double, _ i: Int) {} // expected-note{{found candidate with type '(
f0(1, 2) // expected-error{{ambiguous use of 'f0'}} f0(1, 2) // expected-error{{ambiguous use of 'f0'}}
func f1(_ i: Int16) {} // expected-note{{found this candidate}} func f1(_ i: Int16) {} // expected-note{{found candidate with type '(Int16) -> ()'}}
func f1(_ i: Int32) {} // expected-note{{found this candidate}} func f1(_ i: Int32) {} // expected-note{{found candidate type '(Int32) -> ()'}}
f1(0) // expected-error{{ambiguous use of 'f1'}} f1(0) // expected-error{{ambiguous use of 'f1'}}
infix operator +++ infix operator +++
func +++(i: Int, d: Double) {} // expected-note{{found this candidate}} func +++(i: Int, d: Double) {} // expected-note{{found candidate with type '(Int, Double) -> ()'}}
func +++(d: Double, i: Int) {} // expected-note{{found this candidate}} func +++(d: Double, i: Int) {} // expected-note{{found candidate with type '(Double, Int) -> ()'}}
1 +++ 2 // expected-error{{ambiguous use of operator '+++'}} 1 +++ 2 // expected-error{{ambiguous use of operator '+++'}}

View File

@@ -7,9 +7,9 @@ import has_ambiguities
maybeTrans(0) // expected-error{{ambiguous use of 'maybeTrans'}} maybeTrans(0) // expected-error{{ambiguous use of 'maybeTrans'}}
// CHECK: ambiguous use of 'maybeTrans' // CHECK: ambiguous use of 'maybeTrans'
// CHECK: maybeTrans(0) // CHECK: maybeTrans(0)
// CHECK: found this candidate // CHECK: found candidate with type '(Int16) -> ()' in module 'has_ambiguities'
// CHECK-NOT: transparent // CHECK-NOT: transparent
// CHECK: maybeTrans(_ i: Int16) // CHECK: maybeTrans(_ i: Int16)
// CHECK: found this candidate
// CHECK-NOT: transparent // CHECK-NOT: transparent
// CHECK: maybeTrans(_ i: Int32) // CHECK: maybeTrans(_ i: Int32)
// CHECK: found candidate with type '(Int32) -> ()' in module 'has_ambiquities'

View File

@@ -27,10 +27,10 @@ class X {
@objc func foo(_ i: Int) { } @objc func foo(_ i: Int) { }
@objc func bar() { } @objc func bar() { }
@objc func ovl2() -> A { } // expected-note{{found candidate with type '(X) -> () -> A'}} @objc func ovl2() -> A { } // expected-note{{found candidate with type '() -> A'}}
@objc func ovl4() -> B { } @objc func ovl4() -> B { }
@objc func ovl5() -> B { } // expected-note{{found candidate with type '(X) -> () -> B'}} @objc func ovl5() -> B { } // expected-note{{found candidate with type '() -> B'}}
@objc class func staticFoo(_ i : Int) { } @objc class func staticFoo(_ i : Int) { }
@@ -46,7 +46,7 @@ class Y : P {
@objc func ovl1() -> A { } @objc func ovl1() -> A { }
@objc func ovl4() -> B { } @objc func ovl4() -> B { }
@objc func ovl5() -> C { } // expected-note{{found candidate with type '(Y) -> () -> C'}} @objc func ovl5() -> C { } // expected-note{{found candidate with type '() -> C'}}
@objc var prop1 : Int { @objc var prop1 : Int {
get { get {
@@ -81,7 +81,7 @@ class Y : P {
class Z : Y { class Z : Y {
@objc override func ovl1() -> B { } @objc override func ovl1() -> B { }
@objc func ovl2() -> C { } // expected-note{{found candidate with type '(Z) -> () -> C'}} @objc func ovl2() -> C { } // expected-note{{found candidate with type '() -> C'}}
@objc(ovl3_A) func ovl3() -> A { } @objc(ovl3_A) func ovl3() -> A { }
@objc func ovl3() -> B { } @objc func ovl3() -> B { }
func generic4<T>(_ x : T) { } func generic4<T>(_ x : T) { }
@@ -356,7 +356,7 @@ func dynamicInitCrash(ao: AnyObject.Type) {
// Test that we correctly diagnose ambiguity for different typed members available // Test that we correctly diagnose ambiguity for different typed members available
// through dynamic lookup. // through dynamic lookup.
@objc protocol P3 { @objc protocol P3 {
var ambiguousProperty: String { get } // expected-note {{found candidate with type '() -> String'}} var ambiguousProperty: String { get } // expected-note {{found candidate with type 'String'}}
var unambiguousProperty: Int { get } var unambiguousProperty: Int { get }
func ambiguousMethod() -> String // expected-note 2{{found candidate with type '() -> String'}} func ambiguousMethod() -> String // expected-note 2{{found candidate with type '() -> String'}}
@@ -365,16 +365,16 @@ func dynamicInitCrash(ao: AnyObject.Type) {
func ambiguousMethodParam(_ x: String) // expected-note {{found candidate with type '(String) -> ()'}} func ambiguousMethodParam(_ x: String) // expected-note {{found candidate with type '(String) -> ()'}}
func unambiguousMethodParam(_ x: Int) func unambiguousMethodParam(_ x: Int)
subscript(ambiguousSubscript _: Int) -> String { get } // expected-note {{found candidate with type '(Int) -> String'}} subscript(ambiguousSubscript _: Int) -> String { get } // expected-note {{found candidate with type '<Self where Self : P3> (ambiguousSubscript: Int) -> String'}}
subscript(unambiguousSubscript _: String) -> Int { get } subscript(unambiguousSubscript _: String) -> Int { get }
subscript(differentSelectors _: Int) -> Int { // expected-note {{found candidate with type '(Int) -> Int'}} subscript(differentSelectors _: Int) -> Int { // expected-note {{found candidate with type '<Self where Self : P3> (differentSelectors: Int) -> Int'}}
@objc(differentSelector1:) get @objc(differentSelector1:) get
} }
} }
class C1 { class C1 {
@objc var ambiguousProperty: Int { return 0 } // expected-note {{found candidate with type '() -> Int'}} @objc var ambiguousProperty: Int { return 0 } // expected-note {{found candidate with type 'Int'}}
@objc var unambiguousProperty: Int { return 0 } @objc var unambiguousProperty: Int { return 0 }
@objc func ambiguousMethod() -> Int { return 0 } // expected-note 2{{found candidate with type '() -> Int'}} @objc func ambiguousMethod() -> Int { return 0 } // expected-note 2{{found candidate with type '() -> Int'}}

View File

@@ -364,8 +364,8 @@ class TestFailableOnly {
do { do {
@_disfavoredOverload @_disfavoredOverload
func test(over: Int, that: String = "", block: @escaping (Int) throws -> Void) async throws {} func test(over: Int, that: String = "", block: @escaping (Int) throws -> Void) async throws {}
func test(over: Int, that: String = "", block: @escaping (Int) throws -> Void) throws {} // expected-note {{found candidate with type '(Int, String, Int) -> ()'}} func test(over: Int, that: String = "", block: @escaping (Int) throws -> Void) throws {} // expected-note {{found candidate with type '(Int, String, @escaping (Int) throws -> Void) throws -> ()'}}
func test(over: Int, other: String = "", block: @escaping (Int) throws -> Void) throws {} // expected-note {{found candidate with type '(Int, String, Int) -> ()'}} func test(over: Int, other: String = "", block: @escaping (Int) throws -> Void) throws {} // expected-note {{found candidate with type '(Int, String, @escaping (Int) throws -> Void) throws -> ()'}}
func performLocal(v: Int, block: @escaping (Int) throws -> Void) async throws { func performLocal(v: Int, block: @escaping (Int) throws -> Void) async throws {
try await test(over: v, block: block) // expected-error {{ambiguous use of 'test'}} try await test(over: v, block: block) // expected-error {{ambiguous use of 'test'}}

View File

@@ -343,8 +343,8 @@ func testExplicitCoercionRequirement(v: any B, otherV: any B & D) {
// CHECK: open_existential_expr {{.*}} location={{.*}}:[[@LINE+1]]:{{[0-9]+}} range= // CHECK: open_existential_expr {{.*}} location={{.*}}:[[@LINE+1]]:{{[0-9]+}} range=
_ = getF(otherV) // Ok `E` doesn't have a `where` clause _ = getF(otherV) // Ok `E` doesn't have a `where` clause
func getSelf<T: B>(_: T) -> T { fatalError() } // expected-note {{found candidate with type '(B) -> B'}} func getSelf<T: B>(_: T) -> T { fatalError() } // expected-note {{found candidate with type '<T where T : B> (T) -> T'}}
func getSelf<T: D>(_: T) -> T { fatalError() } // expected-note {{found candidate with type '(D) -> D'}} func getSelf<T: D>(_: T) -> T { fatalError() } // expected-note {{found candidate with type '<T where T : D> (T) -> T'}}
// CHECK: open_existential_expr {{.*}} location={{.*}}:[[@LINE+1]]:{{[0-9]+}} range= // CHECK: open_existential_expr {{.*}} location={{.*}}:[[@LINE+1]]:{{[0-9]+}} range=
_ = getSelf(v) // Ok _ = getSelf(v) // Ok

View File

@@ -295,8 +295,8 @@ func test_init_refs_with_single_pack_expansion_param() {
_ = Data(42, "") // Ok _ = Data(42, "") // Ok
struct EmptyAmbiguous<each V> { struct EmptyAmbiguous<each V> {
init(_: repeat each V) {} // expected-note {{found this candidate}} init(_: repeat each V) {} // expected-note {{found candidate with type '(repeat each V) -> EmptyAmbiguous<repeat each V>'}}
init(x: repeat each V) {} // expected-note {{found this candidate}} init(x: repeat each V) {} // expected-note {{found candidate with type '(repeat each V) -> EmptyAmbiguous<repeat each V>'}}
} }
_ = EmptyAmbiguous() // expected-error {{ambiguous use of 'init'}} _ = EmptyAmbiguous() // expected-error {{ambiguous use of 'init'}}
@@ -630,25 +630,25 @@ do {
// rdar://112029630 - incorrect variadic generic overload ranking // rdar://112029630 - incorrect variadic generic overload ranking
do { do {
func test1<T>(_: T...) {} func test1<T>(_: T...) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '(T...) -> ()'}}
func test1<each T>(_: repeat each T) {} func test1<each T>(_: repeat each T) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '<each T> (repeat each T) -> ()'}}
test1(1, 2, 3) // expected-error {{ambiguous use of 'test1'}} test1(1, 2, 3) // expected-error {{ambiguous use of 'test1'}}
test1(1, "a") // Ok test1(1, "a") // Ok
func test2<each T>(_: repeat each T) {} func test2<each T>(_: repeat each T) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '<each T> (repeat each T) -> ()'}}
func test2<each T>(vals: repeat each T) {} func test2<each T>(vals: repeat each T) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '<each T> (vals:repeat each T) -> ()'}}
test2() // expected-error {{ambiguous use of 'test2'}} test2() // expected-error {{ambiguous use of 'test2'}}
func test_different_requirements<A: BinaryInteger & StringProtocol>(_ a: A) { func test_different_requirements<A: BinaryInteger & StringProtocol>(_ a: A) {
func test3<each T: BinaryInteger>(str: String, _: repeat each T) {} func test3<each T: BinaryInteger>(str: String, _: repeat each T) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '<A, each T where A : BInaryInteger, A : StringProtocol, repeat each T : StringProtocol> (str: repeat each T) -> ()'}}
func test3<each U: StringProtocol>(str: repeat each U) {} func test3<each U: StringProtocol>(str: repeat each U) {}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type '<A, each U where A : BinaryInteger, A : StringProtocol, repeat each U : StringProtocol> (str: repeat each U) -> ()'}}
test3(str: "", a, a) // expected-error {{ambiguous use of 'test3'}} test3(str: "", a, a) // expected-error {{ambiguous use of 'test3'}}
} }

View File

@@ -9,8 +9,8 @@ protocol P {
// We currently only apply the constructor ranking rule to X() and not X.init(). // We currently only apply the constructor ranking rule to X() and not X.init().
struct S<T : P> { struct S<T : P> {
init(_ x: T = .init()) {} // expected-note {{found candidate with type '(P) -> S'}} init(_ x: T = .init()) {} // expected-note {{found candidate with type '(T) -> S'}}
init(_ x: T? = nil) {} // expected-note {{found candidate with type '(P?) -> S'}} init(_ x: T? = nil) {} // expected-note {{found candidate with type '(T?) -> S'}}
func testInitRanking() { func testInitRanking() {
_ = S<T>() // Okay _ = S<T>() // Okay
_ = S<T>.init() // expected-error {{ambiguous use of 'init(_:)'}} _ = S<T>.init() // expected-error {{ambiguous use of 'init(_:)'}}
@@ -28,8 +28,8 @@ struct S1 {
// Ambiguous because we don't prefer one label over the other. // Ambiguous because we don't prefer one label over the other.
struct S2 { struct S2 {
init(x: Int...) {} // expected-note {{found this candidate}} init(x: Int...) {} // expected-note {{found candidate with type '(Int...) -> S2'}}
init(y: Int...) {} // expected-note {{found this candidate}} init(y: Int...) {} // expected-note {{found candidate with type '(Int...) -> S2'}}
func testInitRanking() { func testInitRanking() {
_ = S2() // expected-error {{ambiguous use of 'init'}} _ = S2() // expected-error {{ambiguous use of 'init'}}
@@ -39,8 +39,8 @@ struct S2 {
// Ambiguous because we don't apply the prefer-unlabeled rule if the types // Ambiguous because we don't apply the prefer-unlabeled rule if the types
// aren't compatible. // aren't compatible.
struct S3 { struct S3 {
init(x: Int...) {} // expected-note {{found this candidate}} init(x: Int...) {} // expected-note {{found candidate with type '(Int...) -> S3'}}
init(_: String...) {} // expected-note {{found this candidate}} init(_: String...) {} // expected-note {{found candidate with type '(String...) -> S3'}}
func testInitRanking() { func testInitRanking() {
_ = S3() // expected-error {{ambiguous use of 'init'}} _ = S3() // expected-error {{ambiguous use of 'init'}}
@@ -51,8 +51,8 @@ struct S3 {
// parameter list, and we don't have a special case for it. Ideally we would // parameter list, and we don't have a special case for it. Ideally we would
// align this behavior with the variadic behavior. // align this behavior with the variadic behavior.
struct S4 { struct S4 {
init(x: Int = 0) {} // expected-note {{found this candidate}} init(x: Int = 0) {} // expected-note {{found candidate with type '(Int) -> S4'}}
init(_: Int = 0) {} // expected-note {{found this candidate}} init(_: Int = 0) {} // expected-note {{found candidate with type '(Int) -> S4'}}
func testInitRanking() { func testInitRanking() {
_ = S4() // expected-error {{ambiguous use of 'init'}} _ = S4() // expected-error {{ambiguous use of 'init'}}
@@ -60,8 +60,8 @@ struct S4 {
} }
infix operator ^^^ infix operator ^^^
func ^^^ (lhs: (Int, Int), rhs: Int) -> Int { 0 } // expected-note {{found this candidate}} func ^^^ (lhs: (Int, Int), rhs: Int) -> Int { 0 } // expected-note {{found candidate with type '((Int, Int), Int) -> Int'}}
func ^^^ (lhs: (Int, Int), rhs: Int) -> String { "" } // expected-note {{found this candidate}} func ^^^ (lhs: (Int, Int), rhs: Int) -> String { "" } // expected-note {{found candidate with type '((Int, Int), Int) -> String'}}
// We shouldn't favor based on the type of a tuple element. // We shouldn't favor based on the type of a tuple element.
struct S5 { struct S5 {

View File

@@ -141,11 +141,11 @@ func testDiags() {
struct A { } struct A { }
struct B { } struct B { }
func overloadedTuplify<T>(_ cond: Bool, @TupleBuilder body: (Bool) -> T) -> A { // expected-note {{found this candidate}} func overloadedTuplify<T>(_ cond: Bool, @TupleBuilder body: (Bool) -> T) -> A { // expected-note {{found candidate with type '<T> (Bool, body: (Bool) -> T) -> A'}}
return A() return A()
} }
func overloadedTuplify<T>(_ cond: Bool, @TupleBuilderWithoutIf body: (Bool) -> T) -> B { // expected-note {{found this candidate}} func overloadedTuplify<T>(_ cond: Bool, @TupleBuilderWithoutIf body: (Bool) -> T) -> B { // expected-note {{found candidate with type '<T> (Bool, body: (Bool) -> T) -> B'}}
return B() return B()
} }

View File

@@ -147,8 +147,8 @@ func passGeneric() {
struct SomeType { struct SomeType {
func identity<T>(_ x: T) -> T { return x } func identity<T>(_ x: T) -> T { return x }
func identity2<T>(_ x: T) -> T { return x } // expected-note 2{{found candidate with type '(_) -> _'}} func identity2<T>(_ x: T) -> T { return x } // expected-note 2{{found candidate with type '(T) -> T'}}
func identity2<T>(_ x: T) -> Float { } // expected-note 2{{found candidate with type '(_) -> Float'}} func identity2<T>(_ x: T) -> Float { } // expected-note 2{{found candidate with type '(T) -> Float'}}
func returnAs<T>() -> T {} func returnAs<T>() -> T {}
} }

View File

@@ -68,8 +68,8 @@ protocol Overload {
func getB() -> B func getB() -> B
func f1(_: A) -> A // expected-note {{candidate expects value of type 'OtherOvl.A' for parameter #1}} func f1(_: A) -> A // expected-note {{candidate expects value of type 'OtherOvl.A' for parameter #1}}
func f1(_: B) -> B // expected-note {{candidate expects value of type 'OtherOvl.B' for parameter #1}} func f1(_: B) -> B // expected-note {{candidate expects value of type 'OtherOvl.B' for parameter #1}}
func f2(_: Int) -> A // expected-note{{found this candidate}} func f2(_: Int) -> A // expected-note{{found candidate with type '(Int) -> Self.A'}}
func f2(_: Int) -> B // expected-note{{found this candidate}} func f2(_: Int) -> B // expected-note{{found candidate with type '(Int) -> Self.B'}}
func f3(_: Int) -> Int // expected-note {{found candidate with type '(Int) -> Int'}} func f3(_: Int) -> Int // expected-note {{found candidate with type '(Int) -> Int'}}
func f3(_: Float) -> Float // expected-note {{found candidate with type '(Float) -> Float'}} func f3(_: Float) -> Float // expected-note {{found candidate with type '(Float) -> Float'}}
func f3(_: Self) -> Self // expected-note {{found candidate with type '(OtherOvl) -> OtherOvl'}} func f3(_: Self) -> Self // expected-note {{found candidate with type '(OtherOvl) -> OtherOvl'}}

View File

@@ -23,7 +23,7 @@ var e = 3
// Name lookup with imports. // Name lookup with imports.
import imported_module import imported_module
func over1(_ x: UInt64) {} // expected-note{{found this candidate}} func over1(_ x: UInt64) {} // expected-note{{found candidate with type '(UInt64) -> ()}}
func over2(_ x: UInt32) {} func over2(_ x: UInt32) {}
func over3(_ x: UInt32) {} func over3(_ x: UInt32) {}
typealias over4 = UInt32 typealias over4 = UInt32

View File

@@ -154,10 +154,10 @@ private class VIPPrivateSetPropSub : VIPPrivateSetPropBase, VeryImportantProto {
} }
extension Container { extension Container {
private typealias ExtensionConflictingType = Int // expected-note {{found candidate with type}} expected-note {{previously declared here}} expected-note{{found this candidate}} private typealias ExtensionConflictingType = Int // expected-note {{found candidate with type}} expected-note {{previously declared here}} expected-note{{found candidate with type 'Int'}}
} }
extension Container { extension Container {
private typealias ExtensionConflictingType = Double // expected-error {{invalid redeclaration of 'ExtensionConflictingType'}} expected-note {{found candidate with type}} expected-note{{found this candidate}} private typealias ExtensionConflictingType = Double // expected-error {{invalid redeclaration of 'ExtensionConflictingType'}} expected-note {{found candidate with type}} expected-note{{found candidate with type 'Double'}}
} }
extension Container { extension Container {
func test() { func test() {

View File

@@ -15,14 +15,14 @@ protocol P1 {
func callAsFunction() -> Self func callAsFunction() -> Self
} }
extension P1 { extension P1 {
// expected-note @+1 {{found this candidate}} // expected-note @+1 {{found candidate with type '() -> Self'}}
func callAsFunction() -> Self { func callAsFunction() -> Self {
return self return self
} }
} }
protocol P2 {} protocol P2 {}
extension P2 { extension P2 {
// expected-note @+1 {{found this candidate}} // expected-note @+1 {{found candidate with type '(Int, Int) -> Int'}}
func callAsFunction(x: Int, y: Int) -> Int { func callAsFunction(x: Int, y: Int) -> Int {
return x + y return x + y
} }

View File

@@ -99,17 +99,17 @@ import LibUnrelated
ambiguous() // expected-error {{ambiguous use of 'ambiguous()'}} ambiguous() // expected-error {{ambiguous use of 'ambiguous()'}}
// CHECK-NOT: LibCore // CHECK-NOT: LibCore
// CHECK-NOT: LibMiddle // CHECK-NOT: LibMiddle
// CHECK: LibUnrelated.ambiguous:1:13: note: found this candidate in module 'LibUnrelated' // CHECK: LibUnrelated.ambiguous:1:13: note: found candidate with type '() -> ()' in module 'LibUnrelated'
// CHECK: Lib.ambiguous:1:13: note: found this candidate in module 'Lib' // CHECK: Lib.ambiguous:1:13: note: found candidate with type '() -> ()' in module 'Lib'
// CHECK: Lib.ambiguous:1:13: note: found this candidate in module 'Lib' // CHECK: Lib.ambiguous:1:13: note: found candidate with type '() -> ()' in module 'Lib'
//--- ClientMiddle.swift //--- ClientMiddle.swift
import LibCore import LibCore
import LibMiddle import LibMiddle
ambiguous() // expected-error {{ambiguous use of 'ambiguous()'}} ambiguous() // expected-error {{ambiguous use of 'ambiguous()'}}
// CHECK: LibCore.ambiguous:1:13: note: found this candidate in module 'LibCore' // CHECK: LibCore.ambiguous:1:13: note: found candidate with type '() -> ()' in module 'LibCore'
// CHECK: LibMiddle.ambiguous:1:13: note: found this candidate in module 'LibMiddle' // CHECK: LibMiddle.ambiguous:1:13: note: found candidate with type '() -> ()' in module 'LibMiddle'
//--- ClientAccessLevelOnImports.swift //--- ClientAccessLevelOnImports.swift
internal import Lib // expected-note {{global function 'coreFunc()' imported as 'internal' from 'Lib' here}} internal import Lib // expected-note {{global function 'coreFunc()' imported as 'internal' from 'Lib' here}}

View File

@@ -8,14 +8,14 @@ class A {
func f(x: X) -> X { } func f(x: X) -> X { }
func f(y: Y) -> Y { } func f(y: Y) -> Y { }
func g(z: Z) -> X { } // expected-note 2{{found this candidate}} func g(z: Z) -> X { } // expected-note 2{{found candidate with type '(Z) -> X'}}
func g(z: Z) -> Y { } // expected-note 2{{found this candidate}} func g(z: Z) -> Y { } // expected-note 2{{found candidate with type '(Z) -> Y'}}
class func sf(x: X) -> X { } class func sf(x: X) -> X { }
class func sf(y: Y) -> Y { } class func sf(y: Y) -> Y { }
class func sg(z: Z) -> X { } // expected-note 2{{found this candidate}} class func sg(z: Z) -> X { } // expected-note 2{{found candidate with type '(Z) -> X'}}
class func sg(z: Z) -> Y { } // expected-note 2{{found this candidate}} class func sg(z: Z) -> Y { } // expected-note 2{{found candidate with type '(Z) -> Y'}}
func mixed(x: X) -> X { } func mixed(x: X) -> X { }
class func mixed(y: Y) -> Y { } class func mixed(y: Y) -> Y { }

View File

@@ -2,11 +2,11 @@
// REQUIRES: concurrency // REQUIRES: concurrency
// Concurrent attribute on a function type. // Concurrent attribute on a function type.
// expected-note@+1{{found this candidate}} // expected-note@+1{{found candidate with type '@Sendable (Int) -> Int'}}
func f(_ fn: @Sendable (Int) -> Int) { } func f(_ fn: @Sendable (Int) -> Int) { }
// Okay to overload @Sendable vs. not concurrent // Okay to overload @Sendable vs. not concurrent
// expected-note@+1{{found this candidate}} // expected-note@+1{{found candidate with type '(Int) -> Int'}}
func f(_ fn: (Int) -> Int) { } func f(_ fn: (Int) -> Int) { }
// Concurrent attribute with other function attributes. // Concurrent attribute with other function attributes.

View File

@@ -131,8 +131,8 @@ infix operator +-+=
infix func +-+ (x: Int, y: Int) -> Int {} // expected-error {{'infix' modifier is not required or allowed on func declarations}} {{1-7=}} infix func +-+ (x: Int, y: Int) -> Int {} // expected-error {{'infix' modifier is not required or allowed on func declarations}} {{1-7=}}
prefix func +-+ (x: Int) -> Int {} prefix func +-+ (x: Int) -> Int {}
prefix func -+- (y: inout Int) -> Int {} // expected-note 2{{found this candidate}} prefix func -+- (y: inout Int) -> Int {} // expected-note 2{{found candidate with type '(inout Int) -> Int'}}
postfix func -+- (x: inout Int) -> Int {} // expected-note 2{{found this candidate}} postfix func -+- (x: inout Int) -> Int {} // expected-note 2{{found candidate with type '(inout Int) -> Int'}}
infix func +-+= (x: inout Int, y: Int) -> Int {} // expected-error {{'infix' modifier is not required or allowed on func declarations}} {{1-7=}} infix func +-+= (x: inout Int, y: Int) -> Int {} // expected-error {{'infix' modifier is not required or allowed on func declarations}} {{1-7=}}

View File

@@ -5,10 +5,10 @@ var_redecl1 = 0
var var_redecl1: UInt // expected-error {{invalid redeclaration of 'var_redecl1'}} var var_redecl1: UInt // expected-error {{invalid redeclaration of 'var_redecl1'}}
var var_redecl2: Int // expected-note {{previously declared here}} var var_redecl2: Int // expected-note {{previously declared here}}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type 'Int'}}
var_redecl2 = 0 // expected-error {{ambiguous use of 'var_redecl2'}} var_redecl2 = 0 // expected-error {{ambiguous use of 'var_redecl2'}}
var var_redecl2: Int // expected-error {{invalid redeclaration of 'var_redecl2'}} var var_redecl2: Int // expected-error {{invalid redeclaration of 'var_redecl2'}}
// expected-note@-1 {{found this candidate}} // expected-note@-1 {{found candidate with type 'Int'}}
var var_redecl3: (Int) -> () { get {} } // expected-note {{previously declared here}} var var_redecl3: (Int) -> () { get {} } // expected-note {{previously declared here}}
var var_redecl3: () -> () { get {} } // expected-error {{invalid redeclaration of 'var_redecl3'}} var var_redecl3: () -> () { get {} } // expected-error {{invalid redeclaration of 'var_redecl3'}}
@@ -74,17 +74,17 @@ class mixed_redecl2 {} // expected-note {{previously declared here}}
struct mixed_redecl2 {} // expected-error {{invalid redeclaration}} struct mixed_redecl2 {} // expected-error {{invalid redeclaration}}
class mixed_redecl3 {} // expected-note {{previously declared here}} class mixed_redecl3 {} // expected-note {{previously declared here}}
// expected-note @-1 2{{found this candidate}} // expected-note @-1 2{{found candidate with type 'mixed_redecl3'}}
enum mixed_redecl3 {} // expected-error {{invalid redeclaration}} enum mixed_redecl3 {} // expected-error {{invalid redeclaration}}
// expected-note @-1 2{{found this candidate}} // expected-note @-1 2{{found candidate with type 'mixed_redecl3'}}
enum mixed_redecl3a : mixed_redecl3 {} // expected-error {{'mixed_redecl3' is ambiguous for type lookup in this context}} enum mixed_redecl3a : mixed_redecl3 {} // expected-error {{'mixed_redecl3' is ambiguous for type lookup in this context}}
// expected-error@-1 {{an enum with no cases cannot declare a raw type}} // expected-error@-1 {{an enum with no cases cannot declare a raw type}}
class mixed_redecl3b : mixed_redecl3 {} // expected-error {{'mixed_redecl3' is ambiguous for type lookup in this context}} class mixed_redecl3b : mixed_redecl3 {} // expected-error {{'mixed_redecl3' is ambiguous for type lookup in this context}}
class mixed_redecl4 {} // expected-note {{previously declared here}} class mixed_redecl4 {} // expected-note {{previously declared here}}
// expected-note@-1{{found this candidate}} // expected-note@-1{{found candidate with type 'mixed_redecl4'}}
protocol mixed_redecl4 {} // expected-error {{invalid redeclaration}} protocol mixed_redecl4 {} // expected-error {{invalid redeclaration}}
// expected-note@-1{{found this candidate}} // expected-note@-1{{found candidate with type 'mixed_redecl4'}}
protocol mixed_redecl4a : mixed_redecl4 {} // expected-error {{'mixed_redecl4' is ambiguous for type lookup in this context}} protocol mixed_redecl4a : mixed_redecl4 {} // expected-error {{'mixed_redecl4' is ambiguous for type lookup in this context}}
class mixed_redecl5 {} // expected-note {{previously declared here}} class mixed_redecl5 {} // expected-note {{previously declared here}}
@@ -579,27 +579,27 @@ enum E8_52486 {
} }
enum E9_52486 { enum E9_52486 {
case A // expected-note {{'A' previously declared here}} expected-note {{found this candidate}} case A // expected-note {{'A' previously declared here}} expected-note {{found candidate with type 'E9_52486'}}
static let A: E9_52486 = .A // expected-error {{invalid redeclaration of 'A'}} static let A: E9_52486 = .A // expected-error {{invalid redeclaration of 'A'}}
// expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found this candidate}} // expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found candidate with type 'E9_52486'}}
} }
enum E10_52486 { enum E10_52486 {
static let A: E10_52486 = .A // expected-note {{'A' previously declared here}} static let A: E10_52486 = .A // expected-note {{'A' previously declared here}}
// expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found this candidate}} // expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found candidate with type 'E10_52486'}}
case A // expected-error {{invalid redeclaration of 'A'}} expected-note {{found this candidate}} case A // expected-error {{invalid redeclaration of 'A'}} expected-note {{found candidate with type 'E10_52486'}}
} }
enum E11_52486 { enum E11_52486 {
case A // expected-note {{'A' previously declared here}} expected-note {{found this candidate}} case A // expected-note {{'A' previously declared here}} expected-note {{found candidate with type 'E11_52486'}}
static var A: E11_52486 = .A // expected-error {{invalid redeclaration of 'A'}} static var A: E11_52486 = .A // expected-error {{invalid redeclaration of 'A'}}
// expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found this candidate}} // expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found candidate with type 'E11_52486'}}
} }
enum E12_52486 { enum E12_52486 {
static var A: E12_52486 = .A // expected-note {{'A' previously declared here}} static var A: E12_52486 = .A // expected-note {{'A' previously declared here}}
// expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found this candidate}} // expected-error@-1 {{ambiguous use of 'A'}} expected-note@-1 {{found candidate with type 'E12_52486'}}
case A // expected-error {{invalid redeclaration of 'A'}} expected-note {{found this candidate}} case A // expected-error {{invalid redeclaration of 'A'}} expected-note {{found candidate with type 'E12_52486'}}
} }
enum E13_52486 { enum E13_52486 {

View File

@@ -327,10 +327,10 @@ protocol DuplicateSuper : Concrete, Concrete {}
// Ambiguous name lookup situation // Ambiguous name lookup situation
protocol Amb : Concrete {} protocol Amb : Concrete {}
// expected-note@-1 {{'Amb' previously declared here}} // expected-note@-1 {{'Amb' previously declared here}}
// expected-note@-2 {{found this candidate}} // expected-note@-2 {{found candidate with type 'Amb'}}
protocol Amb : Concrete {} protocol Amb : Concrete {}
// expected-error@-1 {{invalid redeclaration of 'Amb'}} // expected-error@-1 {{invalid redeclaration of 'Amb'}}
// expected-note@-2 {{found this candidate}} // expected-note@-2 {{found candidate with type 'Amb'}}
extension Amb { // expected-error {{'Amb' is ambiguous for type lookup in this context}} extension Amb { // expected-error {{'Amb' is ambiguous for type lookup in this context}}
func extensionMethodUsesClassTypes() { func extensionMethodUsesClassTypes() {