Files
swift-mirror/test/DebugInfo/nested_opaque.swift
Augusto Noronha 7b46d41823 [DebugInfo] Fix infinite recursion when opaque return type is defined
inside function returning it

A stack overflow would happen when the compiler tried emitting debug
info for a function whose opaque return type was declared inside the
function itself. This fixes the issue by emitting a forward declaration
for the function before emitting it.

rdar://150313956

(cherry picked from commit c03831f70d)
2025-08-05 17:36:28 -07:00

15 lines
396 B
Swift

// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
protocol TheProtocol {
}
// CHECK: ![[FUNC_ID:[0-9]+]] = distinct !DISubprogram(name: "theFunction",
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "TheType", scope: ![[FUNC_ID]]
func theFunction() -> some TheProtocol {
struct TheType: TheProtocol {
}
return TheType()
}
theFunction()