Skip to content

Commit fd38724

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents a1a71ac + a6464da commit fd38724

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,20 @@ void ConstraintSystem::PotentialBindings::addPotentialBinding(
224224

225225
bool ConstraintSystem::PotentialBindings::isViable(
226226
PotentialBinding &binding) const {
227-
// Prevent against checking against the same bound generic type
227+
// Prevent against checking against the same opened nominal type
228228
// over and over again. Doing so means redundant work in the best
229229
// case. In the worst case, we'll produce lots of duplicate solutions
230230
// for this constraint system, which is problematic for overload
231231
// resolution.
232232
auto type = binding.BindingType;
233233
if (type->hasTypeVariable()) {
234-
auto *BGT = type->getAs<BoundGenericType>();
235-
if (!BGT)
234+
auto *NTD = type->getAnyNominal();
235+
if (!NTD)
236236
return true;
237237

238238
for (auto &existing : Bindings) {
239-
auto existingBGT = existing.BindingType->getAs<BoundGenericType>();
240-
if (!existingBGT)
241-
continue;
242-
243-
if (BGT != existingBGT && BGT->getDecl() == existingBGT->getDecl())
239+
auto *existingNTD = existing.BindingType->getAnyNominal();
240+
if (existingNTD && NTD == existingNTD)
244241
return false;
245242
}
246243
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %scale-test --begin 1 --end 30 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
struct A<T> {
6+
struct B {
7+
init(_: T) {}
8+
}
9+
}
10+
11+
public func test(_ fn: @escaping () -> Void) {}
12+
test {
13+
let _ = [
14+
%for i in range(0, N):
15+
A.B(1),
16+
%end
17+
A.B(1.0)
18+
]
19+
}

0 commit comments

Comments
 (0)