Skip to content

Commit

Permalink
Expose lookup functions through TypedProgram
Browse files Browse the repository at this point in the history
  • Loading branch information
tothambrus11 committed Jun 13, 2024
1 parent f6ee33c commit 26f19c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3169,7 +3169,7 @@ struct TypeChecker {
/// without qualification.
///
/// - Requires: The imports of the module containing `scopeOfUse` have been configured.
private mutating func lookup(
mutating func lookup(
unqualified stem: String, in scopeOfUse: AnyScopeID
) -> Set<AnyDeclID> {
var matches = Set<AnyDeclID>()
Expand Down Expand Up @@ -3289,7 +3289,7 @@ struct TypeChecker {

/// Returns the declarations that introduce a name with given `stem` as member of `nominalScope`
/// and are exposed to `scopeOfUse`.
private mutating func lookup(
mutating func lookup(
_ stem: String, memberOf nominalScope: AnyType, exposedTo scopeOfUse: AnyScopeID
) -> Set<AnyDeclID> {
switch nominalScope.base {
Expand Down
20 changes: 20 additions & 0 deletions Sources/FrontEnd/TypedProgram.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ public struct TypedProgram {
}
}

/// Returns the declarations that introduce an entity with given `stem` exposed to `scopeOfUse`
/// without qualification.
///
/// - Requires: The imports of the module containing `scopeOfUse` have been configured.
public func lookup(
unqualified stem: String, in scopeOfUse: AnyScopeID
) -> Set<AnyDeclID> {
var checker = TypeChecker(asContextFor: self)
return checker.lookup(unqualified: stem, in: scopeOfUse)

Check warning on line 203 in Sources/FrontEnd/TypedProgram.swift

View check run for this annotation

Codecov / codecov/patch

Sources/FrontEnd/TypedProgram.swift#L201-L203

Added lines #L201 - L203 were not covered by tests
}

/// Returns the declarations that introduce a name with given `stem` as member of `nominalScope`
/// and are exposed to `scopeOfUse`.
public func lookup(
_ stem: String, memberOf nominalScope: AnyType, exposedTo scopeOfUse: AnyScopeID
) -> Set<AnyDeclID> {
var checker = TypeChecker(asContextFor: self)
return checker.lookup(stem, memberOf: nominalScope, exposedTo: scopeOfUse)

Check warning on line 212 in Sources/FrontEnd/TypedProgram.swift

View check run for this annotation

Codecov / codecov/patch

Sources/FrontEnd/TypedProgram.swift#L210-L212

Added lines #L210 - L212 were not covered by tests
}

/// Returns `true` iff deinitializing an instance of `t` in `scopeOfUse` is a no-op.
///
/// A type is "trivially deinitializable" if deinitializing its instances doesn't have runtime
Expand Down

0 comments on commit 26f19c2

Please sign in to comment.