Skip to content

DeserializeSIL: Fix two places where we want the SILType inside of the current function according to the TypeExpansionContext #28901

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
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: 2 additions & 2 deletions lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
// two values in the list are the basic block identifiers.
auto Ty = MF->getType(TyID);
auto Ty2 = MF->getType(TyID2);
SILType FnTy = getSILType(Ty, SILValueCategory::Object, nullptr);
SILType FnTy = getSILType(Ty, SILValueCategory::Object, Fn);
SILType SubstFnTy = getSILType(Ty2, SILValueCategory::Object, Fn);

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

SubstitutionMap Substitutions = MF->getSubstitutionMap(NumSubs);
Expand Down
18 changes: 18 additions & 0 deletions test/Serialization/Inputs/opaque_types_inlineable_2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public protocol P {}

public struct M<T : P> : P {
public init(t: T) {}
}
extension Int : P {}

extension P {
@inlinable
public func o<T : P>(_ t: T) -> some P {
return M<T>(t: t)
}

@inlinable
public func p() throws -> some P {
return Int()
}
}
29 changes: 29 additions & 0 deletions test/Serialization/opaque_types_inlineable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -module-name A -emit-module %s %S/Inputs/opaque_types_inlineable_2.swift

// This test case use to crash in the merge modules phase when the two partial
// modules are merged as one deserializing the module for this file now has
// access to opaque types in the other file (opaque_types_inlineable_2.swift).

extension P {
@inlinable
public func r() -> some P {
return f { self.o(Q()) }
}

@inlinable
public func q() throws -> some P {
return try p()
}
}

public func f<T : P>(_ fn: () -> T) -> some P {
return K()
}

public struct K : P {
public init() {}
}

public struct Q : P {
public init() {}
}