Commit Graph

5899 Commits

Author SHA1 Message Date
Pavel Yaskevich
8e95096e85 [TypeChecker] NFC: Add a test-case for rdar://70880670 2020-11-04 16:19:51 -08:00
Pavel Yaskevich
1c65a55633 [CSGen] Turn invalid decls into holes
Instead of failing constraint generation upon encountering
an invalid declaration, let's turn that declaration into a
potential hole and keep going. Doing so enables the solver
to reach a solution and diagnose any other issue with
expression.
2020-11-04 16:19:38 -08:00
Holly Borla
099560813e [ConstraintSystem] Only factor in existing operator bindings in
selectDisjunction if both disjunctions are operator bindings.
2020-11-04 15:23:12 -08:00
Ben Rimmington
824e4d0cad [SE-0270] Reset availability of RangeSet APIs (#34567) 2020-11-04 16:49:18 -06:00
Rintaro Ishizaki
d78bf22413 [CodeCompletion] Fix crashes in TypeCheckASTNodeAtLocRequest
receive {
    switch <HERE>
  }

In the current Parser implementation, if there's a error in 'switch'
subject, the 'SwitchStmt' is not placed in the parsed AST.

When the type checker searches AST node at the location, it used to find
'receive { ... }' because that is the *innermost* node in the AST that
contains the loc. But the decl context is the closure. This behavior used
to cause crashes because 'receive { ... }' is re-typechecked.

For solution, when finding the innermost AST node, clear the found node
in parent context before walking into brace statement.

rdar://problem/69246891
2020-10-30 15:56:31 -07:00
Rintaro Ishizaki
147015da55 [Test] Fix test cases (#34511) 2020-10-30 08:10:51 -07:00
swift-ci
28182942d9 Merge pull request #34505 from CodaFi/verifly 2020-10-29 19:52:40 -07:00
Holly Borla
8dd2008f7e [Test] Adjust type checker performance tests 2020-10-29 19:49:47 -07:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Robert Widmann
6204b371f3 [Gardening] Strip -verify out of a test that doesn't need it 2020-10-29 17:19:07 -07:00
Rintaro Ishizaki
a69502e6b1 Merge pull request #34486 from rintaro/ide-completion-rdar69246891
[CodeCompletion] Fix a crash in collectPossibleReturnTypesFromContext
2020-10-29 09:27:25 -07:00
tbkka
b0675c0dd6 [DynamicCast] Rely on runtime when casts can't be optimized (#33761)
* [DynamicCast] Rely on runtime when casts can't be optimized

The Swift compiler renders `as?` operations in Swift into variations of the
`checked_cast_br` instructions in SIL.  Subsequent optimization passes may alter
or eliminate these instructions.  Any remaining instructions after optimization
are translated by IRGen into runtime calls.

At least, that's the theory.  Unfortunately, the current IRGen logic does not
recognize all of the casting instruction variants and renders one particular
unrecognized variant as a simple nil load.  Specifically, this occurs for
optimized casts of metatypes to AnyObject:
```
  let a = Int.self
  let b = a as? AnyObject
  // b should not be nil here
```

This PR changes this case in IRGen to instead generate a call to
`swift_dynamicCast`, deferring this case to the runtime.

Future:  Someday, the compiler should be taught to correctly optimize
this cast away.
2020-10-28 15:59:13 -07:00
Rintaro Ishizaki
84205e3c97 [CodeCompletion] Fix a crash in collectPossibleReturnTypesFromContext
Avoid re-typechecking for nested closures. For example:

  Something {
    Other {
      #^COMPLETE^#
    }
  }

If 'Something' is successfully type checked but 'Other' is failed, the
outer closure has type, but the inner closure doesn't. In such state,
when the type of 'Other' is requested, the outer closure used to be
re-typechecked. That may cause crash because it may contain expressions
CSGen doesn't expect.

rdar://problem/69246891
2020-10-28 15:21:13 -07:00
Pavel Yaskevich
811fc0659f Merge pull request #34467 from xedin/protocol-conformance-error-as-note
[Diagnostics] Split "only concrete types conform to protocols" into a separate note
2020-10-27 17:54:11 -07:00
Pavel Yaskevich
f24e5dbd26 [Diangostics] NFC: Adjust test-cases to expect that "type cannot conform" diagnostic has a note 2020-10-27 14:54:07 -07:00
Gwen Mittertreiner
c10064a698 Merge pull request #34407 from rmaz/testconfig
Make it possible to configure Swift test options with CMake
2020-10-27 09:05:37 -07:00
Kuba (Brecka) Mracek
d7dfa3e942 Bring up tests + validation tests for the 'freestanding' build and the standalone_minimal preset (#34386) 2020-10-26 16:32:36 -07:00
Karoy Lorentey
58d07a4efd Merge pull request #34426 from lorentey/array-cannot-append
[stdlib] Fix Array.append(contentsOf:) for arguments of type NSArray
2020-10-26 14:12:49 -07:00
Richard Howell
8b6a09b1f1 configure Swift test options with CMake 2020-10-26 13:54:07 -07:00
Alejandro Alonso
84e5fd2137 Merge pull request #28833 from Azoy/void-is-equatable
[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples
2020-10-26 13:53:29 -04:00
Karoy Lorentey
184367ca8f [stdlib] Fix Array.append(contentsOf:) for arguments of type NSArray
Due to a couple of unfortunate circumstances, appending an NSArray instance to an Array instance does not actually append any elements.

The cause is https://github.com/apple/swift/pull/29220, which accidentally optimized away the actual loop that appends the elements in this particular case. (And only this particular case, which is why this wasn’t detected by the test suite.)

When the argument to `Array.append(contentsOf:)` is of type NSArray, the `newElements is [Element]` expression is compiled into a runtime check that returns true, eliminating the subsequent loop over the remaining items of the iterator. Sadly, NSArray.underestimatedCount` currently returns 0, so the earlier _copyContents call is a noop, so no elements get added to `self` at all.

Turning the `is` test into a direct equality check between the metatype instances resolves the issue.
2020-10-24 18:17:52 -07:00
Slava Pestov
acef0261fc Add regression test for https://bugs.swift.org/browse/SR-13727 / rdar://problem/70298061 2020-10-23 17:07:30 -04:00
Slava Pestov
b3578abe69 Add regression test for https://bugs.swift.org/browse/SR-12473 / rdar://problem/61111969 2020-10-23 17:06:20 -04:00
Azoy
05cc4aa8af [Runtime] Emit non lazy stub pointers for 32 bit x86 for tuple conformances 2020-10-22 18:28:38 -04:00
John McCall
a8464dcaf1 Implicitly import _Concurrency under -enable-experimental-concurrency 2020-10-22 00:53:15 -04:00
Doug Gregor
6a40a3a8aa [SE-0289] Add support for @resultBuilder.
"Function builders" are being renamed to "result builders". Add the
corresponding `@resultBuilder` attribute, with `@_functionBuilder` as
an alias for it, Update test cases to use @resultBuilder.
2020-10-20 13:24:51 -07:00
Slava Pestov
c39bb8970a Add regression test for https://bugs.swift.org/browse/SR-8456 2020-10-19 16:03:06 -04:00
Mishal Shah
21f4cf6a9c [XFAIL] Disable validation-test/stdlib/CommandLine.swift (70423908) 2020-10-18 17:42:21 -07:00
Holly Borla
1e0038c3be [ConstraintSystem] Remove implementation of operator designated types
in the solver.
2020-10-14 16:05:54 -07:00
nate-chandler
c9115dc7c5 Merge pull request #34277 from nate-chandler/concurrency/irgen/thread-emission-through-emit-polymorphic
[Async CC] Pull polymorphic parameters from entry point emission.
2020-10-12 14:13:03 -07:00
Nate Chandler
6fce6d9363 [Async CC] Pull poly params from entry point emission.
Previously, EmitPolymorphicParameters dealt directly with an Explosion
from which it pulled values.  In one place, there was a conditional
check for async which handled some cases.  There was however another
place where the polymorphic parameter was pulled directly from the
explosion.  That missed case resulted in attempting to pull a
polymorphic parameter directly from an Explosion which contains only a
%swift.context* per the async calling convention.

Here, those parameters are now pulled from an EntryPointArgumentEmission
subclasses of which are able to provide the relevant definition of what
pulling a parameter means.

rdar://problem/70144083
2020-10-12 10:52:23 -07:00
Slava Pestov
e59069f60f Add a couple of crashers that are now fixed 2020-10-07 12:33:58 -04:00
Slava Pestov
bd36100cb3 Update tests in preparation for disabling parser lookup
I created a second copy of each test where the output changes
after disabling parser lookup. The primary copy now explicitly
calls the frontend with -disable-parser-lookup and expects the
new diagnostics; the *_parser_lookup.swift version calls the
frontend with -enable-parser-lookup and has the old expectations.

This allows us to turn parser lookup on and off by default
without disturbing tests. Once parser lookup is completely
removed we can remove the *_parser_lookup.swift variants.
2020-10-03 09:37:55 -04:00
Robert Widmann
74765a8ba8 Remove Type Body Fingerprints Flags
This infrastructure has more than proven itself. Drop the code paths and tests supporting the status quo.
2020-10-01 13:09:00 -07:00
Saleem Abdulrasool
af868e5c8f build: migrate towards the unified directory layout for modules
This changes the install layout to be similar across Darwin and
non-Darwin platforms.  This will enable simplifying the user experience,
build infrastructure, and the driver as the SDK layout converges towards
a single layout on all the platforms.
2020-09-13 17:46:54 -07:00
adrian-prantl
4247b6008e Merge pull request #33417 from adrian-prantl/55412920
Add a callback to swift::reflection::MemoryReader that allows LLDB to…
2020-09-08 09:56:21 -07:00
Robert Widmann
161fa16cf8 Revert "Turn on Verbose Output For Test"
This reverts commit c34212aa20.
2020-08-29 17:20:49 -07:00
Robert Widmann
c34212aa20 Turn on Verbose Output For Test 2020-08-29 09:40:09 -07:00
Robert Widmann
592d427876 Merge pull request #33668 from CodaFi/field-day
[SR-13461] Relax An Assert
2020-08-28 14:07:23 -07:00
Joe Groff
f588f2f478 Merge pull request #33650 from jckarter/global_init_mangling
Remove hardcoded symbol name parsing from SILOptimizer passes
2020-08-28 08:34:35 -07:00
Joe Groff
0bef4a661b Give global once symbols stabler manglings.
This allows symbol ordering and other analyses to be more robust with regards to these symbols.
2020-08-27 16:00:20 -07:00
Robert Widmann
84c5065547 [SR-13461] Relax An Assert
This assert doesn't consider reference storage types in its predicate.
Look through them since they're not relevant to the type consistency
check it's trying to pick out.
2020-08-27 12:51:04 -07:00
tbkka
524cfae1b2 [Dynamic Casting] Overhauled Runtime (#33561)
* Dynamic Cast Rework: Runtime

This is a completely refactored version of the core swift_dynamicCast
runtime method.

This fixes a number of bugs, especially in the handling of multiply-wrapped
types such as Optional within Any.  The result should be much closer to the
behavior specified by `docs/DynamicCasting.md`.

Most of the type-specific logic is simply copied over from the
earlier implementation, but the overall structure has been changed
to be uniformly recursive.  In particular, this provides uniform
handling of Optional, existentials, Any and other common "box"
types along all paths.  The consistent structure should also be
easier to update in the future with new general types.

Benchmarking does not show any noticable performance implications.

**Temporarily**, the old implementation is still available.  Setting the
environment variable `SWIFT_OLD_DYNAMIC_CAST_RUNTIME` before launching a program
will use the old runtime implementation.  This is only to facilitate testing;
once the new implementation is stable, I expect to completely remove the old
implementation.
2020-08-27 11:06:40 -07:00
Kuba (Brecka) Mracek
9de7b59388 Subsume SWIFT_STDLIB_USE_NONATOMIC_RC into SWIFT_STDLIB_SINGLE_THREADED_RUNTIME (#33643) 2020-08-26 21:28:30 -07:00
Adrian Prantl
56b2e906da Support MetatypeTypeRefs in DemanglingForTypeRef. 2020-08-25 15:44:28 -07:00
Adrian Prantl
9287707520 Support generic parent contexts in DemanglingForTypeRef. 2020-08-25 15:30:50 -07:00
Slava Pestov
5e3ef645e6 AST: Fix ASTScopeLookup crash if a PatternBindingEntry's context is not a PatternBindingInitializer
The function builder transform creates pattern bindings parented
in other DeclContexts. If those pattern binding initializer
expressions in turn contain multi-statement closures, we will
try to perform unqualified lookups from those contexts when we
get around to type checking the closure body.

Change some unconditional casts to conditional casts in ASTScope
lookup, to handle this case. The casts are only performed while
checking if the initializer context is part of a 'lazy'
property, which doesn't apply here.

Fixes <rdar://problem/67265731>.
2020-08-24 22:55:23 -04:00
Slava Pestov
21c9c39fa5 Merge pull request #33548 from slavapestov/redecl-check-set-invalid
Sema: Redeclaration checking should not mark implicit decls as invalid
2020-08-19 09:38:02 -04:00
Slava Pestov
a1255a81aa Merge pull request #33549 from slavapestov/regression-test-sr13141
Add regression test for https://bugs.swift.org/browse/SR-13141
2020-08-19 09:37:52 -04:00
Slava Pestov
487f6d9c47 Add regression test for https://bugs.swift.org/browse/SR-12691 2020-08-18 23:56:57 -04:00