Skip to content

Commit 0eaa4e1

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents 651b263 + f1690b0 commit 0eaa4e1

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ void ASTMangler::appendOpaqueDeclName(const OpaqueTypeDecl *opaqueDecl) {
736736
if (canSymbolicReference(opaqueDecl)) {
737737
appendSymbolicReference(opaqueDecl);
738738
} else if (auto namingDecl = opaqueDecl->getNamingDecl()) {
739+
CanGenericSignature savedSignature = CurGenericSignature;
739740
appendEntity(namingDecl);
741+
CurGenericSignature = savedSignature;
740742
appendOperator("QO");
741743
} else {
742744
llvm_unreachable("todo: independent opaque type decls");

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ add_custom_command_target(unused_var
123123
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
124124
add_dependencies(copy_shim_headers symlink_clang_headers)
125125

126+
if(NOT SWIFT_BUILT_STANDALONE)
127+
if(TARGET clang-resource-headers) # LLVM > 8
128+
set(clang_resource_headers clang-resource-headers)
129+
elseif(TARGET clang-headers) # LLVM <= 8
130+
set(clang_resource_headers clang-headers)
131+
else()
132+
message(SEND_ERROR
133+
"Unable to determine clang resource headers target in unified build")
134+
endif()
135+
136+
foreach(target
137+
symlink_clang_headers
138+
clang-builtin-headers
139+
clang-resource-dir-symlink
140+
clang-builtin-headers-in-clang-resource-dir)
141+
add_dependencies(${target} ${clang_resource_headers})
142+
endforeach()
143+
endif()
144+
126145
swift_install_in_component(FILES ${sources}
127146
DESTINATION "lib/swift/shims"
128147
COMPONENT stdlib)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
public protocol Proto {
2+
associatedtype Assoc : Proto
3+
var value: Assoc { get }
4+
}
5+
6+
extension Never : Proto {}
7+
8+
extension Never {
9+
public typealias Assoc = Never
10+
11+
public var value: Never {
12+
switch self {}
13+
}
14+
}
15+
protocol PrimitiveProto : Proto {}
16+
17+
extension PrimitiveProto {
18+
public var value: Never { valueError() }
19+
}
20+
21+
extension Proto {
22+
func valueError() -> Never {
23+
fatalError("value() should not be called on \(Self.self).")
24+
}
25+
}
26+
27+
public struct EmptyProto : PrimitiveProto {
28+
public init() {}
29+
}
30+
31+
struct M<Content: Proto> : Proto {
32+
var t: Content
33+
34+
init(_ t: Content) {
35+
self.t = t
36+
}
37+
38+
var value: some Proto {
39+
return t.value
40+
}
41+
}
42+
43+
public struct Group<T> {
44+
var t: T
45+
46+
public init(_ t: T) {
47+
self.t = t
48+
}
49+
}
50+
51+
extension Group : Proto, PrimitiveProto where T : Proto {
52+
public typealias Assoc = Never
53+
}
54+
55+
public struct Choice<T, V>{
56+
var v: V
57+
58+
public init(_ t: T, _ v: V) {
59+
self.v = v
60+
}
61+
}
62+
63+
extension Choice : Proto where T: Proto, V: Proto {
64+
public var value: some Proto {
65+
return v.value
66+
}
67+
}
68+
69+
extension Proto {
70+
public func add() -> some Proto {
71+
return M(self)
72+
}
73+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -disable-availability-checking -emit-module -enable-library-evolution -emit-module-path=%t/A.swiftmodule -module-name=A %S/Inputs/mangle-opaque-return-types-A.swift
3+
// RUN: %target-swift-frontend -disable-availability-checking -I %t -emit-ir %s
4+
import A
5+
6+
public struct C<T, Content: Proto> {
7+
let data: T
8+
let content: Content
9+
10+
init(_ t: T, _ c: Content) {
11+
data = t
12+
content = c
13+
}
14+
15+
public var dontCrash : some Proto {
16+
return Group(Choice(content, EmptyProto().add()))
17+
}
18+
}
19+

tools/SourceKit/lib/SwiftLang/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ add_sourcekit_library(SourceKitSwiftLang
4949
objcarcopts
5050
profiledata
5151
)
52+
53+
add_dependencies(SourceKitSwiftLang clang-tablegen-targets)

0 commit comments

Comments
 (0)