Skip to content

Commit 0fe1f78

Browse files
authored
Merge pull request #68012 from artemcm/59ConstExtractTypeAliasUnderlyingType
[5.9 🍒][Compile Time Constant Extraction] Emit underlying types for typealias types
2 parents bc58dd5 + c93eb0e commit 0fe1f78

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

lib/ConstExtract/ConstExtract.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ std::string toFullyQualifiedTypeNameString(const swift::Type &Type) {
7171
Options.AlwaysDesugarArraySliceTypes = true;
7272
Options.AlwaysDesugarDictionaryTypes = true;
7373
Options.AlwaysDesugarOptionalTypes = true;
74+
Options.PrintTypeAliasUnderlyingType = true;
7475
Options.OpaqueReturnTypePrinting =
7576
PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword;
7677
Type.print(OutputStream, Options);

test/ConstExtraction/ExtractGroups.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ extension String: Foo {}
321321
// CHECK-NEXT: },
322322
// CHECK-NEXT: {
323323
// CHECK-NEXT: "label": "tuple3",
324-
// CHECK-NEXT: "type": "Swift.Void",
324+
// CHECK-NEXT: "type": "()",
325325
// CHECK-NEXT: "mangledTypeName": "n/a - deprecated",
326326
// CHECK-NEXT: "isStatic": "false",
327327
// CHECK-NEXT: "isComputed": "false",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo "[MyProto]" > %t/protocols.json
3+
4+
// RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractTypeAliasUnderlyingType.swiftconstvalues -const-gather-protocols-file %t/protocols.json -primary-file %s
5+
// RUN: cat %t/ExtractTypeAliasUnderlyingType.swiftconstvalues 2>&1 | %FileCheck %s
6+
7+
protocol MyProto {}
8+
9+
public struct SomeStruct {
10+
typealias SomeTypeAlias = String
11+
}
12+
13+
public struct Foo: MyProto {
14+
var name: SomeStruct.SomeTypeAlias?
15+
}
16+
17+
// CHECK: "properties": [
18+
// CHECK-NEXT: {
19+
// CHECK-NEXT: "label": "name",
20+
// CHECK-NEXT: "type": "Swift.Optional<Swift.String>",

0 commit comments

Comments
 (0)