Skip to content

Commit 0e45890

Browse files
committed
Sema: Remove hack introduced by 31245556
It looks like Type::subst() was subsequently fixed for GenericFunctionTypes in 06d1679 so we can remove this hack.
1 parent 7b73135 commit 0e45890

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

lib/Sema/LookupVisibleDecls.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -763,17 +763,6 @@ template <> struct DenseMapInfo<FoundDeclTy> {
763763

764764
namespace {
765765

766-
/// Hack to guess at whether substituting into the type of a declaration will
767-
/// be okay.
768-
/// FIXME: This is awful. We should either have Type::subst() work for
769-
/// GenericFunctionType, or we should kill it outright.
770-
static bool shouldSubstIntoDeclType(Type type) {
771-
auto genericFnType = type->getAs<GenericFunctionType>();
772-
if (!genericFnType) return true;
773-
774-
return false;
775-
}
776-
777766
class OverrideFilteringConsumer : public VisibleDeclConsumer {
778767
public:
779768
std::set<ValueDecl *> AllFoundDecls;
@@ -865,8 +854,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
865854

866855
auto FoundSignature = VD->getOverloadSignature();
867856
auto FoundSignatureType = VD->getOverloadSignatureType();
868-
if (FoundSignatureType && shouldSubst &&
869-
shouldSubstIntoDeclType(FoundSignatureType)) {
857+
if (FoundSignatureType && shouldSubst) {
870858
auto subs = BaseTy->getMemberSubstitutionMap(M, VD);
871859
if (auto CT = FoundSignatureType.subst(subs))
872860
FoundSignatureType = CT->getCanonicalType();
@@ -883,8 +871,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
883871

884872
auto OtherSignature = OtherVD->getOverloadSignature();
885873
auto OtherSignatureType = OtherVD->getOverloadSignatureType();
886-
if (OtherSignatureType && shouldSubst &&
887-
shouldSubstIntoDeclType(OtherSignatureType)) {
874+
if (OtherSignatureType && shouldSubst) {
888875
auto subs = BaseTy->getMemberSubstitutionMap(M, OtherVD);
889876
if (auto CT = OtherSignatureType.subst(subs))
890877
OtherSignatureType = CT->getCanonicalType();

test/IDE/complete_from_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func testArchetypeReplacement2<BAR : Equatable>(_ a: [BAR]) {
148148
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/CurrNominal: append({#(newElement): Equatable#})[#Void#]{{; name=.+}}
149149
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/CurrNominal: insert({#(newElement): Equatable#}, {#at: Int#})[#Void#]{{; name=.+}}
150150
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropFirst()[#ArraySlice<Equatable>#]{{; name=.+}}
151-
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropLast()[#ArraySlice<Equatable>#]{{; name=.+}}
151+
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropLast()[#[Equatable]#]{{; name=.+}}
152152
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: enumerated()[#EnumeratedSequence<[Equatable]>#]{{; name=.+}}
153153
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: min({#by: (Equatable, Equatable) throws -> Bool##(Equatable, Equatable) throws -> Bool#})[' rethrows'][#Equatable?#]{{; name=.+}}
154154
// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: max({#by: (Equatable, Equatable) throws -> Bool##(Equatable, Equatable) throws -> Bool#})[' rethrows'][#Equatable?#]{{; name=.+}}

test/IDE/complete_value_expr.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,10 +1850,13 @@ struct dedupS : dedupP {
18501850
func testDeDuped(_ x: dedupS) {
18511851
x#^PROTOCOL_EXT_DEDUP_1^#
18521852
// FIXME: Should produce 3 items (?)
1853-
// PROTOCOL_EXT_DEDUP_1: Begin completions, 7 items
1853+
1854+
// PROTOCOL_EXT_DEDUP_1: Begin completions, 6 items
18541855
// PROTOCOL_EXT_DEDUP_1: Decl[InstanceMethod]/CurrNominal: .foo()[#Int#]; name=foo()
18551856
// PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/CurrNominal: .bar[#Int#]; name=bar
18561857
// PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/CurrNominal: [{#Int#}][#Int#]; name=[Int]
1858+
// PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/Super: .bar[#Int#]; name=bar
1859+
// PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/Super: [{#Self.T#}][#Self.T#]; name=[Self.T]
18571860
// PROTOCOL_EXT_DEDUP_1: Keyword[self]/CurrNominal: .self[#dedupS#]; name=self
18581861
// PROTOCOL_EXT_DEDUP_1: End completions
18591862
}

0 commit comments

Comments
 (0)