Commit Graph

7628 Commits

Author SHA1 Message Date
Karoy Lorentey
c94556165e Merge pull request #62794 from lorentey/character-recognizer
[stdlib] Export grapheme breaking facility
2023-01-04 23:54:48 -08:00
Pavel Yaskevich
f8bf74b457 Merge pull request #62773 from xedin/rdar-83418797
[CSClosure] Fix handling of non-representivate variables
2023-01-04 09:48:54 -08:00
Pavel Yaskevich
2e25c2fc80 Merge pull request #62791 from xedin/rdar-103739206
[Diagnostics] Relax contextual type presence from assertion to a check
2023-01-04 09:47:19 -08:00
Pavel Yaskevich
eaf0532a04 [Diagnostics] Relax contextual type presence from assertion to a check
In some situations `getContextualType` for a contextual type
locator is going to return then empty type. This happens because
e.g. optional-some patterns and patterns with incorrect type don't
have a contextual type for initialization expression but use
a conversion with contextual locator nevertheless to indicate
the purpose. This doesn't affect non-ambiguity diagnostics
because mismatches carry both `from` and `to` types.

Resolves: rdar://problem/103739206
2023-01-02 21:11:07 -08:00
Karoy Lorentey
4d9edad297 [test] Improve grapheme breaking tests
Instead of just checking the number of breaks in each test case,
expose and check the actual positions of those breaks, too.
2022-12-29 17:56:45 -08:00
Pavel Yaskevich
47893695be [CSClosure] Fix handling of non-representivate variables
All of the type variables referenced by a type had to be
handled by `inferVariables` otherwise it would to possible
to bring non-representative variable into scope which in
turn later would get simplied into a variable that doesn't
exist in the active scope and solver would crash.

Resolves: rdar://83418797
2022-12-23 20:08:09 -08:00
Pavel Yaskevich
36a50c7070 [ResultBuilder] Don't run syntactic diagnostics on transformed do statements
Visiting of transformed `do` shouldn't run syntatic diagnostics because
they are going to be performed by `visit` that called `visitDoStmt`.
2022-12-21 10:31:36 -08:00
Pavel Yaskevich
697dfbae96 [TypeChecker] Enable result builder AST transform by default 2022-12-21 10:31:30 -08:00
Luciano Almeida
0db4b43f6d Merge pull request #61863 from LucianoPAlmeida/crash-dump-parse-init
[ASTDumper] Special handling for init kind in pre-typecheck dump
2022-12-16 09:42:31 -03:00
Rintaro Ishizaki
4e334498e8 [CodeCompletion] Don't suggest opaque generic parameter types
'some' parameter types don't have spelling.

rdar://102958462
2022-12-15 13:26:17 -08:00
Dario Rexin
39aef7d2ef Merge pull request #62446 from drexin/wip-103080745
[Build] Pass missing build parameters
2022-12-14 10:09:24 -08:00
Pavel Yaskevich
db37be971d Merge pull request #62527 from xedin/attempt-conjunctions-in-source-order
[CSSolver] Solve multi-statement closures in source order
2022-12-13 12:45:48 -05:00
Pavel Yaskevich
65e7eec62f [CSSolver] Solve multi-statement closures in source order
Currently solver picks the first conjunction it can find,
which means - the earliest resolved closure. This is not
always correct because when calls are chained closures
passed to the lower members could be resolved sooner
than the ones higher up but at the same time they depend
on types inferred from members higher in the chain.

Let's make sure that multi-statement closures are always
solved in order they appear in the AST to make sure that
types are available to members lower in the chain.
2022-12-12 10:57:21 -08:00
Pavel Yaskevich
7166f193b5 [ConstraintSystem] Reject property wrapper transform on func parameters in pattern context
The transform is not currently supported on anything but regular calls.
2022-12-09 15:47:57 -05:00
Dario Rexin
2bac2a1cbf Update skip_build_xcode.test 2022-12-08 09:41:33 -08:00
Luciano Almeida
70b884cf08 [ASTDumper] Special handling for init kind in pre-typecheck dump 2022-12-06 22:50:00 -03:00
Pavel Yaskevich
7588434007 [CSSimplify] Account for tuple splat when resolving closure parameters
SE-0110 allows tuple slat between function types. The solver needs to
account for that when trying to infer parameter types from context
while resolving a closure in order to propagate types and speed up
type-checking.

Resolves: https://github.com/apple/swift/issues/62390
2022-12-05 00:28:52 -08:00
Slava Pestov
2f8998a84f Merge pull request #62288 from slavapestov/various-fixes
A couple of random name lookup fixes
2022-11-29 11:48:25 -05:00
Anthony Latsis
05756a47a7 Merge pull request #62224 from AnthonyLatsis/fix-xcode-build
build: Fix Xcode project generation
2022-11-29 16:11:34 +03:00
Slava Pestov
3dc7a2decd Sema: Fix substMemberTypeWithBase() for non-generic typealias with 'where' clause
getContextSubstitutionMap() builds a substitution map for the generic signature of
the parent context, which is wrong if the typealias has its own 'where' clause.
2022-11-28 23:57:53 -05:00
Pavel Yaskevich
2e0cc04ba1 Merge pull request #62227 from xedin/result-builder-ast-transform-direct-buildBlock
[ResultBuilder] ASTTransform: Don't capture buildBlock into a separat…
2022-11-28 10:18:53 -08:00
Pavel Yaskevich
c17d35dc3e Merge pull request #62146 from xedin/rdar-102085039
[AST] `getParameterAt` should check index before retrieving it
2022-11-28 10:01:51 -08:00
Pavel Yaskevich
8060fa0844 [ResultBuilder] ASTTransform: Don't capture buildBlock into a separate variable
Inject `buildBlock` call into `return`, `buildFinalResult`, and
`build{Optional, Either}` to take advantage of contextual information
and maintain compatibility with current inference behavior.
2022-11-22 11:42:18 -08:00
Anthony Latsis
c50d2214cb build: Mirror LLVM+Xcode-specific build-script-impl logic in CMake build-script product
This fixes the behavior of `--xcode`, which was relying on this logic and was
compromised when LLVM became a build-script product.
2022-11-22 19:44:14 +03:00
Pavel Yaskevich
4e3a4ffbe9 Merge pull request #62120 from xedin/rdar-100753270
[CSSyntaxElement] Detect type variables in sequence expressions of `for-in` loops
2022-11-17 09:54:22 -08:00
Dario Rexin
f63de71001 Merge pull request #38507 from drexin/wip-llvm-build-script
[Build] Make LLVM a build-script product
2022-11-16 20:44:13 -08:00
Pavel Yaskevich
7bc1dc59ab [AST] getParameterAt should check index before retrieving it
`getParameterAt` needs to be more defensive about the input
because caller cannot always perform all the checks upfront.

Resolves: rdar://102085039
2022-11-16 15:34:05 -08:00
Pavel Yaskevich
cab0cb52ab [CSSyntaxElement] Detect type variables in sequence expressions of for-in loops
Invalid syntax could introduce type variables into sequence which
have to be brought into scope otherwise solver is going to crash.

Resolves: rdar://100753270
2022-11-15 11:56:36 -08:00
Holly Borla
0708e0efd4 Revert "Tests: Disable failing SwiftUI validation tests" 2022-11-15 09:10:23 -08:00
Slava Pestov
34c9daa635 Merge pull request #62076 from slavapestov/no-assert-test-hang-fix
Disable 0022-rdar21625478.swift entirely on noassert builds
2022-11-14 19:52:45 -05:00
Allan Shortlidge
b2421aa463 Tests: Disable failing SwiftUI validation tests until rdar://102298208 is fixed. 2022-11-13 16:56:20 -08:00
Slava Pestov
abfe49fd3d Disable 0022-rdar21625478.swift entirely on noassert builds
Fixes rdar://problem/99800538.
2022-11-11 23:31:06 -05:00
Pavel Yaskevich
0a75a07962 [CSSolver] Don't drop bindings with type variables while applying solutions
If a (partial) solution has a type variable it could only be unbound
if `FreeTypeVariableBinding` is set to `Allow`, in all other cases
solution would either have a fully resolved type or a hole.

`applySolution` shouldn't second guess `finalize()` and just apply
a solution as given. This is very important for multi-statement closures
because their elements are solved in isolation and opaque value types
inferred for their result could contain not-yet-resolved type variables
 from outer context in their substitution maps (which it totally legal
under bi-directional inference).
2022-11-10 10:12:38 -08:00
Nuri Amari
48604ca729 Merge pull request #61819 from NuriAmari/remote-ast-runtime-type-mismatch
Fix issues with runtime reporting incorrect types for nested generics
2022-11-07 14:01:38 -08:00
Nuri Amari
66f993194a Fix issues with runtime reporting incorrect types for nested generics
Fixes: https://github.com/apple/swift/issues/60565
2022-11-04 09:43:26 -07:00
Augusto Noronha
352c4c209a Merge pull request #61837 from augusto2112/reflect-optional-bool
Implement reading extra inhabitants of integers
2022-11-03 09:38:25 -07:00
Augusto Noronha
2ae06446a4 Add the reflect_Optional_Bool validation test
Bools are special in that they only need 1 bit of storage, and have many
extra inhabitants available. This adds a test to check that an optional
whose payload is a bool is reflected correctly.
2022-11-02 10:20:24 -07:00
Alsey Coleman Miller
62b7be4e9c [stdlib] Add RISCV64 support 2022-11-01 23:59:42 -07:00
Dario Rexin
3f80cb6712 [Build] Make LLVM a build-script product
rdar://80733826
2022-10-30 22:47:29 -07:00
Arnold Schwaighofer
411b3d2f18 Merge pull request #61750 from aschwaighofer/use_clang_for_protocol_irgen
IRGen: Use clang's codegen for protocol decls
2022-10-28 08:46:08 -07:00
Pavel Yaskevich
e3cd2abdec Merge pull request #61778 from xedin/rdar-98862079
[Diagnostics] Diagnose type with mismatching generic arguments in ternary expr
2022-10-27 19:07:47 -07:00
Pavel Yaskevich
8ab37ca449 [Diagnostics] Diagnose type with mismatching generic arguments in ternary expr
Fixes a missing diagnostic related to types with mismatched
generic arguments in one of both ternary branches.

Resolves: rdar://98862079
2022-10-27 15:56:50 -07:00
Nate Chandler
ed623d7b64 [NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init]
everywhere.
2022-10-27 10:38:54 -07:00
Arnold Schwaighofer
ba9578d6ce IRGen: Use clang's codegen for protocol decls
There are certain protocol method decls types that swift does not import
today.

```
@protocol Incomplete
- (id)getObjectFromVarArgs:(id)first, ...;
@end
```

Furthermore, the old method also emitted duplicate entries for protocols
methods when Swift synthesized methods for diagnosics.

We won't import this method into Swift. So if we emit protocol metadata
from swift delcs we would generate incomplete records.

rdar://60888524
2022-10-26 12:34:25 -07:00
Mike Ash
4945a56344 [Reflection] Put a recursion limit on readTypeFromMetadata.
We can end up with a stack overflow if we encounter a very deeply nested type, or bad data that looks like one. Fail gracefully for types that are nested beyond a limit. By default, the limit is 50.

rdar://100847548
2022-10-25 10:35:51 -04:00
Anthony Latsis
d977dd101f Merge pull request #61469 from AnthonyLatsis/verify-bugs
tests: Address a few stale FIXMEs & replace some commented-out test cases with verifications
2022-10-10 15:16:49 +03:00
Becca Royal-Gordon
f66d5cd9cf Merge pull request #61463 from beccadax/lint-trap
Move Python linting to primary tests
2022-10-07 13:57:35 -07:00
Evan Wilde
64b19f7f45 Backdeploy task_wait_future fix to Swift 5.6 (#61254)
* Backdeploy swift_task_future_wait

This patch adds the implementation for `swift_task_future_wait`
entrypoint to the backdeploy library.

This involves pulling in `AsyncTask::waitFuture`, which relies on a fair
bit.

Please note, this pulls in the `StaticMutex` implementation from Swift
5.6. There are some challenges here. The concurrency version of the
`StaticMutex` involves a fairly nasty set of ODR violations in the
normal setup. See `public/Concurrency/Mutex.cpp`, which includes the
Mutex implementations cpp files directly, while defining a single macro
to replace the implementation of swift::fatalError with
swift_concurrency_fatalError. We only need the concurrency mutex (at
least for now), so I have hard-coded the `swift_concurrency_fatalError`
version into this library. If we should need the other implementation,
we are forced to include ODR-related undefined behavior.

We need symbols from C++, so I've added an implicit linker flag whenever
the static library is used, namely, it passes `-lc++` to the linker.
Since we only backdeploy on Apple platforms, this should be fine.

Some of the platform runtimes we need to backdeploy to have the
enter/exitThreadLocalContext functions defined, while others don't. We
define our own backdeploy56 shim function that dlsym's the function
pointer for these symbols if we have exclusivity checking available.
Otherwise, it doesn't do anything. If concurrency exclusivity checking
is available, we'll use it, otherwise we wont'.

The same dlsym check is done for `swift_task_escalate`. Not all
platforms we need to backdeploy to have a concurrency runtime. The
symbols that do need to use pieces of the concurrency runtime should not
be getting hit when deploying to systems that don't have concurrency. In
the event that you've gotten around the language blocking you from
calling these symbols and you've managed to call concurrency pieces
without using concurrency, we'll abort because something is seriously
wrong.

* Backdeploy swift_task_future_wait_throwing

Drop the remaining pieces in for adding
`swift_task_future_wait_throwing`.

* Apply task_wait_future fix

Actually apply the fix from ef80a315f8.

This deviates slightly from the original patch.

AsyncTask::PrivateStorage::_Status() does not exist in the Swift 5.6
library. Instead I am using `AsyncTask::PrivateStorage::Status`.

* Workaround missing compiler-rt linking

Working around the missing link against compiler-rt in these test.
They are a bit brittle as if anything in them uses compiler-rt, they
will start failing. The backdeploy 5.6 library uses some symbols from
compiler-rt, thus causes them to fail to link.

Disabling the runtime compatibility version checking to avoid these
symbols. This should be fine for the MicroStdlib test, but we should fix
'%target-ld' to handle this better in the future.
rdar://100868842
2022-10-07 09:36:17 -07:00
Anthony Latsis
6637c18954 Address a few stale FIXMEs & replace some commented-out test cases with verifications 2022-10-06 16:39:18 +03:00
Becca Royal-Gordon
1cc7e3b72c Move Python linting to primary tests
This will make it more likely that contributors discover Python style mistakes at their desks instead of in Swift CI.
2022-10-05 16:19:04 -07:00