Skip to content

Commit e27af10

Browse files
authored
Merge pull request #16784 from xedin/rdar-37384120
[Serialization] Allow unbound generic types to cross-reference typealias decls
2 parents 80c38cb + 7ed3d75 commit e27af10

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3943,7 +3943,9 @@ void Serializer::writeType(Type ty) {
39433943

39443944
unsigned abbrCode = DeclTypeAbbrCodes[UnboundGenericTypeLayout::Code];
39453945
UnboundGenericTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
3946-
addDeclRef(generic->getDecl()),
3946+
addDeclRef(generic->getDecl(),
3947+
/*forceSerialization*/false,
3948+
/*allowTypeAliasXRef*/true),
39473949
addTypeRef(generic->getParent()));
39483950
break;
39493951
}

test/Serialization/Inputs/alias.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ public struct Outer { public typealias G<T> = T }
3636
public typealias GG = Outer.G
3737

3838
public typealias GInt = Outer.G<Int>
39+
40+
public struct UnboundStruct<T> {}
41+
public typealias UnboundAlias<T: Comparable> = UnboundStruct<T>

test/Serialization/typealias.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-build-swift -module-name alias -emit-module -o %t %S/Inputs/alias.swift
3+
// RUN: %target-build-swift -I %t %s -module-name typealias -emit-module-path %t/typealias.swiftmodule -o %t/typealias.o
34
// RUN: llvm-bcanalyzer %t/alias.swiftmodule | %FileCheck %s
45
// RUN: %target-build-swift -I %t %s -o %t/a.out
56
// RUN: %target-run %t/a.out | %FileCheck -check-prefix=OUTPUT %s
@@ -53,3 +54,5 @@ func check(_: BaseAlias) {
5354

5455
let x: GG<Int> = 0
5556
let x2: GInt = 1
57+
58+
public typealias TestUnbound = UnboundAlias

0 commit comments

Comments
 (0)