Skip to content

Commit adf11eb

Browse files
committed
Fix merge artifacts.
1 parent d8cb895 commit adf11eb

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

Sources/SwiftLexicalLookup/Scopes/GenericParameterOrAssociatedTypeScopeSyntax.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ import SwiftSyntax
3939
/// this method passes lookup to function scope's parent scope
4040
/// (in this case: file scope).
4141
@_spi(Experimental) public func lookup(
42-
identifier: Identifier?,
42+
_ identifier: Identifier?,
4343
at lookUpPosition: AbsolutePosition,
4444
with config: LookupConfig
4545
) -> [LookupResult] {
4646
return defaultLookupImplementation(
47-
identifier: identifier,
47+
identifier,
4848
at: lookUpPosition,
4949
with: config,
5050
propagateToParent: false
5151
)
5252
+ lookupBypassingParentResults(
53-
identifier: identifier,
53+
identifier,
5454
at: lookUpPosition,
5555
with: config
5656
)
@@ -75,7 +75,7 @@ import SwiftSyntax
7575
/// to pass lookup to the function scope's parent scope (in this case: file scope)
7676
/// and effectively bypass names already looked up before.
7777
private func lookupBypassingParentResults(
78-
identifier: Identifier?,
78+
_ identifier: Identifier?,
7979
at lookUpPosition: AbsolutePosition,
8080
with config: LookupConfig
8181
) -> [LookupResult] {
@@ -84,9 +84,9 @@ import SwiftSyntax
8484
if let parentScope = Syntax(parentScope).asProtocol(SyntaxProtocol.self)
8585
as? WithGenericParametersOrAssociatedTypesScopeSyntax
8686
{
87-
return parentScope.lookupInParent(identifier: identifier, at: lookUpPosition, with: config)
87+
return parentScope.lookupInParent(identifier, at: lookUpPosition, with: config)
8888
} else {
89-
return lookupInParent(identifier: identifier, at: lookUpPosition, with: config)
89+
return lookupInParent(identifier, at: lookUpPosition, with: config)
9090
}
9191
}
9292
}

Sources/SwiftLexicalLookup/Scopes/ScopeSyntax.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,18 @@ extension SyntaxProtocol {
8787
func defaultLookupImplementation(
8888
_ identifier: Identifier?,
8989
at lookUpPosition: AbsolutePosition,
90-
with config: LookupConfig
90+
with config: LookupConfig,
91+
propagateToParent: Bool = true
9192
) -> [LookupResult] {
9293
let filteredNames =
9394
introducedNames
9495
.filter { introducedName in
9596
checkIdentifier(identifier, refersTo: introducedName, at: lookUpPosition)
9697
}
9798

98-
if filteredNames.isEmpty {
99-
return lookupInParent(identifier, at: lookUpPosition, with: config)
100-
} else {
101-
return [.fromScope(self, withNames: filteredNames)]
102-
+ lookupInParent(identifier, at: lookUpPosition, with: config)
103-
}
99+
let fromThisScope = filteredNames.isEmpty ? [] : [LookupResult.fromScope(self, withNames: filteredNames)]
100+
101+
return fromThisScope + (propagateToParent ? lookupInParent(identifier, at: lookUpPosition, with: config) : [])
104102
}
105103

106104
/// Looks up in parent scope.

Sources/SwiftLexicalLookup/Scopes/WithGenericParametersOrAssociatedTypesScopeSyntax.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ import SwiftSyntax
3838
/// scope (`WithGenericParametersOrAssociatedTypesScopeSyntax`)
3939
/// instead of it's actual parent scope (in this case: file scope).
4040
@_spi(Experimental) public func lookup(
41-
identifier: Identifier?,
41+
_ identifier: Identifier?,
4242
at lookUpPosition: AbsolutePosition,
4343
with config: LookupConfig
4444
) -> [LookupResult] {
4545
return defaultLookupImplementation(
46-
identifier: identifier,
46+
identifier,
4747
at: position,
4848
with: config,
4949
propagateToParent: false
5050
)
5151
+ lookupThroughGenericParameterScope(
52-
identifier: identifier,
52+
identifier,
5353
at: lookUpPosition,
5454
with: config
5555
)
@@ -72,16 +72,16 @@ import SwiftSyntax
7272
/// scope (`WithGenericParametersOrAssociatedTypesScopeSyntax`)
7373
/// with this method (instead of using standard `lookupInParent`).
7474
private func lookupThroughGenericParameterScope(
75-
identifier: Identifier?,
75+
_ identifier: Identifier?,
7676
at lookUpPosition: AbsolutePosition,
7777
with config: LookupConfig
7878
) -> [LookupResult] {
7979
if let genericParameterClause {
80-
return genericParameterClause.lookup(identifier: identifier, at: lookUpPosition, with: config)
80+
return genericParameterClause.lookup(identifier, at: lookUpPosition, with: config)
8181
} else if let primaryAssociatedTypeClause {
82-
return primaryAssociatedTypeClause.lookup(identifier: identifier, at: lookUpPosition, with: config)
82+
return primaryAssociatedTypeClause.lookup(identifier, at: lookUpPosition, with: config)
8383
} else {
84-
return lookupInParent(identifier: identifier, at: lookUpPosition, with: config)
84+
return lookupInParent(identifier, at: lookUpPosition, with: config)
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)