Files
swift-mirror/test/IDE/complete_name_lookup.swift
Hamish Knight 669a2ce9b0 [CS] Sink placeholder handling logic into Solution::simplifyType
Move the logic from `FailureDiagnostic::resolveType` into
`Solution::simplifyType` to allow completion to use it too. While
here, also handle cases where the placeholder is from a different
member of the equivalence class to the generic parameter.
2025-10-04 12:56:52 +01:00

53 lines
2.3 KiB
Swift

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=FOO_OBJECT_DOT_1 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BAR_OBJECT_DOT_1 | %FileCheck %s -check-prefix=BAR_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CATCHSEQUENCE_DOT | %FileCheck %s -check-prefix=CATCHSEQUENCE_DOT
protocol FooBaseProtocol {
var instanceProperty: Int { get }
}
protocol FooRefinedProtocol : FooBaseProtocol {}
protocol FooMoreRefinedProtocol : FooRefinedProtocol {}
protocol FooEvenMoreRefinedProtocol : FooRefinedProtocol {}
struct FooStruct : FooMoreRefinedProtocol {
var instanceProperty: Int { return 0 }
}
// FOO_OBJECT_DOT: Begin completions, 2 items
// FOO_OBJECT_DOT-DAG: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
// FOO_OBJECT_DOT-DAG: Decl[InstanceVar]/CurrNominal: instanceProperty[#Int#]
struct BarStruct : FooEvenMoreRefinedProtocol {
var instanceProperty: Int { return 0 }
}
// BAR_OBJECT_DOT: Begin completions, 2 items
// BAR_OBJECT_DOT-DAG: Keyword[self]/CurrNominal: self[#BarStruct#]; name=self
// BAR_OBJECT_DOT-DAG: Decl[InstanceVar]/CurrNominal: instanceProperty[#Int#]
func test(a: FooStruct) {
a.#^FOO_OBJECT_DOT_1^#
}
func test(a: BarStruct) {
a.#^BAR_OBJECT_DOT_1^#
}
protocol ObservableConvertibleType {
associatedtype T
}
class Observable<T> : ObservableConvertibleType {}
class CatchSequence<S: Sequence>: Observable<S.Element.T> where S.Element: ObservableConvertibleType {}
extension ObservableConvertibleType {
static func catchError() -> Observable<T> {
return CatchSequence.#^CATCHSEQUENCE_DOT^#
}
}
// CATCHSEQUENCE_DOT-DAG: Keyword[self]/CurrNominal: self[#CatchSequence<S>.Type#]; name=self
// CATCHSEQUENCE_DOT-DAG: Keyword/CurrNominal: Type[#CatchSequence<S>.Type#]; name=Type
// CATCHSEQUENCE_DOT-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init()[#CatchSequence<S>#]; name=init()
// CATCHSEQUENCE_DOT-DAG: Decl[StaticMethod]/Super/TypeRelation[Convertible]: catchError()[#Observable<CatchSequence<S>.T>#]; name=catchError()
// CATCHSEQUENCE_DOT-DAG: Decl[TypeAlias]/Super: T[#Observable<S.Element.T>.T#]; name=T