[Compile Time Constant Extraction] Emit underlying types for typealias types

Resolves rdar://113402135
This commit is contained in:
Artem Chikin
2023-08-18 10:34:40 -07:00
parent c33f69dbe9
commit faa9751c37
3 changed files with 22 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ std::string toFullyQualifiedTypeNameString(const swift::Type &Type) {
Options.AlwaysDesugarArraySliceTypes = true;
Options.AlwaysDesugarDictionaryTypes = true;
Options.AlwaysDesugarOptionalTypes = true;
Options.PrintTypeAliasUnderlyingType = true;
Options.OpaqueReturnTypePrinting =
PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword;
Type.print(OutputStream, Options);

View File

@@ -321,7 +321,7 @@ extension String: Foo {}
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "label": "tuple3",
// CHECK-NEXT: "type": "Swift.Void",
// CHECK-NEXT: "type": "()",
// CHECK-NEXT: "mangledTypeName": "n/a - deprecated",
// CHECK-NEXT: "isStatic": "false",
// CHECK-NEXT: "isComputed": "false",

View File

@@ -0,0 +1,20 @@
// RUN: %empty-directory(%t)
// RUN: echo "[MyProto]" > %t/protocols.json
// RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractTypeAliasUnderlyingType.swiftconstvalues -const-gather-protocols-file %t/protocols.json -primary-file %s
// RUN: cat %t/ExtractTypeAliasUnderlyingType.swiftconstvalues 2>&1 | %FileCheck %s
protocol MyProto {}
public struct SomeStruct {
typealias SomeTypeAlias = String
}
public struct Foo: MyProto {
var name: SomeStruct.SomeTypeAlias?
}
// CHECK: "properties": [
// CHECK-NEXT: {
// CHECK-NEXT: "label": "name",
// CHECK-NEXT: "type": "Swift.Optional<Swift.String>",