Skip to content

Commit

Permalink
Merge pull request #1558 from hylo-lang/eliminate-dead-code
Browse files Browse the repository at this point in the history
Eliminate dead code
  • Loading branch information
kyouko-taiga authored Aug 17, 2024
2 parents 61cf91c + 2367d77 commit b5bd439
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
43 changes: 0 additions & 43 deletions Sources/FrontEnd/TypeChecking/ConstraintSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,49 +230,6 @@ struct ConstraintSystem {
}
}

/// If `goal.model` is a structural type, creates and returns sub-goals checking that its parts
/// conform to `goal.concept`; returns `.failure` otherwise.
///
/// - Requires: `goal.concept` is a trait supporting structural conformances and `goal.model` is
/// not a type variable.
private mutating func solve(structuralConformance goal: ConformanceConstraint) -> Outcome {
let model = checker.canonical(goal.model, in: scope)
assert(!(model.base is TypeVariable))

switch model.base {
case let t as ArrowType:
return delegate(structuralConformance: goal, for: [t.environment])
case let t as TupleType:
return delegate(structuralConformance: goal, for: t.elements.lazy.map(\.type))
case let t as UnionType:
return delegate(structuralConformance: goal, for: t.elements)
default:
return .failure(failureToSolve(goal))
}
}

/// Returns the outcome of breaking down `goal`, which is a structural conformance constraint,
/// into a set containing a conformance constraint for each type in `elements`.
private mutating func delegate<S: Collection<AnyType>>(
structuralConformance goal: ConformanceConstraint, for elements: S
) -> Outcome {
if elements.isEmpty {
return .success
}

let subordinateOrigin = goal.origin.subordinate()
var subordinates: [GoalIdentity] = []
for e in elements {
let c = ConformanceConstraint(e, conformsTo: goal.concept, origin: subordinateOrigin)
subordinates.append(schedule(c))
}

return .product(subordinates) { (d, m, _) in
let t = m.reify(goal.model)
d.insert(.error(t, doesNotConformTo: goal.concept, at: goal.origin.site))
}
}

/// Returns a closure diagnosing a failure to solve `goal`.
private mutating func failureToSolve(_ goal: ConformanceConstraint) -> DiagnoseFailure {
return { (d, m, _) in
Expand Down
31 changes: 0 additions & 31 deletions Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2759,17 +2759,6 @@ struct TypeChecker {
return (e, i)
}

/// Computes and returns the type of `d`.
///
/// - Requires: `d` has a type annotation.
private mutating func uncheckedInputType(of d: ParameterDecl.ID) -> CallableTypeParameter {
.init(
label: program[d].label?.value,
type: uncheckedType(of: d, ignoringSharedCache: true),
hasDefault: program[d].defaultValue != nil,
isImplicit: program[d].isImplicit)
}

/// Computes and returns the types of the inputs `ps` of `d`.
///
/// - Requires: The parameters in `ps` have type annotations.
Expand Down Expand Up @@ -6195,26 +6184,6 @@ struct TypeChecker {
assert(solution.isSound || diagnostics.containsError, "inference failed without diagnostics")
}

/// Commits `r` in the program, where `r` is the name resolution result for a name component
/// used in a type expression, returning the type of that component.
///
/// - Precondition: `r` has a single candidate.
private mutating func bindTypeAnnotation(
_ r: NameResolutionResult.ResolvedComponent
) -> AnyType {
let c = r.candidates.uniqueElement!
cache.write(c.reference, at: \.referredDecl[r.component], ignoringSharedCache: true)

let t: AnyType
if isBoundToNominalTypeDecl(c.reference) {
t = MetatypeType(c.type)!.instance
} else {
t = c.type
}
cache.write(t, at: \.exprType[r.component], ignoringSharedCache: true)
return t
}

/// Calls `action` on `self`, logging a trace of constraint solving iff `shouldTraceInference(n)`
/// returns `true`.
private mutating func tracingInference<T: NodeIDProtocol>(
Expand Down

0 comments on commit b5bd439

Please sign in to comment.