diff --git a/Sources/Core/AST/AST+Walk.swift b/Sources/Core/AST/AST+Walk.swift index 70110bae1..6c26d9256 100644 --- a/Sources/Core/AST/AST+Walk.swift +++ b/Sources/Core/AST/AST+Walk.swift @@ -20,7 +20,7 @@ import Utils /// } /// } /// var v = V() -/// ast.modules.forEach({ ast.walk($0, notifying: &v) }) +/// for m in ast.modules { ast.walk(m, notifying: &v) } /// print(v.outermostFunctions) /// /// This program prints the IDs of the outermost function declarations in `ast`. @@ -222,7 +222,7 @@ extension AST { /// Visits all nodes in `roots` and their children in pre-order, notifying `o` when a node is /// entered or left. public func walk(roots: [T], notifying o: inout O) { - roots.forEach({ walk(AnyNodeID($0), notifying: &o) }) + for r in roots { walk(AnyNodeID(r), notifying: &o) } } /// Visits all condition items in `i` and their children in pre-order, notifying `o` when a node @@ -806,7 +806,7 @@ extension AST { /// Visits the children of `c` in pre-order, notifying `o` when a node is entered or left. public func traverse(whereClause c: WhereClause, notifying o: inout O) { - c.constraints.forEach({ traverse(constraintExpr: $0.value, notifying: &o) }) + for k in c.constraints { traverse(constraintExpr: k.value, notifying: &o) } } /// Visits the children of `c` in pre-order, notifying `o` when a node is entered or left. @@ -816,7 +816,7 @@ extension AST { switch c { case .conformance(let lhs, let traits): walk(lhs, notifying: &o) - traits.forEach({ walk($0, notifying: &o) }) + for t in traits { walk(t, notifying: &o) } case .equality(let lhs, let rhs): walk(lhs, notifying: &o) walk(rhs, notifying: &o) diff --git a/Sources/Core/Types/LambdaType.swift b/Sources/Core/Types/LambdaType.swift index caa7fb749..f882c9681 100644 --- a/Sources/Core/Types/LambdaType.swift +++ b/Sources/Core/Types/LambdaType.swift @@ -30,7 +30,7 @@ public struct LambdaType: TypeProtocol { self.output = output var fs = environment.flags - inputs.forEach({ fs.merge($0.type.flags) }) + for i in inputs { fs.merge(i.type.flags) } fs.merge(output.flags) flags = fs } diff --git a/Sources/Core/Types/MethodType.swift b/Sources/Core/Types/MethodType.swift index bbdc58620..f964455c6 100644 --- a/Sources/Core/Types/MethodType.swift +++ b/Sources/Core/Types/MethodType.swift @@ -30,7 +30,7 @@ public struct MethodType: TypeProtocol { self.output = output var fs = receiver.flags - inputs.forEach({ fs.merge($0.type.flags) }) + for i in inputs { fs.merge(i.type.flags) } fs.merge(output.flags) flags = fs } diff --git a/Sources/Core/Types/SubscriptImplType.swift b/Sources/Core/Types/SubscriptImplType.swift index 123f56fdd..fafecb69b 100644 --- a/Sources/Core/Types/SubscriptImplType.swift +++ b/Sources/Core/Types/SubscriptImplType.swift @@ -33,7 +33,7 @@ public struct SubscriptImplType: TypeProtocol { self.output = output var fs = environment.flags - inputs.forEach({ fs.merge($0.type.flags) }) + for i in inputs { fs.merge(i.type.flags) } fs.merge(output.flags) flags = fs } diff --git a/Sources/Core/Types/SubscriptType.swift b/Sources/Core/Types/SubscriptType.swift index 657537f14..52165df69 100644 --- a/Sources/Core/Types/SubscriptType.swift +++ b/Sources/Core/Types/SubscriptType.swift @@ -35,7 +35,7 @@ public struct SubscriptType: TypeProtocol { self.output = output var fs = environment.flags - inputs.forEach({ fs.merge($0.type.flags) }) + for i in inputs { fs.merge(i.type.flags) } fs.merge(output.flags) flags = fs } diff --git a/Sources/FrontEnd/TypeChecking/TypeChecker.swift b/Sources/FrontEnd/TypeChecking/TypeChecker.swift index aa186f22b..3aac1b0e4 100644 --- a/Sources/FrontEnd/TypeChecking/TypeChecker.swift +++ b/Sources/FrontEnd/TypeChecking/TypeChecker.swift @@ -364,7 +364,7 @@ struct TypeChecker { /// Type checks the sources in `batch`. mutating func check>(_ batch: S) { - batch.forEach({ check($0) }) + for u in batch { check(u) } } /// Type checks `u` and all declarations nested in `d`. @@ -386,7 +386,7 @@ struct TypeChecker { private mutating func check, T: DeclID>( _ batch: S, ignoringSharedCache ignoreSharedCache: Bool = false ) { - batch.forEach({ check($0, ignoringSharedCache: ignoreSharedCache) }) + for d in batch { check(d, ignoringSharedCache: ignoreSharedCache) } } /// Type checks `d` and all declarations nested in `d`. @@ -565,7 +565,7 @@ struct TypeChecker { /// Type checks `d` and all declarations nested in `d`. private mutating func _check(_ d: ModuleDecl.ID) { - program[d].sources.forEach({ check($0) }) + check(program[d].sources) } /// Type checks `d` and all declarations nested in `d`. @@ -785,7 +785,7 @@ struct TypeChecker { /// Type checks `s`. private mutating func check(_ s: BraceStmt.ID) { - program[s].stmts.forEach({ check($0) }) + for t in program[s].stmts { check(t) } } /// Type checks `s`. @@ -1097,7 +1097,7 @@ struct TypeChecker { /// Appends each variant of `c` to `candidates` that is has type `t`. func appendDefinitions(of d: MethodDecl.ID, matching t: AnyType, in s: inout [AnyDeclID]) { - program[d].impls.forEach({ appendIfDefinition($0, matching: t, in: &s) }) + for v in program[d].impls { appendIfDefinition(v, matching: t, in: &s) } } /// Appends `d` to `s` iff it's a a definition with type `t`.