profile
viewpoint
Tony Allevato allevato @google Kirkland, WA http://tonyallevato.com Staff Software Engineer at Google, working on Swift-related things.

allevato/icu-swift 22

Swift APIs for ICU

allevato/icu4c-swift 5

Low-level ICU C APIs for Swift

allevato/bitfield-keypath-repro 1

Repro for Swift linker error when keypath references imported C bitfield

allevato/bazel 0

a fast, scalable, multi-language and extensible build system

allevato/bazel-skylib 0

Common useful functions for writing custom build rules with Skylark

allevato/buildtools 0

A bazel BUILD file formatter and editor

allevato/clang 0

Mirror of official clang git repository located at http://llvm.org/git/clang. Updated every five minutes.

allevato/class-dump 0

Generate Objective-C headers from Mach-O files.

allevato/cmark 0

CommonMark parsing and rendering library and program in C

PullRequestReviewEvent

pull request commentapple/swift-format

Make Rule nameCache thread safe

Previously, we had the rule cache but weren't actually updating it, and populating the cache yielded a significant performance improvement (https://github.com/apple/swift-format/commit/13fd74d5bb7d287c13acf260608c92b3652efd99#diff-850e7af4319cd80f84d3ffdc821387f341b7cc167465cbb3e3b20d4e9b7fc142) when @dylansturg fixed it.

I don't recall, however, where the time profile mostly showed we were getting hit—it very well could have been the repeated heap allocations for the array result of split. If that was the case, then an improvement would be to do what you alluded to and stop using split, but instead just find the last occurrence of . and take the tail of that string.

If you'd like to explore a couple options and see what the time profiles look like, that'd be great—but I'm also happy to merge this as-is and do that exploration later. WDYT?

keith

comment created time in 10 hours

pull request commentapple/swift-format

Multithread processing source files

We've submitted changes to checkout swift-format as part of the CI builds and added build scripts for that purpose (see https://forums.swift.org/t/testing-swift-format-as-part-of-swift-s-ci-infrastructure/30619).

@shahmishal , can you update us on the current status of swift-format on Swift CI? Is there anything else we need to do on our end or does your team need to enable something for this to work?

keith

comment created time in 10 hours

PullRequestReviewEvent

pull request commentbazelbuild/bazel

Filter duplicate libraries from objc fully link

@googlewalt can probably speak to this better than I can (and correct anything wrong that I say below).

I believe the issue is simply the disconnect between how apple_binary (and ObjcProvider) treat cc_library dependencies differently from objc_library dependencies. For reasons (possibly historical) that I'm not 100% clear on, cc_library dependencies (and the code looks specifically for cc_library rules, which is even worse) are put into a separate provider field from other static libraries, and apple_binary later on combines those two sets when it provides the inputs to the linker action. But it ignores libraries from CcInfo.linking_context entirely, so the Swift hack exists because there's no other way to get libraries from rules that only propagate a CcInfo (like cc_library) up to apple_binary for linking on Darwin platforms.

To fix this, I think we'd need to fix up the apple_binary code to only consume linker inputs from CcInfo. I see code in ObjcLibrary.java that looks like it's creating a CcLinkingContext for the target (though I can't see whether it's merging them from its deps) and then it propagates a CcInfo, but the code that apple_binary eventually calls (CompilationSupport.registerLinkActions) doesn't do anything with the CcInfo libraries; it only pulls them from ObjcProvider.

keith

comment created time in 12 hours

push eventapple/swift-format

Keith Smiley

commit sha aac7bb620a7d325199e4091927c03a20e7e1c1ea

Switch Package.swift to point to main branch

view details

Tony Allevato

commit sha 842f22a5d612f1ef6112ef526683458609c259d3

Merge pull request #241 from keith/ks/switch-packageswift-to-point-to-main-branch Switch Package.swift to point to main branch

view details

push time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

[Clang Importer] Set IsSystem module flag for Clang input files when precompiling a clang module

+// Emit the explicit system module.+// RUN: %empty-directory(%t)+// RUN: %target-swift-emit-pcm -module-name CoreCooling -Xcc -Xclang -Xcc -emit-module -Xcc -Xclang -Xcc -fsystem-module -o %t/CoreCooling.pcm %S/Inputs/custom-modules/module.map++// Verify that the input modulemap if marked [System] in the output of the -dump-pcm action.+// RUN: %swift-dump-pcm %t/CoreCooling.pcm | %FileCheck %s --check-prefix=CHECK-SYSTEM-INPUT+// CHECK-SYSTEM-INPUT: Input file: SOURCE_DIR/{{.*}}/ClangImporter/Inputs/custom-modules/module.map [System]

Nice—I didn't realize the dump output distinguished them that way. That's more direct than my suggestion!

artemcm

comment created time in 7 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

push eventapple/swift-format

Dylan Sturgeon

commit sha 8b21c0aac0dae299cf217f10668e3bf2651e28d4

Revert "Fix for newly optional return type of `withDigits`."

view details

Tony Allevato

commit sha a05fc94372a2e67d8b6e8ba7f557969208ac1bce

Merge pull request #239 from dylansturg/revert-237-maybe_break_fix Revert "Fix for newly optional return type of `withDigits`."

view details

push time in 8 days

PR merged apple/swift-format

Revert "Fix for newly optional return type of `withDigits`."

Reverts apple/swift-format#237

The change that made makeIntegerLiteralExpr return an optional was reverted, so this needs to be reverted to build swift-format.

+5 -9

0 comment

1 changed file

dylansturg

pr closed time in 8 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

[Syntax] Parse attributed types in expr position as TypeExprSyntax

 class C <MemberDeclBlock>{<MemberDeclListItem><FunctionDecl>    func foo3<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>     _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><ArrayExpr>[<ArrayElement><TypeExpr><SimpleTypeIdentifier>Any</SimpleTypeIdentifier></TypeExpr></ArrayElement>]</ArrayExpr>()</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>+    _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><TupleExpr>(<TupleExprElement><AttributedType><Attribute>@convention(c) </Attribute><FunctionType>(<TupleTypeElement><SimpleTypeIdentifier>Int</SimpleTypeIdentifier></TupleTypeElement>) -> <SimpleTypeIdentifier>Void</SimpleTypeIdentifier></FunctionType></AttributedType></TupleExprElement>)</TupleExpr>.self</MemberAccessExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>

According to ExprNodes.py, the expression child of a TupleExprElement must be of kind Expr. But if I'm reading this XML correctly, would this attempt to put an AttributedType directly into the TupleExprElement, which wouldn't "fit" because an AttributedType isn't an Expr?

What would this look like when SwiftSyntax tries to parse it into the gybbed data types; i.e., how would I access the type?

rintaro

comment created time in 12 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/swift-format

Multithread processing source files

Thanks for catching that one; it's not one of the original data races we dealt with in earlier iterations of this PR (the linked code was added later; it wasn't a race before because we inadvertently were never updating the cache 😬) but we'll need to go back and synchronize that now too.

@keith is correct about the original blocking issue being that DiagnosticEngine in SwiftSyntax not being thread-safe. Last I chatted with @akyrtzi he wasn't opposed to just synchronizing inside that class by default, so I can try to put together a PR for that soon unless someone else beats me to it.

keith

comment created time in 13 days

push eventapple/swift-format

Dylan Sturgeon

commit sha 191094c758ae97c517952a2a038745b7581b6464

Handle #if clauses inside of switch statements. The special IfConfigDecl, aka `#if`, can exist in the `cases` of a SwitchStmtSyntax because the `#if` "wraps" one or more switch cases. These weren't being considered for the purposes of indenting the cases. There were also no breaks between the switch statement's left brace and `#if` when `#if` was the first "case" which caused malformed code. I have opted to treat `indentSwitchCaseLabels` as also indenting the `#if` cases in a switch statement, because that makes the `#if` here consistent with other locations.

view details

Tony Allevato

commit sha 8df2cb04f2aa41089cd14379552cb97bcc89133a

Merge pull request #238 from dylansturg/pound_if_cases Handle #if clauses inside of switch statements.

view details

push time in 14 days

PR merged apple/swift-format

Handle #if clauses inside of switch statements.

The special IfConfigDecl, aka #if, can exist in the cases of a SwitchStmtSyntax because the #if "wraps" one or more switch cases. These weren't being considered for the purposes of indenting the cases. There were also no breaks between the switch statement's left brace and #if when #if was the first "case" which caused malformed code.

I have opted to treat indentSwitchCaseLabels as also indenting the #if cases in a switch statement, because that makes the #if here consistent with other locations.

+106 -0

0 comment

2 changed files

dylansturg

pr closed time in 14 days

PullRequestReviewEvent

delete branch google/swift

delete branch : rxwei-patch-1

delete time in 14 days

delete branch google/swift

delete branch : glibc_define_fix

delete time in 14 days

delete branch google/swift

delete branch : multi_arch

delete time in 14 days

delete branch google/swift

delete branch : lld_support

delete time in 14 days

delete branch google/swift

delete branch : extra-stdlib

delete time in 14 days

delete branch google/swift

delete branch : glibc_feature_define

delete time in 14 days

delete branch google/swift

delete branch : vfs_glibc

delete time in 14 days

delete branch google/swift

delete branch : fuchsia_pr

delete time in 14 days

delete branch google/swift

delete branch : fuchsia_toolchain

delete time in 14 days

delete branch google/swift

delete branch : fuchsia_release

delete time in 14 days

delete branch google/swift

delete branch : format

delete time in 14 days

delete branch google/swift

delete branch : format-doc-comments

delete time in 14 days

delete branch google/swift

delete branch : format-blank-lines

delete time in 14 days

delete branch google/swift

delete branch : format-shorthand

delete time in 14 days

delete branch google/swift

delete branch : format-control-flow-breaks

delete time in 14 days

delete branch google/swift

delete branch : format-new-tests

delete time in 14 days

PR closed apple/swift-format

Cherry-pick switch/case indentation PR

Cherry-picks and squashes #204 into the Swift 5.2 branch so it can be used against projects running the production Swift version.

Feel free to close if this you want to do this differently, just thought I'd save you some trouble from having to do it manually.

+441 -3

1 comment

4 changed files

MPLew-is

pr closed time in 15 days

pull request commentapple/swift-format

Cherry-pick switch/case indentation PR

This apparently slipped under my radar. My apologies!

While not the original request, this change did go into the 5.3-compatible release.

MPLew-is

comment created time in 15 days

push eventapple/swift-format

Dylan Sturgeon

commit sha b7f63387363411cf80f0e58d713f3e2e31249342

Fix for newly optional return type of `withDigits`. The `withDigits` method was updated to return an optional, which causes this to fail to build. I think a nil value here would indicate an error in swift-format's numeric grouping that resulted in an invalid numeric literal. `withDigits` was udpated in a recent swift-syntax change: https://github.com/apple/swift-syntax/commit/94fc5ae3f34fac87380756b9c17ea7c6752a227b#diff-8c79a56bd4eb3d1313169ca412f5e11eL2387

view details

Tony Allevato

commit sha 9ecc5e2a3d66eb1f664b09008cafa0f5d8f599d9

Merge pull request #237 from dylansturg/maybe_break_fix Fix for newly optional return type of `withDigits`.

view details

push time in 15 days

PR merged apple/swift-format

Fix for newly optional return type of `withDigits`.

The withDigits method was updated to return an optional, which causes this to fail to build. I think a nil value here would indicate an error in swift-format's numeric grouping that resulted in an invalid numeric literal.

withDigits was udpated in a recent swift-syntax change: https://github.com/apple/swift-syntax/commit/94fc5ae3f34fac87380756b9c17ea7c6752a227b#diff-8c79a56bd4eb3d1313169ca412f5e11eL2387

+9 -5

0 comment

1 changed file

dylansturg

pr closed time in 15 days

PullRequestReviewEvent

pull request commentapple/swift

Disallow trailing commas when collection type sugar is parsed as exprs.

I've rebased this on top of the main branch.

@CodaFi , if you think it's still good to have this for consistency/correctness, can you review it? Thanks!

allevato

comment created time in 16 days

pull request commentapple/swift

Disallow trailing commas when collection type sugar is parsed as exprs.

@swift-ci please test

allevato

comment created time in 16 days

push eventallevato/swift

Tim Kientzle

commit sha 310c2656f0a05e52c2cdb0bc3f42460b8fb07c0b

Reorganize DynamicCasting spec This only rearranges the existing sections; it does not change any technical points. This attempts to make the spec a little clearer by grouping the individual type discussions under four main headings: * Classes and Foreign Types. This includes Swift classes, Obj-C classes, and CF types. * Other Concrete Types. Struct, Enum, Tuple, Function, Optional, and Set/Dict/Array * Existential Types. Any, AnyObject, Error, Protocol types, and AnyHashable(*) * Metatypes & Existential Metatypes (*) This organization seems to flow a little better. In particular, it gives me a place to discuss issues common to all Existential types, which I'll work through in a subsequent PR. Footnotes: This organization isn't perfect, of course: * AnyHashable isn't really an Existential type, but it behaves as such for casting purposes, so it makes the most sense to discuss it in the Existentials section. * Metatypes are technically concrete types, but it seems to make more sense to discuss them after discussing Existential types.

view details

Michael Gottesman

commit sha ba6dc1724b9a981eb6c4425a9372f436a4aabef5

[semantic-arc] Split load [copy] -> load_borrow opt into its own file.

view details

Nathan Hawes

commit sha 816b555d76d7868af1be4c115e65eced81bc0a47

Merge pull request #33695 from nathawes/fix-typo [IDE] Fix typo to address unused warning (NFC)

view details

Nathan Hawes

commit sha 9da1d895207136f84fc5346fb16706dd082aa1fc

Manually merge remote-tracking branch 'upstream/master' into HEAD Conflicts: lib/AST/ExtInfo.cpp

view details

Tim Kientzle

commit sha 62bae423b5b052277801882945865740ec837f70

Un-XFAIL a test that now passes protocol_lookup_foreign exercises CF casting that used to be broken, but now works with the new dynamic casting implementation.

view details

Xi Ge

commit sha 55e77785dfacdcfcecad801faaa2a38b4bbec6fb

ABI checker: add a mechansim for specifying allowd ABI breakages When the checker found a breakage listed in the user-specified list, the breage should be consumed internally without failing the check. rdar://68086477

view details

Michael Gottesman

commit sha af4199e4f6b0e97f700ef363f0d2c6e4d6a2b264

[build-toolchain] Add an option to control if code built by the toolchain links by default to the OS runtime or the toolchain runtime. Today by default, we always link against the runtime runtime. This option just lets our users decide what they want, but leaves the defaults alone.

view details

Michael Gottesman

commit sha 905712373999b00f977c98d083f813948e0f740e

Merge pull request #33618 from gottesmm/pr-bb7b96b4e43e9b8289ab38ff2613f251e373f0f3 [ownership] When computing usesNotContainedWithinLifetime make sure the error is only a use not in lifetime error.

view details

Doug Gregor

commit sha 0b2b7b58e88b16c7d9c0a1d07c57959b270e3ddc

[Constraint solver] Fix backward trailing closures with ".member" expressions The introduction of forward-scan matching for trailing closures (SE-0286) failed to account for unresolved member expressions, sometimes causing a crash in SILGen. Fixes rdar://problem/67781123.

view details

Frederick Kellison-Linn

commit sha c37d3c3917582c4420bab063a87aed6363a46444

Update CHANGELOG.md table of contents, add SE-0287 (#33685)

view details

Michael Gottesman

commit sha d29bca5a5340489906d2314e9cea566857f1f2af

[ownership] Extract out the computation of implicit uses for BorrowingOperands and InteriorPointerOperands into utilities on those classes. I am currently working on updating SimplifyCFG for ownership. One thing that I am finding that I need is the ability to compute the lifetime of a guaranteed argument from a checked_cast_br/switch_enum in order to convert said instructions to a br. The issue comes from br acting as a consuming (lifetime ending) use of a borrowed value, unlike checked_cast_br/switch_enum (which are treated like forwarding instructions). This means that during the conversion we need to insert a begin_borrow on the value before the new br instruction and then create an end_borrow at the end of the successor block's argument's lifetime. By refactoring out this code from the ownership verifier, I can guarantee that said lifetime computation will always match what the ownership verifier does internally preventing them from getting out of sync.

view details

swift-ci

commit sha e98c2587ec614f2747c507077fbcd3da4b0e1a16

Merge pull request #33715 from tbkka/tbkka/dynamicCastRework-Specification-c

view details

Michael Gottesman

commit sha 9b8c4141ce85b8609f8a3955eba4f1a0cf1fe2b5

Merge pull request #33707 from gottesmm/pr-73ca3d4385ca24e8499ece6066aa1942458cdedf [semantic-arc] Split load [copy] -> load_borrow opt into its own file.

view details

swift-ci

commit sha 1b928b5037ebf51e1ab939c889a9a56845ba73d1

Merge pull request #33719 from tbkka/tbkka/dynamicCast-CFUXPASS

view details

Xi Ge

commit sha e470919a4f799f31b516cb6c125fa40ba96feaf6

Merge pull request #33720 from nkcsgexi/add-allow-list-abi-checker ABI checker: add a mechansim for specifying allowed ABI breakages

view details

Doug Gregor

commit sha cabcbc92707e2e85a203dc99573c57537e1fbf24

[Constraint application] Find trailing closure direction more carefully. Rather than trying to include each expression kind, which leaves us open to errors of omission, exclude only the case where we don't record locators for trailing closure directions.

view details

Michael Gottesman

commit sha 8b5fb43370467a42eb19a2808a76bbac9ca68949

Merge pull request #33714 from gottesmm/pr-328e13b915804e9b08d18a354ef036522340f489 [ownership] Extract out the computation of implicit uses for BorrowingOperands and InteriorPointerOperands into utilities on those classes.

view details

Michael Gottesman

commit sha 7c12c7f4667a9afaddc658b48bda1ab89f9d0522

[semantic-arc] Extract out borrow scope optimizations into its own file.

view details

Artem Chikin

commit sha fd3f732e5f6658e6880f57ae79d17099b0f4c2c1

Merge pull request #33687 from artemcm/DepScannerOrder [DependencyScanner] Change the scanner order to resolve placeholders first

view details

swift-ci

commit sha c708785d3344a27c1044c465ea7362a5c01e645b

Merge pull request #33696 from varungandhi-apple/vg-fix-doc-library-evolution-protocols

view details

push time in 16 days

create barnchallevato/swift

branch : main

created branch time in 16 days

Pull request review commentapple/swift-protobuf

Sort map fields for TextFormat.

 internal struct TextFormatEncodingVisitor: Visitor {   private mutating func _visitMap<K, V>(     map: Dictionary<K, V>,     fieldNumber: Int,+    lessThanFunc: (K, K) -> Bool,

Nit: isOrderedBefore would be a cleaner name that matches the argument name used by Swift's stdlib for other sorting predicates.

thomasvl

comment created time in a month

Pull request review commentapple/swift-protobuf

Sort map fields for TextFormat.

 public protocol FieldType { /// Marker protocol for types that can be used as map keys /// public protocol MapKeyType: FieldType {+    /// A comparision function for where order is needed.  Can't use `Comparable`+    /// because `Bool` doesn't conform, and since it is `public` there is no way+    /// to add a conformance internal to SwiftProtobuf.+    static func lessThan(lhs: BaseType, rhs: BaseType) -> Bool

We could make the name of the method _lessThan to make it clear that it's only meant to be used by the library.

(We probably should have done that for the protocol itself, in retrospect.)

thomasvl

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

create barnchallevato/swift-syntax

branch : main

created branch time in a month

PullRequestReviewEvent

Pull request review commentapple/swift-syntax

Add Double and Int Convenience Properties

+//===- SyntaxConvenienceMethods.swift - Convenience funcs for syntax nodes ===//+//+// This source file is part of the Swift.org open source project+//+// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors+// Licensed under Apache License v2.0 with Runtime Library Exception+//+// See https://swift.org/LICENSE.txt for license information+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors+//+//===----------------------------------------------------------------------===//++public extension FloatLiteralExprSyntax {+  var floatingValue: Double {+    return potentialFloatingValue!+  }++  fileprivate var potentialFloatingValue: Double? {+    let floatingDigitsWithoutUnderscores = floatingDigits.text.filter {+      $0 != "_"+    }+    return Double(floatingDigitsWithoutUnderscores)+  }+}++public extension IntegerLiteralExprSyntax {+  var integerValue: Int {+    return potentialIntegerValue!+  }++  fileprivate var potentialIntegerValue: Int? {+    let text = digits.text+    let (prefixLength, radix) = IntegerLiteralExprSyntax.prefixLengthAndRadix(text: text)+    let digitsStartIndex = text.index(text.startIndex, offsetBy: prefixLength)+    let textWithoutPrefix = text.suffix(from: digitsStartIndex)++    let textWithoutPrefixOrUnderscores = textWithoutPrefix.filter {+      $0 != "_"+    }++    return Int(textWithoutPrefixOrUnderscores, radix: radix)

This isn't quite accurate; IntegerLiteralExprSyntax is not limited to what can fit into the Int type; it's any sequence of characters that is syntactically a valid integer literal. The error you're showing occurs later on at the semantic analysis phase, but the compiler and SwiftSyntax will still parse it without error. If we try the following command:

echo 'let foo = 42424242424242424242424242424242424242424242424242424242424242424242424242' | \
  swiftc -frontend -emit-syntax -

we'll see this in the output:

...
{
  "id":6,
  "kind":"IntegerLiteralExpr",
    "layout":[{
      "id":5,
      "tokenKind": {
        "kind":"integer_literal",
        "text":"42424242424242424242424242424242424242424242424242424242424242424242424242"
      },

So potentialIntegerValue called on this would return nil, and integerValue would crash.

vermont42

comment created time in a month

created tagapple/swift-format

tag0.50300.0

Formatting technology for Swift source code

created time in a month

release apple/swift-format

0.50300.0

released time in a month

delete branch allevato/swift-format

delete branch : swift-5.3-version

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha 7e18a585e40b8bf0f77a87f4860cbdd8bccbba4c

Update version number printed by `-v` flag.

view details

Tony Allevato

commit sha 12089179aa1668a2478b2b2111d98fa37f3531e3

Merge pull request #236 from allevato/swift-5.3-version Update version number printed by `-v` flag.

view details

push time in a month

create barnchallevato/swift-format

branch : swift-5.3-version

created branch time in a month

delete branch allevato/swift-format

delete branch : swift-5.3-swiftsyntax-release

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha a69a1134d6b2cdd55ef2f5712b81e1bc8c61fe32

Use swift-syntax version 0.50300.0.

view details

Tony Allevato

commit sha e719526300040b5972af9b2bb963f06cd903a895

Merge pull request #235 from allevato/swift-5.3-swiftsyntax-release Use swift-syntax version 0.50300.0.

view details

push time in a month

create barnchallevato/swift-format

branch : swift-5.3-swiftsyntax-release

created branch time in a month

delete branch allevato/swift-format

delete branch : swift-5.3-cherrypicks

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha 24084c6281abb42693c8074aca3dc34612574385

Merge pull request #233 from allevato/update-readme Update README for Swift 5.3.

view details

Tony Allevato

commit sha e286081a1342944236bde8653f5ca763ba61cfc3

Merge pull request #230 from allevato/multiple-trailing-closures Format multiple trailing closures.

view details

push time in a month

create barnchallevato/swift-format

branch : swift-5.3-cherrypicks

created branch time in a month

push eventallevato/swift-format

Tony Allevato

commit sha fcf193d4adc43e6d92999ca21baa48dc89365e8a

Format multiple trailing closures. When a function call has multiple trailing closures, every closure is forced to wrap.

view details

Tony Allevato

commit sha d4bba6e22891ff1813e8267e36f2b00307684366

Merge pull request #230 from allevato/multiple-trailing-closures Format multiple trailing closures.

view details

push time in a month

delete branch allevato/swift-format

delete branch : multiple-trailing-closures

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha fcf193d4adc43e6d92999ca21baa48dc89365e8a

Format multiple trailing closures. When a function call has multiple trailing closures, every closure is forced to wrap.

view details

Tony Allevato

commit sha d4bba6e22891ff1813e8267e36f2b00307684366

Merge pull request #230 from allevato/multiple-trailing-closures Format multiple trailing closures.

view details

push time in a month

PR merged apple/swift-format

Format multiple trailing closures.

When a function call has multiple trailing closures, every closure is forced to wrap.


There are two potentially surprising things about the behavior here:

  1. Unlike an if/else statement, which can be formatted like this if it would fit entirely on one line:

    if foo { bar } else { baz }
    

    ...we do not allow the same thing to occur for multiple trailing closures at this time:

    // this
    foo(x) { bar() } label: { baz() }
    // will always become
    foo(x) {
      bar()
    } label: {
      baz()
    }
    
  2. The forced break occurs after the closure signature { arg, arg, arg in‸ if it's present; otherwise, it occurs after the open brace. This lets the closure signature stay on the same line as the open brace if it fits, but it will still wrap (via the normal break that occurs here {‸arg, arg, arg in) if it wouldn't fit.

    However, because the break after in‸ is forced, that means that if the break after {‸ also fires, then even a single-statement closure will have a line break after the signature, when regular closures otherwise wouldn't. In other words,

    // possible
    reallyLongFunctionName(x) {
      x in bar(x)
    }
    
    // NOT possible
    reallyLongFunctionName(x) {
      x in bar(x)
    } secondLabelThatIsAlsoLong: {
      y in baz(y)
    }
    
    // ...it becomes this:
    reallyLongFunctionName(x) {
      x in
      bar(x)
    } secondLabelThatIsAlsoLong: {
      y in
      baz(y)
    }
    

I can live with (1); I don't think it's a huge problem because I imagine the number of function calls with multiple trailing closures that would fit entirely on one line are exceedingly rare to begin with, and I think in the case of multiple trailing closures it's more readable to have them wrapped anyway so that the label isn't hidden in the middle of the line.

I'm less happy about (2), since it's a weird inconsistency, but I'm not sure our current model is flexible enough to say "given {₁arg, arg, arg in₂, force break 2 only if we didn't already break at 1". It's almost like a reset, but not quite the same because we're not conditioning it on continuation line state.

@dylansturg Any ideas here?

+80 -6

1 comment

2 changed files

allevato

pr closed time in a month

pull request commentapple/swift-format

Format multiple trailing closures.

Going to go ahead and merge this to get it into the 5.3 branch; I'll revisit improvements to the newline behavior above later.

allevato

comment created time in a month

push eventallevato/swift-format

Tony Allevato

commit sha bf6f116a78aa2f0e79708448b6978f2549d19dc6

Update README for Swift 5.3.

view details

Tony Allevato

commit sha 71b1e726dfbacf381da4c28e93759f76be7e6b75

Merge pull request #233 from allevato/update-readme Update README for Swift 5.3.

view details

push time in a month

delete branch allevato/swift-format

delete branch : update-readme

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha bf6f116a78aa2f0e79708448b6978f2549d19dc6

Update README for Swift 5.3.

view details

Tony Allevato

commit sha 71b1e726dfbacf381da4c28e93759f76be7e6b75

Merge pull request #233 from allevato/update-readme Update README for Swift 5.3.

view details

push time in a month

PR opened apple/swift-format

Update README for Swift 5.3.
+3 -2

0 comment

1 changed file

pr created time in a month

create barnchallevato/swift-format

branch : update-readme

created branch time in a month

delete branch allevato/swift-format

delete branch : swift-5.3-cherrypicks

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha 57a5cb66a72bd04c9a07635b8a980573033dcc96

Merge pull request #212 from frankus/add-throws-comment-support Add support for Throws doc comments

view details

Tony Allevato

commit sha 8423f767becd2efee6c663222ef91d09603ad9ba

Merge pull request #218 from dylansturg/pipeline_refresh Refresh generated code by running generate-pipeline.

view details

Tony Allevato

commit sha 40bab4e8b99d52dc561e62aa14e39d0d6cda7c17

Merge pull request #219 from dylansturg/optional_rules Support opt-in rules using an `isOptIn` class property.

view details

Tony Allevato

commit sha ea02880b86bee22da9fbbfe37e43e17d75b673dd

Merge pull request #220 from dylansturg/better_diagnostic_locs Fix invalid location references in some diagnostics.

view details

Tony Allevato

commit sha 90807621e2a52ca3432c56c3bb855bc89146b360

Merge pull request #221 from dylansturg/test_name_freedom Add an exception to AlwaysUseLowerCamelCase for test names.

view details

Tony Allevato

commit sha 97628a8b0068fd0977ce50915c36f3dee8c5426a

Merge pull request #222 from dylansturg/accurate_decltypes Specify the type of decl to rename in AlwaysUseLowerCamelCase.

view details

Tony Allevato

commit sha 642c2d17e50936aa517f08c72eed9826bc163e4d

Merge pull request #223 from dylansturg/opt_in_rules Convert some rules to be opt-in because they are noisy for non-strict…

view details

Tony Allevato

commit sha 7867cda76f800f6031cafa83793dd136f17b1c38

Merge pull request #224 from dylansturg/more_lowercase Apply AlwaysUseLowerCamelCase in more places.

view details

Tony Allevato

commit sha 674b34df5114291df26f0f9edba8b94b76c28f80

Merge pull request #225 from dylansturg/never_doesnt_return Don't require a returns comment for functions that never return.

view details

Tony Allevato

commit sha 89d621f9e79df73b0c2cf0084119105b0ab71831

Merge pull request #226 from dylansturg/fewer_linter_allocs Allocate 1 instance of each rule per LintPipeline.

view details

Tony Allevato

commit sha 1c2a5a2d244b89ef10195799bbe9ca86ecc15bf3

Merge pull request #227 from dylansturg/more_optional_rules Migrate some rules to opt-in status.

view details

Tony Allevato

commit sha 483580f1d3047272292aa516e06a02adc8b365aa

Merge pull request #228 from dylansturg/commas_crash Handle existing commas in single element collections.

view details

Tony Allevato

commit sha 73e2f4e57e3a62a9f7e2330d597b4dbc15a9460a

Merge pull request #229 from dylansturg/allow_empty_paths Allow empty paths to imply reading from stdin.

view details

Tony Allevato

commit sha fffd3db3f6c491c14007f0e512ec5feaf3e61839

Merge pull request #231 from allevato/argparse-deprecations Use regular property initialization for argument defaults.

view details

Tony Allevato

commit sha ef0ec02e290f3725ea9c2862dacb2b345db143bc

Update dependencies for Swift 5.3. Temporarily using the `swift-5.3-RELEASE` tag of SwiftSyntax until a semver tag is available.

view details

push time in a month

PR merged apple/swift-format

[5.3] Cherry-pick Swift 5.3 compatible changes since 7/29.

All changes since fa84e116f909f487b3886f498ac19df8cb43fc60 have been Swift 5.3 compatible. The only omission is 33f0b37f607d90a6da7d445140b798a09a57f778, which addressed a breaking API change from the addition of the async keyword in master.

+676 -205

0 comment

30 changed files

allevato

pr closed time in a month

PR opened apple/swift-format

[5.3] Cherry-pick Swift 5.3 compatible changes since 7/29.

All changes since fa84e116f909f487b3886f498ac19df8cb43fc60 have been Swift 5.3 compatible. The only omission is 33f0b37f607d90a6da7d445140b798a09a57f778, which addressed a breaking API change from the addition of the async keyword in master.

+676 -205

0 comment

30 changed files

pr created time in a month

create barnchallevato/swift-format

branch : swift-5.3-cherrypicks

created branch time in a month

create barnchapple/swift-format

branch : swift-5.3-branch

created branch time in a month

push eventallevato/swift-format

Tony Allevato

commit sha 762c20a2b88169426168e49159465c8f74a515ee

Use regular property initialization for argument defaults. This gets rid of warnings from deprecated swift-argument-parser APIs.

view details

Tony Allevato

commit sha 58582412951938d411be4d55d776a30816ea5c0c

Merge pull request #231 from allevato/argparse-deprecations Use regular property initialization for argument defaults.

view details

push time in a month

delete branch allevato/swift-format

delete branch : argparse-deprecations

delete time in a month

push eventapple/swift-format

Tony Allevato

commit sha 762c20a2b88169426168e49159465c8f74a515ee

Use regular property initialization for argument defaults. This gets rid of warnings from deprecated swift-argument-parser APIs.

view details

Tony Allevato

commit sha 58582412951938d411be4d55d776a30816ea5c0c

Merge pull request #231 from allevato/argparse-deprecations Use regular property initialization for argument defaults.

view details

push time in a month

PR merged apple/swift-format

Use regular property initialization for argument defaults.

This gets rid of warnings from deprecated swift-argument-parser APIs.

+8 -9

1 comment

4 changed files

allevato

pr closed time in a month

pull request commentapple/swift-format

Use regular property initialization for argument defaults.

cc @dylansturg

allevato

comment created time in a month

PR opened apple/swift-format

Use regular property initialization for argument defaults.

This gets rid of warnings from deprecated swift-argument-parser APIs.

+8 -9

0 comment

4 changed files

pr created time in a month

PR opened apple/swift-format

Format multiple trailing closures.

When a function call has multiple trailing closures, every closure is forced to wrap.


There are two potentially surprising things about the behavior here:

  1. Unlike an if/else statement, which can be formatted like this if it would fit entirely on one line:

    if foo { bar } else { baz }
    

    ...we do not allow the same thing to occur for multiple trailing closures at this time:

    // this
    foo(x) { bar() } label: { baz() }
    // will always become
    foo(x) {
      bar()
    } label: {
      baz()
    }
    
  2. The forced break occurs after the closure signature { arg, arg, arg in‸ if it's present; otherwise, it occurs after the open brace. This lets the closure signature stay on the same line as the open brace if it fits, but it will still wrap (via the normal break that occurs here {‸arg, arg, arg in) if it wouldn't fit.

    However, because the break after in‸ is forced, that means that if the break after {‸ also fires, then even a single-statement closure will have a line break after the signature, when regular closures otherwise wouldn't. In other words,

    // possible
    reallyLongFunctionName(x) {
      x in bar(x)
    }
    
    // NOT possible
    reallyLongFunctionName(x) {
      x in bar(x)
    } secondLabelThatIsAlsoLong: {
      y in baz(y)
    }
    
    // ...it becomes this:
    reallyLongFunctionName(x) {
      x in
      bar(x)
    } secondLabelThatIsAlsoLong: {
      y in
      baz(y)
    }
    

I can live with (1); I don't think it's a huge problem because I imagine the number of function calls with multiple trailing closures that would fit entirely on one line are exceedingly rare to begin with, and I think in the case of multiple trailing closures it's more readable to have them wrapped anyway so that the label isn't hidden in the middle of the line.

I'm less happy about (2), since it's a weird inconsistency, but I'm not sure our current model is flexible enough to say "given {₁arg, arg, arg in₂, force break 2 only if we didn't already break at 1". It's almost like a reset, but not quite the same because we're not conditioning it on continuation line state.

@dylansturg Any ideas here?

+80 -6

0 comment

2 changed files

pr created time in a month

create barnchallevato/swift-format

branch : argparse-deprecations

created branch time in a month

create barnchallevato/swift-format

branch : multiple-trailing-closures

created branch time in a month

push eventallevato/swift-format

Dylan Sturgeon

commit sha dc3eccb6455417e256a2354df847245f30877558

Migrate some rules to opt-in status. This migrates the following rules to opt-in status: * NoLeadingUnderscores * ValidateDocumentationComments The rationale for their opt-in status is described in the code where they are marked as opt-in.

view details

Tony Allevato

commit sha 5986f6562f953560b48844f6e1eaead82f2684cc

Merge pull request #227 from dylansturg/more_optional_rules Migrate some rules to opt-in status.

view details

Dylan Sturgeon

commit sha c405d72d0c4fc20178e8998f105c7264fe5be884

Handle existing commas in single element collections. The `whitespaceOnly` mode in the PrettyPrinter handle existing commas in single element collections incorrectly by always removing the comma. This happened because an earlier fix stopped placing `commaDelimitedRegion[Start|End]` tokens around single element collections, while still ignoring any existing trailing comma token. Rather than move the `whitespaceOnly` decision deep into the TokenStreamCreator, I've revised that previous fix so that all logic to decide when to keep and remove commas is localized inside the PrettyPrinter. This was causing crashes when linting code that had a trailing comma in a single element collection, because `whitespaceOnly` mode was incorrectly causing non-whitespace changes to occur. Fixes SR-12782

view details

Dylan Sturgeon

commit sha 32ddb82ccc4b291d53bec03277ebb2c87b9f5515

Allow empty paths to imply reading from stdin. This has been supported for a long time, but a recent change in swift-argument-parser 0.3.0 changed the behavior for non-nullable array types as arguments. Previously, the argument parser defaulted them to empty arrays. The suggested migration is to simply specify a default empty array for optional array arguments. Reference: https://github.com/apple/swift-argument-parser/releases/tag/0.3.0

view details

Tony Allevato

commit sha a1a46075df26d939fe0d42e916cdddd5c930b008

Merge pull request #228 from dylansturg/commas_crash Handle existing commas in single element collections.

view details

Tony Allevato

commit sha 4af1af9a0bae7ffef0bf0f604d61346d23f92a7b

Merge pull request #229 from dylansturg/allow_empty_paths Allow empty paths to imply reading from stdin.

view details

push time in a month

issue commentapple/swift-protobuf

oneof with no associated value

Setting aside the question of whether or not we should do this, if we did want to support it, one way that still probably gets the issue author what they want would be to define a convenience constant for oneof cases that correspond to google.protobuf.Empty fields; i.e.,

 enum OneOf_Baz {
   case foo(Google_Protobuf_Empty)
   case bar(Int64)

+  static let foo = OneOf_Baz.foo(Google_Protobuf_Empty())
 }

This preserves the original message (in case unknown fields are captured), but in situations where the user wants to write the short-hand for a value, .foo could be used instead of .foo(Google_Protobuf_Empty()).

In pattern matching scenarios, it's already possible to leave off the associated value and write case .foo: to match all possible foos regardless of associated value, so I don't think we need to handle that situation.

With that being said, given the fact that it affects the API surface, I think we should consider possible language-specific enhancements like this holistically along with a number of others, like treating wrapper types as Swift optionals, and even overhauling the entire set of generated properties using property wrappers.

wilg

comment created time in a month

more