Skip to content

[Serialization] Allow unbound generic types to cross-reference typealias decls #16784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3943,7 +3943,9 @@ void Serializer::writeType(Type ty) {

unsigned abbrCode = DeclTypeAbbrCodes[UnboundGenericTypeLayout::Code];
UnboundGenericTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
addDeclRef(generic->getDecl()),
addDeclRef(generic->getDecl(),
/*forceSerialization*/false,
/*allowTypeAliasXRef*/true),
addTypeRef(generic->getParent()));
break;
}
Expand Down
3 changes: 3 additions & 0 deletions test/Serialization/Inputs/alias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ public struct Outer { public typealias G<T> = T }
public typealias GG = Outer.G

public typealias GInt = Outer.G<Int>

public struct UnboundStruct<T> {}
public typealias UnboundAlias<T: Comparable> = UnboundStruct<T>
3 changes: 3 additions & 0 deletions test/Serialization/typealias.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -module-name alias -emit-module -o %t %S/Inputs/alias.swift
// RUN: %target-build-swift -I %t %s -module-name typealias -emit-module-path %t/typealias.swiftmodule -o %t/typealias.o
// RUN: llvm-bcanalyzer %t/alias.swiftmodule | %FileCheck %s
// RUN: %target-build-swift -I %t %s -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck -check-prefix=OUTPUT %s
Expand Down Expand Up @@ -53,3 +54,5 @@ func check(_: BaseAlias) {

let x: GG<Int> = 0
let x2: GInt = 1

public typealias TestUnbound = UnboundAlias