Skip to content

Commit 996e720

Browse files
committed
[ASTGen] Gnerate PlaceholderTypeRepr
1 parent da31340 commit 996e720

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

include/swift/AST/ASTBridging.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,11 @@ BridgedOwnershipTypeRepr BridgedOwnershipTypeRepr_createParsed(
26962696
BridgedASTContext cContext, BridgedTypeRepr base,
26972697
BridgedParamSpecifier cSpecifier, BridgedSourceLoc cSpecifierLoc);
26982698

2699+
SWIFT_NAME("BridgedPlaceholderTypeRepr.createParsed(_:loc:)")
2700+
BridgedPlaceholderTypeRepr
2701+
BridgedPlaceholderTypeRepr_createParsed(BridgedASTContext cContext,
2702+
BridgedSourceLoc cLoc);
2703+
26992704
SWIFT_NAME("BridgedProtocolTypeRepr.createParsed(_:base:protocolKeywordLoc:)")
27002705
BridgedProtocolTypeRepr
27012706
BridgedProtocolTypeRepr_createParsed(BridgedASTContext cContext,

lib/AST/Bridging/TypeReprBridging.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ BridgedOwnershipTypeRepr BridgedOwnershipTypeRepr_createParsed(
141141
base.unbridged(), unbridge(cSpecifier), cSpecifierLoc.unbridged());
142142
}
143143

144+
BridgedPlaceholderTypeRepr
145+
BridgedPlaceholderTypeRepr_createParsed(BridgedASTContext cContext,
146+
BridgedSourceLoc cLoc) {
147+
return new (cContext.unbridged()) PlaceholderTypeRepr(cLoc.unbridged());
148+
}
149+
144150
BridgedProtocolTypeRepr
145151
BridgedProtocolTypeRepr_createParsed(BridgedASTContext cContext,
146152
BridgedTypeRepr baseType,

lib/ASTGen/Sources/ASTGen/Types.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ extension ASTGenVisitor {
7070
if node.name.keywordKind == .Any && node.genericArgumentClause == nil {
7171
return BridgedCompositionTypeRepr.createEmpty(self.ctx, anyKeywordLoc: loc).asTypeRepr
7272
}
73+
if node.name.rawText == "_" {
74+
guard node.genericArgumentClause == nil else {
75+
// TODO: Diagnose.
76+
fatalError()
77+
// return BridgedErrorTypeRepr.create()
78+
}
79+
return BridgedPlaceholderTypeRepr.createParsed(
80+
self.ctx,
81+
loc: loc
82+
).asTypeRepr
83+
}
7384

7485
let id = self.generateIdentifier(node.name)
7586

test/ASTGen/types.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ struct SomeGlobalActor {
7070
typealias SomeGlobalActorIsolated = @SomeGlobalActor () -> Void
7171
typealias TestSpecifiers<Value, Result, E> = (inout sending Value) throws(E) -> sending Result where Value: ~Copyable, Result: ~Copyable, E: Error
7272
typealias TestSpecifierAndAttr<T> = (__owned @Sendable @escaping () async -> T) -> T
73+
74+
let globalOptionalInt: _? = 42
75+
let optionalIntArray: Array<_> = [42]

0 commit comments

Comments
 (0)