Skip to content

Commit d330b3a

Browse files
authored
Merge pull request #250 from ahoppen/ahoppen/no-optional-collection-nodes
Update for the fact that syntax collections are always non-optional in SwiftSyntax now
2 parents acda54a + 2898814 commit d330b3a

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

SwiftEvolve/Sources/SwiftEvolve/DeclContext.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public protocol Decl {
155155
var isResilient: Bool { get }
156156
var isStored: Bool { get }
157157

158-
var modifiers: DeclModifierListSyntax? { get }
158+
var modifiers: DeclModifierListSyntax { get }
159159

160160
func lookupDirect(_ name: String) -> Decl?
161161
}
@@ -165,7 +165,7 @@ public extension Decl {
165165
var isStored: Bool { return false }
166166

167167
var formalAccessLevel: AccessLevel {
168-
return modifiers?.lazy.compactMap { $0.accessLevel }.first ?? .internal
168+
return modifiers.lazy.compactMap { $0.accessLevel }.first ?? .internal
169169
}
170170
}
171171

@@ -197,7 +197,7 @@ public extension Decl where Self: AbstractFunctionDecl {
197197
extension SourceFileSyntax: Decl {
198198
public var nameString: String { return "(file)" }
199199

200-
public var modifiers: DeclModifierListSyntax? { return nil }
200+
public var modifiers: DeclModifierListSyntax { return [] }
201201

202202
public func lookupDirect(_ name: String) -> Decl? {
203203
for item in statements {
@@ -450,17 +450,17 @@ extension IfConfigDeclSyntax {
450450

451451
// MARK: - Helpers
452452

453-
extension Optional where Wrapped == AttributeListSyntax {
453+
extension AttributeListSyntax {
454454
func contains(named name: String) -> Bool {
455-
return self?.contains {
455+
return self.contains {
456456
if let builtinAttribute = $0.as(AttributeSyntax.self) {
457457
// FIXME: Attribute name is a TypeSyntax, so .description isn't quite
458458
// right here (e.g. @MyCustomAttribute<MyTypeParam> is valid)
459459
return builtinAttribute.attributeName.description == name
460460
} else {
461461
preconditionFailure("unhandled AttributeListSyntax element kind")
462462
}
463-
} ?? false
463+
}
464464
}
465465
}
466466

SwiftEvolve/Sources/SwiftEvolve/Evolution.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,9 @@ extension SynthesizeMemberwiseInitializerEvolution {
293293
let evolved = inits.reduce(members) { members, properties in
294294
let parameters = properties.mapToFunctionParameterClause {
295295
FunctionParameterSyntax(
296-
attributes: nil,
297-
modifiers: nil,
298296
firstName: .identifier($0.name),
299-
secondName: nil,
300297
colon: .colonToken(trailingTrivia: [.spaces(1)]),
301-
type: TypeSyntax(IdentifierTypeSyntax(name: .identifier($0.type), genericArgumentClause: nil)),
302-
ellipsis: nil,
303-
defaultValue: nil,
304-
trailingComma: nil
298+
type: TypeSyntax(IdentifierTypeSyntax(name: .identifier($0.type), genericArgumentClause: nil))
305299
)
306300
}
307301

@@ -315,8 +309,6 @@ extension SynthesizeMemberwiseInitializerEvolution {
315309
let signature = FunctionSignatureSyntax(parameterClause: parameters)
316310

317311
let newInitializer = InitializerDeclSyntax(
318-
attributes: nil,
319-
modifiers: nil,
320312
initKeyword: .keyword(.`init`,
321313
leadingTrivia: [
322314
.newlines(2),
@@ -325,10 +317,7 @@ extension SynthesizeMemberwiseInitializerEvolution {
325317
],
326318
trailingTrivia: []
327319
),
328-
optionalMark: nil,
329-
genericParameterClause: nil,
330320
signature: signature,
331-
genericWhereClause: nil,
332321
body: body
333322
)
334323

0 commit comments

Comments
 (0)