Skip to content

Commit c06fe98

Browse files
Merge pull request #68330 from aschwaighofer/private_opaque_irgen_type_lowering
Fix IRGenModule::getMaximalTypeExpansionContext to use the proper associated context
2 parents 43b6117 + 1b8e20e commit c06fe98

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ const llvm::StringRef IRGenerator::getClangDataLayoutString() {
20172017
}
20182018

20192019
TypeExpansionContext IRGenModule::getMaximalTypeExpansionContext() const {
2020-
return TypeExpansionContext::maximal(getSwiftModule(),
2020+
return TypeExpansionContext::maximal(getSILModule().getAssociatedContext(),
20212021
getSILModule().isWholeModule());
20222022
}
20232023

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public protocol P {
2+
associatedtype A : P
3+
func d() -> Self.A
4+
}
5+
6+
public struct B<Content: P> {
7+
public var a: Content.A
8+
init(_ v: Content) {
9+
a = v.d()
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -c -primary-file %s %S/Inputs/opaque_result_type_private_2.swift
2+
3+
// This test used to crash during IRGen.
4+
5+
private struct C : P {
6+
var x = 1
7+
func d() -> some P {
8+
return self
9+
}
10+
}
11+
12+
public func test() {
13+
var x = B(C())
14+
print(x)
15+
}

0 commit comments

Comments
 (0)