Skip to content

Commit

Permalink
Rename 'traitDefining' for consistency with 'requirementDeclaring'
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Oct 16, 2023
1 parent 6ac13e0 commit 81361f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/FrontEnd/TypedProgram.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ public struct TypedProgram {
}

/// Returns the trait of which `d` is a member, or `nil` if `d` isn't member of a trait.
public func traitDefining<T: DeclID>(_ d: T) -> TraitType? {
public func traitDeclaring<T: DeclID>(_ d: T) -> TraitType? {
var checker = TypeChecker(asContextFor: self)
return checker.traitDefining(d)
}

/// If `d` is member of a trait `c`, returns `(d, c)` if `d` is a requirement, or `(r, c)` if `d`
/// is a default implementation of a requirement `r`. Otherwise, returns `nil`.
public func requirementDeclaring(_ d: AnyDeclID) -> (decl: AnyDeclID, trait: TraitType)? {
guard let c = traitDefining(d) else { return nil }
guard let c = traitDeclaring(d) else { return nil }

// `d` might be the default definition of itself.
if isRequirement(d) { return (d, c) }
Expand Down
2 changes: 1 addition & 1 deletion Sources/IR/TypedProgram+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension TypedProgram {
func traitMember(referredBy f: Function.ID) -> (declaration: AnyDeclID, trait: TraitType)? {
switch f.value {
case .lowered(let d):
guard let t = traitDefining(d) else { return nil }
guard let t = traitDeclaring(d) else { return nil }
return (declaration: d, trait: t)

default:
Expand Down

0 comments on commit 81361f5

Please sign in to comment.