Skip to content

Commit 8f713a9

Browse files
committed
AST: Fix swift::substOpaqueTypesWithUnderlyingTypes() to pass PreservePackExpansionLevel
Fixes rdar://problem/123645784.
1 parent ebd4e06 commit 8f713a9

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

lib/AST/Type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,10 +5364,10 @@ CanType swift::substOpaqueTypesWithUnderlyingTypes(CanType ty,
53645364
ReplaceOpaqueTypesWithUnderlyingTypes replacer(
53655365
context.getContext(), context.getResilienceExpansion(),
53665366
context.isWholeModuleContext());
5367-
SubstOptions flags = SubstFlags::SubstituteOpaqueArchetypes;
5367+
SubstOptions flags = (SubstFlags::SubstituteOpaqueArchetypes |
5368+
SubstFlags::PreservePackExpansionLevel);
53685369
if (allowLoweredTypes)
5369-
flags =
5370-
SubstFlags::SubstituteOpaqueArchetypes | SubstFlags::AllowLoweredTypes;
5370+
flags |= SubstFlags::AllowLoweredTypes;
53715371
return ty.subst(replacer, replacer, flags)->getCanonicalType();
53725372
}
53735373

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public protocol P {
2+
func f()
3+
}
4+
5+
public struct G<each T>: P {
6+
public func f() {}
7+
}
8+
9+
public func callee<each T>(_: repeat each T) -> some P {
10+
G<repeat each T>()
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-frontend -emit-silgen -primary-file %s %S/Inputs/variadic_generic_opaque_multifile_other.swift -disable-availability-checking
2+
// RUN: %target-swift-frontend -emit-silgen %s %S/Inputs/variadic_generic_opaque_multifile_other.swift -disable-availability-checking
3+
4+
public func caller() {
5+
callee(1, 2, 3).f()
6+
}

0 commit comments

Comments
 (0)