Skip to content

Commit e39dd6a

Browse files
committed
IDE: Tidy up some GenericEnvironment usages
1 parent 1ae370a commit e39dd6a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/IDE/ConformingMethodList.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ void ConformingMethodListCallbacks::doneParsing(SourceFile *SrcFile) {
124124
return;
125125

126126
T = T->getRValueType();
127-
if (T->hasArchetype())
128-
T = T->mapTypeOutOfContext();
129127

130128
// If there are no (instance) members for this type, bail.
131129
if (!T->mayHaveMembers() || T->is<ModuleType>()) {
132130
return;
133131
}
134132

133+
auto interfaceTy = T;
134+
if (T->hasArchetype())
135+
interfaceTy = interfaceTy->mapTypeOutOfContext();
136+
135137
llvm::SmallPtrSet<ProtocolDecl*, 8> expectedProtocols;
136138
for (auto Name: ExpectedTypeNames) {
137139
if (auto *PD = resolveProtocolName(CurDeclContext, Name)) {
@@ -140,7 +142,7 @@ void ConformingMethodListCallbacks::doneParsing(SourceFile *SrcFile) {
140142
}
141143

142144
// Collect the matching methods.
143-
ConformingMethodListResult result(CurDeclContext, T);
145+
ConformingMethodListResult result(CurDeclContext, interfaceTy);
144146
getMatchingMethods(T, expectedProtocols, result.Members);
145147

146148
Consumer.handleResult(result);

lib/IDE/TypeContextInfo.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,19 @@ void ContextInfoCallbacks::doneParsing(SourceFile *SrcFile) {
133133
continue;
134134

135135
T = T->getRValueType();
136-
if (T->hasArchetype())
137-
T = T->mapTypeOutOfContext();
138136

139-
// TODO: Do we need '.none' for Optionals?
140-
auto objT = T->lookThroughAllOptionalTypes();
141-
142-
if (auto env = CurDeclContext->getGenericEnvironmentOfContext())
143-
objT = env->mapTypeIntoContext(T);
137+
auto interfaceTy = T;
138+
if (interfaceTy->hasArchetype())
139+
interfaceTy = interfaceTy->mapTypeOutOfContext();
144140

145-
if (!seenTypes.insert(objT->getCanonicalType()).second)
141+
// TODO: Do we need '.none' for Optionals?
142+
auto objTy = T->lookThroughAllOptionalTypes();
143+
if (!seenTypes.insert(objTy->getCanonicalType()).second)
146144
continue;
147145

148-
results.emplace_back(T);
146+
results.emplace_back(interfaceTy);
149147
auto &item = results.back();
150-
getImplicitMembers(objT, item.ImplicitMembers);
148+
getImplicitMembers(objTy, item.ImplicitMembers);
151149
}
152150

153151
Consumer.handleResults(results);

0 commit comments

Comments
 (0)