Skip to content

comment whitespace#33

Merged
tkremenek merged 1 commit intoswiftlang:masterfrom
trel:patch-1
Dec 3, 2015
Merged

comment whitespace#33
tkremenek merged 1 commit intoswiftlang:masterfrom
trel:patch-1

Conversation

@trel
Copy link
Copy Markdown
Contributor

@trel trel commented Dec 3, 2015

No description provided.

tkremenek added a commit that referenced this pull request Dec 3, 2015
@tkremenek tkremenek merged commit e86c733 into swiftlang:master Dec 3, 2015
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
…e_fixes

Fixes to enable DISPATCH_DEBUG on Linux
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
…e_fixes

Fixes to enable DISPATCH_DEBUG on Linux

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
DougGregor pushed a commit to DougGregor/swift that referenced this pull request Apr 28, 2024
externalize RPM metadata and make it version based
miku1958 pushed a commit to miku1958/swift that referenced this pull request May 4, 2026
…o-fix-it

Implements proposal §"Containers and extensions" + decision row swiftlang#21 / swiftlang#33
for the container axis. `let xs: [String|Int] = zs` (with
`zs: [Int|String]`) now reports

  error: cannot assign value of type '[Int | String]' to type '[String | Int]'
    note: arguments to generic parameter 'Element' ('Int | String' and
          'String | Int') are expected to be equal
    fix-it:                                          ^ as [String | Int]

with an `as` (not `as!`) fix-it, since cross-spelling reshape is a
runtime-free relabel — both sides erase to the same Any-singleton element
layout, so SIL emits a single `unchecked_addr_cast` for the coercion.

Two changes:

  - `matchDeepEqualityTypes`'s NarrowedAnyType branch detects the
    cross-spelling case (canonical leaf sets equal but spellings
    differ) before the leaf-by-leaf Bind. When the locator path
    carries an `AnyRequirement` element (e.g. `extension Array where
    Element == X | Y` dispatch checking a substituted `Element` of a
    different spelling), fix the same-type requirement directly via
    `fixRequirementFailure` so SameTypeRequirementFailure prints the
    full narrowed-Any spellings instead of the buggy `any Int` /
    `any String` fallout from the previous malformed-wrap path. For
    the plain conversion case, fall through to the leaf-by-leaf Bind
    but tag each leaf locator with a fresh `GenericArgument` element
    so `repairFailures` doesn't inherit `ExistentialConstraintType`
    from the enclosing existential match (which used to construct the
    malformed `ExistentialType::get(<concrete leaf>)` wrap that
    defeated upstream `GenericArgumentsMismatch` recording).

  - `ContextualFailure::tryTypeCoercionFixIt` recognises cross-spelling
    NarrowedAnyType at container position structurally (same generic
    decl, every generic arg either equal or cross-spelling-equal
    NarrowedAnyType) and emits the ` as <toType>` fix-it directly,
    bypassing the generic `typeCheckCheckedCast` path which would
    classify it as ArrayDowncast (and suggest the wrong `as!`
    direction). Restricted to the `BoundGenericType` case so the
    value-level `Int|String → String|Int` path keeps using the
    existing `typeCheckCheckedCast → Coercion` flow with both `as`
    and `as!` fix-its preserved unchanged.

`diagnostics.swift §13` locks the full diagnostic text, the
generic-parameter-mismatch note, and the fix-it insertion. lit 13/13.
miku1958 pushed a commit to miku1958/swift that referenced this pull request May 4, 2026
…o-fix-it

Implements proposal §"Containers and extensions" + decision row swiftlang#21 / swiftlang#33
for the container axis. `let xs: [String|Int] = zs` (with
`zs: [Int|String]`) now reports

  error: cannot assign value of type '[Int | String]' to type '[String | Int]'
    note: arguments to generic parameter 'Element' ('Int | String' and
          'String | Int') are expected to be equal
    fix-it:                                          ^ as [String | Int]

with an `as` (not `as!`) fix-it, since cross-spelling reshape is a
runtime-free relabel — both sides erase to the same Any-singleton element
layout, so SIL emits a single `unchecked_addr_cast` for the coercion.

Two changes:

  - `matchDeepEqualityTypes`'s NarrowedAnyType branch detects the
    cross-spelling case (canonical leaf sets equal but spellings
    differ) before the leaf-by-leaf Bind. When the locator path
    carries an `AnyRequirement` element (e.g. `extension Array where
    Element == X | Y` dispatch checking a substituted `Element` of a
    different spelling), fix the same-type requirement directly via
    `fixRequirementFailure` so SameTypeRequirementFailure prints the
    full narrowed-Any spellings instead of the buggy `any Int` /
    `any String` fallout from the previous malformed-wrap path. For
    the plain conversion case, fall through to the leaf-by-leaf Bind
    but tag each leaf locator with a fresh `GenericArgument` element
    so `repairFailures` doesn't inherit `ExistentialConstraintType`
    from the enclosing existential match (which used to construct the
    malformed `ExistentialType::get(<concrete leaf>)` wrap that
    defeated upstream `GenericArgumentsMismatch` recording).

  - `ContextualFailure::tryTypeCoercionFixIt` recognises cross-spelling
    NarrowedAnyType at container position structurally (same generic
    decl, every generic arg either equal or cross-spelling-equal
    NarrowedAnyType) and emits the ` as <toType>` fix-it directly,
    bypassing the generic `typeCheckCheckedCast` path which would
    classify it as ArrayDowncast (and suggest the wrong `as!`
    direction). Restricted to the `BoundGenericType` case so the
    value-level `Int|String → String|Int` path keeps using the
    existing `typeCheckCheckedCast → Coercion` flow with both `as`
    and `as!` fix-its preserved unchanged.

`diagnostics.swift §13` locks the full diagnostic text, the
generic-parameter-mismatch note, and the fix-it insertion. lit 13/13.
miku1958 pushed a commit to miku1958/swift that referenced this pull request May 4, 2026
…o-fix-it

Implements proposal §"Containers and extensions" + decision row swiftlang#21 / swiftlang#33
for the container axis. `let xs: [String|Int] = zs` (with
`zs: [Int|String]`) now reports

  error: cannot assign value of type '[Int | String]' to type '[String | Int]'
    note: arguments to generic parameter 'Element' ('Int | String' and
          'String | Int') are expected to be equal
    fix-it:                                          ^ as [String | Int]

with an `as` (not `as!`) fix-it, since cross-spelling reshape is a
runtime-free relabel — both sides erase to the same Any-singleton element
layout, so SIL emits a single `unchecked_addr_cast` for the coercion.

Two changes:

  - `matchDeepEqualityTypes`'s NarrowedAnyType branch detects the
    cross-spelling case (canonical leaf sets equal but spellings
    differ) before the leaf-by-leaf Bind. When the locator path
    carries an `AnyRequirement` element (e.g. `extension Array where
    Element == X | Y` dispatch checking a substituted `Element` of a
    different spelling), fix the same-type requirement directly via
    `fixRequirementFailure` so SameTypeRequirementFailure prints the
    full narrowed-Any spellings instead of the buggy `any Int` /
    `any String` fallout from the previous malformed-wrap path. For
    the plain conversion case, fall through to the leaf-by-leaf Bind
    but tag each leaf locator with a fresh `GenericArgument` element
    so `repairFailures` doesn't inherit `ExistentialConstraintType`
    from the enclosing existential match (which used to construct the
    malformed `ExistentialType::get(<concrete leaf>)` wrap that
    defeated upstream `GenericArgumentsMismatch` recording).

  - `ContextualFailure::tryTypeCoercionFixIt` recognises cross-spelling
    NarrowedAnyType at container position structurally (same generic
    decl, every generic arg either equal or cross-spelling-equal
    NarrowedAnyType) and emits the ` as <toType>` fix-it directly,
    bypassing the generic `typeCheckCheckedCast` path which would
    classify it as ArrayDowncast (and suggest the wrong `as!`
    direction). Restricted to the `BoundGenericType` case so the
    value-level `Int|String → String|Int` path keeps using the
    existing `typeCheckCheckedCast → Coercion` flow with both `as`
    and `as!` fix-its preserved unchanged.

`diagnostics.swift §13` locks the full diagnostic text, the
generic-parameter-mismatch note, and the fix-it insertion. lit 13/13.
miku1958 pushed a commit to miku1958/swift that referenced this pull request May 4, 2026
Verify-mode tests for the strict-invariant rules already enforced by
Sema (proposal §"Subtyping lattice"; row swiftlang#21 / row swiftlang#33). All three
sections lock currently-passing rejections so wording / rule drift
fails immediately:

- §17 container narrowing — `[Int|String] -> [Int]`,
  `[String: Int|Bool] -> [String: Int]` (generic-arg-mismatch wording)
- §18 disjoint container element sets — `[Int|String] -> [Bool|Double]`
  (no relabel can rescue, no fix-it)
- §19 function-type variance — `(Int) -> Void -> (Int|String) -> Void`
  rejected; param-widening relaxation lives in the variance future
  direction

phase2f_runtime.swift §1 already covers the positive widening direction
(`[Int] -> [Int|String]` element-lift). Together with §13 (cross-
spelling) and §15 (disjoint return), the variance verify-mode bed now
covers the strict-invariant negatives that Sema currently rejects;
remaining "should error but silently desugar to Any layout" cases
(narrowed-Any -> [Any], function param-narrowing) require Sema work
and stay open in workspace todo.md §四.
miku1958 pushed a commit to miku1958/swift that referenced this pull request May 4, 2026
…sses

`Array<T>`/`Dictionary<K,V>`/`Set<T>` are invariant in narrowed-`Any`
element positions per the proposal's "Subtyping lattice" rule, but the
constraint solver's `ArrayUpcast`/`DictionaryUpcast`/`SetUpcast`
restrictions used the caller's match kind for the inner element match
— so a leaf-typed source array silently widened into a narrowed-`Any`
element type, narrowed-`Any` arrays silently erased to `[Any]`, and
`Set<Int>` silently widened to `Set<Int | String>`. Those three were
the container axis of the v1 gap registered in
§"Strict-invariant rule has silent passes".

Fix: in each of the three Upcast cases, `Type::findIf` over the
canonical tree of either side detects narrowed-`Any` and forces the
inner match to `Bind`, so the leaf-injection / open-erasure subtype
routes no longer fire. Explicit `as` coercion is exempted via the
existing `isExplicitCoerce` idiom (anchor `dyn_cast<CoerceExpr>`),
so cross-spelling reshape (`zs as [String | Int]`) and explicit
widening (`xs as [Int | String]`) still go through the SIL paths
exercised by `phase2_edge.swift §8` and `phase2f_runtime.swift §1`/§2.

Test bed:
- `diagnostics.swift §20` adds the three now-erroring shapes with
  `expected-error` + `expected-note` locks; `§17`'s comment is
  updated to point at `§20` for the symmetric widening direction.
- `phase2f_runtime.swift §1` rewrites the MARK 1 example onto the
  explicit-cast form (per design decision row swiftlang#33), with the comment
  explaining why the per-element wrap is required (source element
  stride 8 bytes vs Any-singleton element stride 32 bytes).

The fourth silent pass — function-type parameter contravariance
narrowing a narrowed-`Any` parameter — still slips through
`function_conversion`; that fix lives in `matchFunctionTypes` and is
the remaining v1-blocking item for this gap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants