Skip to content

[silgen] When transforming values into an existential box representat… #17085

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
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ ManagedValue SILGenFunction::emitExistentialErasure(
ExistentialRepresentation::Boxed, *this);
ManagedValue mv = F(SGFContext(&init));
if (!mv.isInContext()) {
mv.forwardInto(*this, loc, init.getAddress());
mv.ensurePlusOne(*this, loc).forwardInto(*this, loc, init.getAddress());
init.finishInitialization(*this);
}

Expand Down
24 changes: 24 additions & 0 deletions test/SILGen/function_conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,27 @@ func rdar35702810_anyhashable() {
// CHECK: convert_escape_to_noescape [not_guaranteed] [[PA]] : $@callee_guaranteed (@guaranteed Set<B>) -> () to $@noescape @callee_guaranteed (@guaranteed Set<B>) -> ()
bar_set(type: B.self, fn_set)
}

// ==== Function conversion with parameter substToOrig reabstraction.

struct FunctionConversionParameterSubstToOrigReabstractionTest {
typealias SelfTy = FunctionConversionParameterSubstToOrigReabstractionTest

class Klass: Error {}

struct Foo<T> {
static func enum1Func(_ : (T) -> Foo<Error>) -> Foo<Error> {
// Just to make it compile.
return Optional<Foo<Error>>.none!
}
}

static func bar<T>(t: T) -> Foo<T> {
// Just to make it compile.
return Optional<Foo<T>>.none!
}

static func testFunc() -> Foo<Error> {
return Foo<Klass>.enum1Func(SelfTy.bar)
}
}