Skip to content

Commit bc3baaa

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 4f76d25 commit bc3baaa

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

lib/AST/LookupVisibleDecls.cpp

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

769769
namespace {
770770

771-
/// Hack to guess at whether substituting into the type of a declaration will
772-
/// be okay.
773-
/// FIXME: This is awful. We should either have Type::subst() work for
774-
/// GenericFunctionType, or we should kill it outright.
775-
static bool shouldSubstIntoDeclType(Type type) {
776-
auto genericFnType = type->getAs<GenericFunctionType>();
777-
if (!genericFnType) return true;
778-
779-
return false;
780-
}
781-
782771
class OverrideFilteringConsumer : public VisibleDeclConsumer {
783772
public:
784773
std::set<ValueDecl *> AllFoundDecls;
@@ -870,8 +859,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
870859

871860
auto FoundSignature = VD->getOverloadSignature();
872861
auto FoundSignatureType = VD->getOverloadSignatureType();
873-
if (FoundSignatureType && shouldSubst &&
874-
shouldSubstIntoDeclType(FoundSignatureType)) {
862+
if (FoundSignatureType && shouldSubst) {
875863
auto subs = BaseTy->getMemberSubstitutionMap(M, VD);
876864
if (auto CT = FoundSignatureType.subst(subs))
877865
FoundSignatureType = CT->getCanonicalType();
@@ -888,8 +876,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
888876

889877
auto OtherSignature = OtherVD->getOverloadSignature();
890878
auto OtherSignatureType = OtherVD->getOverloadSignatureType();
891-
if (OtherSignatureType && shouldSubst &&
892-
shouldSubstIntoDeclType(OtherSignatureType)) {
879+
if (OtherSignatureType && shouldSubst) {
893880
auto subs = BaseTy->getMemberSubstitutionMap(M, OtherVD);
894881
if (auto CT = OtherSignatureType.subst(subs))
895882
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)