AST: Allow mangling LocatableType in DWARF mode

Fixes rdar://problem/145954323.
This commit is contained in:
Slava Pestov
2025-03-04 19:46:56 -05:00
parent d98d6fd6fe
commit a03b8ee6aa
3 changed files with 38 additions and 2 deletions

View File

@@ -1379,8 +1379,12 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
case TypeKind::BuiltinUnsafeValueBuffer:
return appendOperator("BB");
case TypeKind::BuiltinUnboundGeneric:
case TypeKind::Locatable:
llvm_unreachable("not a real type");
llvm::errs() << "Don't know how to mangle a BuiltinUnboundGenericType\n";
abort();
case TypeKind::Locatable: {
auto loc = cast<LocatableType>(tybase);
return appendType(loc->getSinglyDesugaredType(), sig, forDecl);
}
case TypeKind::BuiltinFixedArray: {
auto bfa = cast<BuiltinFixedArrayType>(tybase);
appendType(bfa->getSize(), sig, forDecl);

View File

@@ -0,0 +1,13 @@
@resultBuilder
public struct Builder {
@_alwaysEmitIntoClient
public static func buildExpression<X>(_ x: X) -> X {x}
@_alwaysEmitIntoClient
public static func buildBlock<X>(_ x: X) -> X {x}
}
public struct View<X> {
public init(@Builder _: () -> X) {}
public func closure(_: () -> Void) {}
}

View File

@@ -0,0 +1,19 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %S/Inputs/result_builder.swift -emit-module -emit-module-path %t/result_builder.swiftmodule
// RUN: %target-swift-frontend -emit-ir %s -I %t -g -O
// FIXME: Devise a test case that does not involve -O.
import result_builder
struct S {
static func foo(_ s: S?) -> S? {s}
static func foo(_ s: S) -> S {s}
}
public func test() {
View { View { S() } }
.closure {
let _: S? = .foo(S())
}
}