Skip to content

Commit c9bd831

Browse files
committed
DeserializeSIL: Fix two places where we want the SILType inside of the current function according to the TypeExpansionContext
rdar://58095210
1 parent a99f24f commit c9bd831

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
14291429
// two values in the list are the basic block identifiers.
14301430
auto Ty = MF->getType(TyID);
14311431
auto Ty2 = MF->getType(TyID2);
1432-
SILType FnTy = getSILType(Ty, SILValueCategory::Object, nullptr);
1432+
SILType FnTy = getSILType(Ty, SILValueCategory::Object, Fn);
14331433
SILType SubstFnTy = getSILType(Ty2, SILValueCategory::Object, Fn);
14341434

14351435
SILBasicBlock *errorBB = getBBForReference(Fn, ListOfValues.back());
@@ -1455,7 +1455,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
14551455
case SILInstructionKind::PartialApplyInst: {
14561456
auto Ty = MF->getType(TyID);
14571457
auto Ty2 = MF->getType(TyID2);
1458-
SILType FnTy = getSILType(Ty, SILValueCategory::Object, nullptr);
1458+
SILType FnTy = getSILType(Ty, SILValueCategory::Object, Fn);
14591459
SILType closureTy = getSILType(Ty2, SILValueCategory::Object, Fn);
14601460

14611461
SubstitutionMap Substitutions = MF->getSubstitutionMap(NumSubs);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public protocol P {}
2+
3+
public struct M<T : P> : P {
4+
public init(t: T) {}
5+
}
6+
extension Int : P {}
7+
8+
extension P {
9+
@inlinable
10+
public func o<T : P>(_ t: T) -> some P {
11+
return M<T>(t: t)
12+
}
13+
14+
@inlinable
15+
public func p() throws -> some P {
16+
return Int()
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -module-name A -emit-module %s %S/Inputs/opaque_types_inlineable_2.swift
2+
3+
// This test case use to crash in the merge modules phase when the two partial
4+
// modules are merged as one deserializing the module for this file now has
5+
// access to opaque types in the other file (opaque_types_inlineable_2.swift).
6+
7+
extension P {
8+
@inlinable
9+
public func r() -> some P {
10+
return f { self.o(Q()) }
11+
}
12+
13+
@inlinable
14+
public func q() throws -> some P {
15+
return try p()
16+
}
17+
}
18+
19+
public func f<T : P>(_ fn: () -> T) -> some P {
20+
return K()
21+
}
22+
23+
public struct K : P {
24+
public init() {}
25+
}
26+
27+
public struct Q : P {
28+
public init() {}
29+
}

0 commit comments

Comments
 (0)