Skip to content

Commit

Permalink
Keep more ParenType parameter flags when canonicalizing function types
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrose-apple committed Jun 20, 2018
1 parent 59e3450 commit ca179e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/AST/Type.cpp
Expand Up @@ -1062,9 +1062,8 @@ getCanonicalInputType(AnyFunctionType *funcType,

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

inputType = ParenType::get(inputType->getASTContext(),
Expand Down
5 changes: 5 additions & 0 deletions validation-test/Serialization/Inputs/SR8045-other.swift
@@ -0,0 +1,5 @@
public typealias Alias<T> = (T) -> ()

public class Super {
public func foo(_ f: @escaping Alias<Bool>) {}
}
6 changes: 6 additions & 0 deletions validation-test/Serialization/SR8045.swift
@@ -0,0 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -emit-module-path %t/main.swiftmodule -module-name main %s %S/Inputs/SR8045-other.swift

public class Sub: Super {
public override func foo(_ f: @escaping Alias<Bool>) {}
}

0 comments on commit ca179e6

Please sign in to comment.