Skip to content

embedded: fix a crash when specializing a generic class method with an indirect return value #73172

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
merged 1 commit into from
Apr 22, 2024
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/SILOptimizer/Utils/Generics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ getReturnTypeCategory(const SILResultInfo &RI,
const SILFunctionConventions &substConv,
TypeExpansionContext typeExpansion) {
auto ResultTy = substConv.getSILType(RI, typeExpansion);
ResultTy = Callee->mapTypeIntoContext(ResultTy);
ResultTy = mapTypeIntoContext(ResultTy);
auto &TL = getModule().Types.getTypeLowering(ResultTy, typeExpansion);

if (!TL.isLoadable())
Expand Down
25 changes: 25 additions & 0 deletions test/embedded/classes-indirect-return.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %target-swift-emit-sil %s -enable-experimental-feature Embedded -wmo | %FileCheck %s

// REQUIRES: swift_in_compiler

// CHECK: sil @$s4main1XC3fooxyFSi_Tg5 : $@convention(method) (@guaranteed X<Int>) -> Int {

// CHECK-LABEL: sil_vtable $X<Int>
// CHECK: #X.foo: <T> (X<T>) -> () -> T : @$s4main1XC3fooxyFSi_Tg5
// CHECK: }

open class X<T> {

var t: T

init(t: T) {
self.t = t
}

open func foo() -> T { t }
}

func testit() -> Int {
let x = X(t: 27)
return x.foo()
}