Commit Graph

566 Commits

Author SHA1 Message Date
Slava Pestov
034c2be004 GSB: An unresolved DependentMemberType might resolve to a concrete TypeAliasDecl with a dependent underlying type
Fixes https://bugs.swift.org/browse/SR-11639 / rdar://problem/56466696
2021-02-12 17:47:31 -05:00
Slava Pestov
5acd795178 Add regression test for recently-fixed crasher 2021-02-11 16:33:35 -05:00
Slava Pestov
8edf4264ae GSB: Better handling of unresolved DependentMemberTypes in maybeResolveEquivalenceClass()
A DependentMemberType can either have a bound AssociatedTypeDecl,
or it might be 'unresolved' and only store an identifier.

In maybeResolveEquivalenceClass(), we did not handle the unresolved
case when the base type of the DependentMemberType had itself been
resolved to a concrete type.

Fixes <rdar://problem/71162777>.
2021-02-11 16:33:35 -05:00
Robert Widmann
013127a947 Fix a Simple Crash-On-Invalid For @_spi
The parser attempts to recover here by producing a broken VarDecl with
no parent pattern. The DeclChecker sees this when trying to install
a default initializer in the linked regression test and crashes because
it tries to look into a null parent pattern.

rdar://74154023
2021-02-09 12:36:50 -08:00
Slava Pestov
65620d75f3 GSB: FloatingRequirementSource::getSource() now takes a ResolvedType 2021-02-07 01:14:52 -05:00
Daniel Rodríguez Troitiño
748339a83a [test] Mark concurrency tests with appropiate REQUIRES. (#35624)
The Python build system always enables concurrency, but CMake has it
disable by default. Collaborators that do not use the Python build
system and use directly CMake will have it disable, unless they
explicitely enable it. If the tests are not marked as requiring the
concurrency features, the tests will fail to execute when concurrency is
disabled.

The changes add the `REQUIRES: concurrency` line to many tests that deal
with concurrency, but wasn't marked as such.
2021-02-01 11:45:15 -08:00
Robert Widmann
0943351fe7 Use the Correct DeclContext When Simplifying Member Constraints
Looking for the parent source file is going to fail when the paramter
we're interested in comes from a module context. Request the correct
top-level context in those situations.

rdar://73379770
2021-01-20 15:42:35 -08:00
Luciano Almeida
1d7d282065 Merge pull request #35255 from LucianoPAlmeida/SR-12383
[SR-12383][Diagnostics] Do not use canonical type for aka diagnostics instead walk the type recursivelly desugaring
2021-01-19 08:19:00 -03:00
Slava Pestov
c8aee4180e Sema: Fix a couple of crash-on-invalid problems with class inheritance
It is possible for ClassDecl::getSuperclassDecl() to succeed but for
ClassDecl::getSuperclass() to fail. This happens if the superclass is
a generic type and one of the generic arguments could not be resolved,
or does not satisfy the generic requirements, for example; in that
case, a BoundGenericType cannot be formed.

In a couple of places we were not prepared for this possibility.
Let's recover by making judicious use of ErrorType.

Fixes <rdar://problem/73169149>.
2021-01-17 18:06:13 -05:00
Varun Gandhi
b263e99d71 Merge pull request #35367 from mininny/simplify-unused-lvalue-wording
[Diagnostics] Simplify unused lvalue warning wording
2021-01-16 14:29:43 -08:00
Minhyuk Kim
7eaabe1996 Simplify unused lvalue warning wording 2021-01-15 22:14:56 +09:00
Luciano Almeida
b9dec7da4c [test] Adjusting tests for generic parameters that are now being aka on diagnostics 2021-01-14 17:44:52 -03:00
Anthony Latsis
afcb1665f8 GSB: Handle concrete ResolvedTypes in ArchetypeType::resolveNestedType()
A nested type of an archetype type might be concrete, for example, via a
same-type constraint:

extension SomeProtocol where SomeAssoc == Int {
  ... Self.SomeAssoc ...
}

This can happen in one of two ways; either the EquivalenceClass of the
nested type has a concrete type, or it is "fully concrete" because
there is no equivalence class and maybeResolveEquivalenceClass() returns
a ResolvedType storing the concrete type.

For some reason we didn't handle the second case here.

Fixes https://bugs.swift.org/browse/SR-13519 / rdar://problem/68531679
2021-01-12 23:52:44 -05:00
David Zarzycki
238413d349 [testing] add missing REQUIRES: concurrency 2020-12-17 09:03:04 -05:00
Nate Chandler
d2726c31bb [Async CC] Don't lookup known archetype conformance.
Previously, when saving NecessaryBindings for an async function, if a
type that was passed-in happened to be an archetype, a lookup for that
type's conformance would always be done.  However, that lookup was not
always necessary or possible such as in the case where both the metadata
and the witness table were provided to the function in an async context.
Here, that is fixed by using the conformance that was seen when
constructing the NecessaryBindings if one is available.

rdar://problem/72397303
2020-12-16 17:20:31 -08:00
David Zarzycki
0e650c1c89 [Testing] Add missing REQUIRES 2020-12-01 06:39:13 -05:00
Nate Chandler
f33f1d3646 [Async CC] Always add full type metadata to bindings.
NecessaryBindings are used by both async functions and partial apply
forwarders.  The latter are able to avoid bindings in some cases because
a new function is generated where the information that would otherwise
be available in the bindings can be made available.  That is not the
case for async functions.  A generic async function requires all of the
metadata and witness tables be passed along to it: unlike a partial
apply forwarder it isn't in any way specialized so this information
can't be recovered.

Previously, metadata bindings were always passed along to async
functions.  However, destructuring that can be done for partial apply
forwarders was still being applied.  This resulted in an inappropriate
and unexpected number of bindings in NecessaryBindings.

Here, that destructuring is avoided for metadata passed to async
functions.

Now, the full metadata required by async functions are passed along to
them as necessary.

rdar://problem/71816041
2020-11-30 14:02:56 -08:00
nate-chandler
84f92a3f00 Merge pull request #34784 from nate-chandler/concurrency/irgen/rdar71491604
[Async CC] Find wtable in async context in thunk.
2020-11-17 14:56:49 -08:00
Slava Pestov
fe5be6368e Merge pull request #34772 from slavapestov/fix-lazy-getter-source-range
Sema: Fix source range of 'lazy' property getter
2020-11-17 17:23:22 -05:00
Slava Pestov
9a510b8ffa Merge pull request #34773 from slavapestov/fix-objc-attr-diagnostic
Sema: Still diagnose '@objc' even if Foundation was imported
2020-11-17 17:22:48 -05:00
Slava Pestov
96c9456ee8 Sema: Still diagnose '@objc' even if Foundation was imported
We checked for an import of a module named 'Foundation' before
checking if Objective-C interoperability was enabled, which
would lead to hilarious results.

Fixes <https://bugs.swift.org/browse/SR-13713> / <rdar://problem/70140319>.
2020-11-17 14:54:34 -05:00
Nate Chandler
e06d316fe7 [Async CC] Find wtable in async context in thunk.
Previously, when looking up a protocol method, the witness table was
always exepcted to be the final argument passed to the function.

That is true for sync protocol witnesses but not for async witnesses.
In the async case, the witness table is embedded in the async context.

Here, the witness table is dug out of the async context.

rdar://problem/71491604
2020-11-17 11:23:37 -08:00
Slava Pestov
756357b8a2 Sema: Fix source range of 'lazy' property getter
The source range of the getter's body was set incorrectly;
both the start and the end were the property's location.

Instead, let's use the source range of the initializer
expression, which fixes an assertion in name lookup.

Fixes <rdar://problem/70732736>.
2020-11-16 23:46:11 -05:00
Slava Pestov
5808d9beb9 Parse: Remove parse-time name lookup 2020-11-16 22:39:44 -05:00
David Zarzycki
b1448edfba [Testing] Add missing REQUIRES: concurrency 2020-11-16 05:54:44 -05:00
Nate Chandler
e27647244d [AsyncCC] Resolve metadata from class instances.
Metadata for an instance of a type is resolved by extracting it from an
instance of the class.  When doing method lookup for an instance method
of a resilient class, the lowered self value was being obtained from the
list of arguments directly by indexing.  That does not apply to async
functions where self is embedded within the async context.  Here, the
self parameter is extracted from the async context so that the metadata
can in turn be extracted from it.

rdar://problem/71260862
2020-11-14 15:15:12 -08:00
Nate Chandler
11723ccc55 [Async CC] Never map to native explosions.
Previously, when lowering the entry point of an async function, the
parameters were lowered to explosions that matched those of sync
functions, namely native explosions.  That is incorrect for async
functions where the structured values are within the async context.
Here, that error is fixed, by adding a new customization point to
NativeCCEntryPointArgumentEmission which behaves as before for sync
functions but which simply extracts an argument from the async context
for async functions.

rdar://problem/71260972
2020-11-13 19:45:03 -08:00
Robert Widmann
2aac6d2af4 Merge pull request #34679 from CodaFi/quality-of-type
Fix Crashes When Resolving Clang Types For Unrepresentable UnsafePointers
2020-11-10 18:53:33 -08:00
Robert Widmann
591c70e364 Fix Crashes When Resolving Clang Types For Unrepresentable UnsafePointers
If the underlying pointer type was not representable in C, we would
attempt to form a pointer type with a null underlying type and crash.
2020-11-10 16:04:05 -08:00
Robert Widmann
363b66a7ad Fully Qualify the Parent Type When Diagnosing Missing Member Types
Use the FullyQualified<Type> abstraction from the prior commit plus DescriptiveDeclKind to give a bit more information when issuing a missing member type diagnostic during type resolution.
2020-11-09 17:10:18 -08:00
Ben Barham
ea365d5d18 [TypeChecker] Do not attempt to skip typechecking for didSet
15f8eb45ea (see PR#26632) introduced
refined didSet semantics where the `oldValue` parameter is skipped if it
isn't used. This would perform typechecking, but later try to set the
body to skipped and thus fire an assert.

For now, do not attempt to skip typechecking of didSet accessors. Still
skip outputting their SIL though.
2020-11-05 11:27:38 +10: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
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
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
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
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
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
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