Skip to content

Commit e219249

Browse files
authored
Keep more ParenType parameter flags when canonicalizing function types (#17369) (#17380)
This will also preserve @escaping and @autoclosure, which were previously dropped. This could lead to mismatches between expected and actual canonical types for serialization cross-references. https://bugs.swift.org/browse/SR-8045, likely others (cherry picked from commit 8abaaea)
1 parent 5163888 commit e219249

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/AST/Type.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,8 @@ getCanonicalInputType(AnyFunctionType *funcType,
10611061

10621062
auto flags = ParameterTypeFlags().withInOut(inputType->is<InOutType>());
10631063
if (auto *parenTy = dyn_cast<ParenType>(origInputType.getPointer())) {
1064-
auto parenFlags = parenTy->getParameterFlags();
1065-
flags =
1066-
flags.withShared(parenFlags.isShared()).withOwned(parenFlags.isOwned());
1064+
flags = parenTy->getParameterFlags().withInOut(flags.isInOut());
1065+
assert(!flags.isVariadic() && "variadic ParenType");
10671066
}
10681067

10691068
inputType = ParenType::get(inputType->getASTContext(),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public typealias Alias<T> = (T) -> ()
2+
3+
public class Super {
4+
public func foo(_ f: @escaping Alias<Bool>) {}
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -emit-module-path %t/main.swiftmodule -module-name main %s %S/Inputs/SR8045-other.swift
3+
4+
public class Sub: Super {
5+
public override func foo(_ f: @escaping Alias<Bool>) {}
6+
}

0 commit comments

Comments
 (0)