Skip to content

[ConstraintSystem] Order VarDecls before other kinds of decls in disjunctions. #72755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

hborla
Copy link
Member

@hborla hborla commented Apr 2, 2024

Order VarDecls before other kinds of declarations because they are effectively favored over functions when the two are in the same overload set. This disjunction order allows SK_UnappliedFunction to prune later overload choices that are functions when a solution has already been found with a property, which enables solving code like this quickly:

func f(
  a: String?,
  b: String?,
  c: Int,
  d: String?,
  e: String?
) -> Int {
  return (a?.unicodeScalars.count ?? 0) +
  (b?.unicodeScalars.count ?? 0) +
  c +
  (d?.unicodeScalars.count ?? 0) +
  (e?.unicodeScalars.count ?? 0)
}

This resolves the source compatibility regression in penny-bot.

Resolves: rdar://125674969

@hborla hborla requested review from slavapestov and xedin as code owners April 2, 2024 00:20
@hborla
Copy link
Member Author

hborla commented Apr 2, 2024

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Apr 2, 2024

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Apr 2, 2024

My added test failed because I added it to a file that overloads count(where:)! The source compat failures are a UPASS of RxReactiveObjc, and importantly, penny-bot passed.

…ce test now

that it's in the standard library.
@hborla
Copy link
Member Author

hborla commented Apr 2, 2024

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@rintaro
Copy link
Member

rintaro commented Apr 2, 2024

@swift-ci please smoke test macOS

@rintaro
Copy link
Member

rintaro commented Apr 2, 2024

(The failure looked unrelated lldb-api :: lang/swift/embedded/frame_variable/TestSwiftEmbeddedFrameVariable.py)
https://ci.swift.org/job/swift-PR-macos-smoke-test/12820/console

@hborla
Copy link
Member Author

hborla commented Apr 2, 2024

Same failure again

@swift-ci please smoke test macOS

@rintaro
Copy link
Member

rintaro commented Apr 2, 2024

@swift-ci please smoke test macOS

1 similar comment
@hborla
Copy link
Member Author

hborla commented Apr 3, 2024

@swift-ci please smoke test macOS

@rintaro rintaro merged commit 51f6e66 into swiftlang:main Apr 3, 2024
@hborla hborla deleted the disjunction-variable-ordering branch April 3, 2024 14:04
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.

3 participants