Commit Graph

6090 Commits

Author SHA1 Message Date
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
Slava Pestov
b183c69d4d Add regression test for https://bugs.swift.org/browse/SR-13141 2020-08-18 23:53:55 -04:00
Slava Pestov
876fe2f639 Sema: Redeclaration checking should not mark implicit decls as invalid
If both the 'other' and 'current' declarations are implicit, we don't
emit a diagnostic unless they are both derived from property wrappers
or lazy property storage.

However, we would still call setInvalid() unconditionally, which splats
an ErrorType into the interface type, which would crash in the AST
verifier if no other diagnostic was emitted.

Fixes <rdar://problem/67259506>.
2020-08-18 23:45:52 -04:00
Slava Pestov
d50e3b00bf Add regression test for rdar://problem/62268062 2020-08-18 18:13:31 -04:00
Meghana Gupta
d463c7933e Merge pull request #33520 from meg-gupta/disabletestforasan
Disable test verify_all_overlays.py for asan builds
2020-08-18 11:21:18 -07:00
Meghana Gupta
ee1d975da0 Disable test for asan builds
Raises a stackoverflow error in some asan builds even though it is not a
runaway recursion.
2020-08-17 19:28:40 -07:00
Rintaro Ishizaki
f470902f42 Merge pull request #33492 from rintaro/ide-completion-rdar67102611
[CodeCompletion] Skip an ASTScope assertion for labeled statements
2020-08-17 09:18:15 -07:00
Slava Pestov
6d84c18ba4 Sema: Check 'where' clause requirements on type witnesses
In the included test case, conformance checking of Wrapper : B would
pick up typealias Foo as a witness for the associated type B.Foo.

However, this typealias Foo is defined in a constrained extension where
T : A, and the underlying type references the associated type A.Foo
on T.

The resulting substitution is invalid when the conformance Wrapper : B
is used in a context where T does not conform to A.

Instead, we should ignore this typealias entirely, since it appears
in an unusable constrained extension.

Fixes <rdar://problem/60219705>, <https://bugs.swift.org/browse/SR-12327>,
<https://bugs.swift.org/browse/SR-12663>.
2020-08-15 01:43:13 -04:00
Rintaro Ishizaki
d9a9b59634 [CodeCompletion] Skip an ASTScope assertion for labeled statements
Code completion performs 'typeCheckASTNodeAtLoc()' which ignores
'StmtChecker::ActiveLabeledStmts'. Since this is not necessary for code
completions, skip an assertion to verify the correctness of ASTScope.

rdar://problem/67102611
2020-08-14 16:01:47 -07:00
Slava Pestov
5ad4fa8b07 SIL: Don't canonicalize struct field and enum element types against the wrong signature
The replacement types of the substitution map are either going
to be contextual types, or interface types using some generic
signature. There is no requirement that this generic signature
is the generic signature of the type declaration itself.

By using the generic signature of the type declaration, we
could incorrectly canonicalize generic parameters to concrete
types if the type itself was defined in a constrained extension,
as in the test case here.

Fixes <rdar://problem/65272763>.
2020-08-11 22:54:19 -04:00