Commit Graph

546 Commits

Author SHA1 Message Date
Slava Pestov
6363961e90 Split up a couple more tests into stable and pre-stable ABI deployment target versions 2019-05-21 17:30:13 -04:00
Slava Pestov
5d66bb810a Run stable ABI tests on all Apple platforms
A number of tests exercise features only available in Apple OSes that
shipped with Swift 5.0 in the OS; this includes the following versions:

- macOS 10.14.4
- iOS 12.2
- tvOS 12.2
- watchOS 5.2

Previously these tests were restricted to running on macOS only, with
an explicit -target x86_64-apple-macosx10.14.4. To get better test
coverage, add a new %target-stable-abi-triple substitution which
expands to a triple with the correct OS version on all Apple platforms.

On non-Apple platforms, this is the same as %target-variant-triple,
but for now any test that uses this exercises Apple platform features
anyway.

One caveat is that since iOS 12.2 does not have a 32-bit slice, we
have to skip any tests that use -target %target-stable-abi-triple
on this platform. A new swift_stable_abi feature flag can be tested
with 'REQUIRES: swift_stable_abi'. To get maximum test coverage,
I split off a 'stable_abi' version of a few tests that build with both
an old and new deployment target. This allows the old deployment
target case to still be tested on 32-bit iOS.
2019-05-16 17:02:06 -04:00
Slava Pestov
c954dfa6a9 Sema: Tweak test/decl/protocol/conforms/nscoding.swift a bit
Make sure we test on both an "old" and "new" deployment target.
2019-05-03 18:56:46 -04:00
Slava Pestov
04ac33dd2b Sema: Fix order dependency in @objc inference from witnessed protocol requirement
If we haven't validated the declaration yet, the 'witnesses @objc
requirement' check would immediately fail. Move the validateDecl()
call to matchWitness() to fix this.

Fixes <rdar://problem/49482328>, <https://bugs.swift.org/browse/SR-10257>.
2019-04-24 17:35:05 -04:00
fischertony
00e6ae1bf3 consolidate func & subscript signature validation 2019-04-20 00:15:12 +03:00
Slava Pestov
06c819d46e Sema: Allow protocols to inherit from subclass existentials
This was a regression from 7566f98a45.

Fixes <rdar://problem/50022955>.
2019-04-18 17:48:28 -04:00
kitasuke
543ddbceee Remove NSKeyedArchiver family support for decl attributes 2019-04-15 17:33:51 +09:00
Brent Royal-Gordon
c37fee1719 Add parallel tests for static subscripts
This commit modifies various subscript-related test files to add static subscript equivalents of existing tests.
2019-04-10 23:17:04 -07:00
Jordan Rose
33438bd0f8 Add a test for circular protocol inheritance through a typealias
We could do better on the diagnostics here, but it's not that
important.

https://bugs.swift.org/browse/SR-9224
2019-04-09 18:17:57 -07:00
Slava Pestov
7566f98a45 Sema: Diagnose enum inheritance clause containing subclass existential
Also, tidy up the code a bit and stop emitting redundant diagnostics for
associated types.

Fixes <https://bugs.swift.org/browse/SR-10232>.
2019-04-01 22:41:16 -04:00
Pavel Yaskevich
688042becf [Diagnostics] Add inaccessible member diagnostic 2019-03-18 13:48:08 -07:00
Slava Pestov
8e14023868 Merge pull request #23280 from slavapestov/enable-resilience-flag
Rename -enable-resilience to -enable-library-evolution and make it a driver flag
2019-03-15 14:26:16 -04:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Brent Royal-Gordon
f2102fccf8 Fix name confusion in Decodable synthesis
Decodable’s init(from:) synthesis sometimes mistook a static property for an identically-named instance property, which could cause it to skip a property or possibly make other mistakes. This change factors a common helper function from encode(to:) and init(from:) synthesis which implements the right logic for both.
2019-03-12 16:32:21 -07:00
Pavel Yaskevich
aeaa26d926 [CSDiagnostics] Add missing arguments failure
Currently only supports closures, but could be easily expanded
to other types of situations e.g. function/member calls.
2019-02-26 13:29:35 -08:00
Slava Pestov
780612cf03 Merge pull request #22800 from slavapestov/witness-access-check-crash
Sema: Fix crashes in witness access control checking
2019-02-22 21:21:47 -05:00
Suyash Srijan
34f8670d2a [CS] Use fixes to diagnose instance member on type (or vice versa) access (#21830)
This PR migrates instance member on type and type member on instance diagnostics handling to use the new diagnostics framework (fixes) and create more reliable and accurate diagnostics in such scenarios.
2019-02-22 16:57:26 -08:00
Slava Pestov
0dba5626b2 Sema: Fix crashes in witness access control checking
This fixes a crash-on-invalid regression from the fix for
<rdar://problem/43824052>.
2019-02-22 14:03:39 -05:00
Doug Gregor
e3729f444a Revert "[GSB] When adding same-type requirements pick representative based on canonical order"
This reverts commit c725660cc9. It
uncovered a use-after-free in the GenericSignatureBuilder. Apologies
for the lack of a test case here; I'm still looking for something
small enough to commit.

Fixes rdar://problem/46772328.
2018-12-21 09:44:48 -08:00
Harlan Haskins
62f9edf647 [Sema] Don't print __consuming when suggesting protocol requirement stubs 2018-12-18 11:26:37 -08:00
Slava Pestov
8c653332ef Sema: Fix failure to emit a diagnostic when a protocol witness is being validated already
Validating a declaration can trigger conformance checking. If the conformance checker
comes across the same declaration as a candidate witness, it would fail to emit a
diagnostic. As a result we would then go onto SILGen, which would crash while emitting
a witness table with a missing entry.

Fixes <rdar://problem/45151902>.
2018-12-07 20:44:59 -05:00
John McCall
8112f68b96 Merge pull request #20629 from rjmccall/error-self-conformance
Allow Error to conform to itself
2018-12-05 19:58:08 -05:00
Karoy Lorentey
666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Pavel Yaskevich
c725660cc9 [GSB] When adding same-type requirements pick representative based on canonical order
Instead of trying to order based on the "nested depth", let's
always prefer canonical ordering of type parameters when it comes
to picking representative equivalence class.

Resolves: rdar://problem/45957015
2018-11-23 00:08:14 -08:00
John McCall
49ba9c59d1 Allow Error to conform to itself.
Most of the foundation for this was laid in earlier patches.
2018-11-17 02:51:45 -05:00
Vinicius Vendramini
39d3963131 Fix broken tests
- Many tests got broken because of two things:
  - AST dump now outputs to stdout, but many tests expected stderr. This was a straightforward fix.
  - Many tests call swift with specific parameters; specifically, many call `swift frontend` directly. This makes them go through the compiler in unexpected ways, and specifically it makes them not have primary files, which breaks the new AST dump implementation. This commit adds the old implementation as a fallback for those cases, except it dumps to `stdout` to maintain some consistence.

Finally, the `/test/Driver/filelists.swift` failed for unknown reasons. It seems its output now had some lines out of order, and fixing the order made the test pass. However, as the reasons why it failed are unknown, this fix might not have been a good idea. Corrections are welcome.
2018-11-14 13:38:01 -02:00
Slava Pestov
97cc601ac9 Sema: A protocol with a class constraint is a subtype of any protocols the class conforms to
The logic was slightly wrong before.

Fixes <rdar://problem/45647080>.
2018-11-06 18:14:50 -05:00
Doug Gregor
feb1b55de2 [Name lookup] Look through parentheses when finding type references.
When resolving type declarations in, e.g., the inherited type declarations
request, look through parenthesized types. Fixes rdar://problem/45527696.
2018-10-24 14:02:24 -07:00
Greg Titus
d20fdf5f82 Merge pull request #19920 from gregomni/8757
[Sema][QoI] Call out missing conformances in protocol witness candidates.
2018-10-22 16:39:51 -07:00
gregomni
b91e455064 Worked out my confusion with existentials, and pulled out constraint fix checking into a separate function and try it with multiple fixes, if they exist. 2018-10-20 09:42:55 -07:00
gregomni
939de4fb4a Extend candidate missing conformance checking to other types of requirements so that we check superclass and same type requirements in the same way. 2018-10-19 10:02:30 -07:00
gregomni
002c04ef96 Modified diagnostics a bit given feedback 2018-10-17 07:35:44 -07:00
gregomni
f2a80c4a9d Let CS::solveSingle() optionally allow fixes in the solution. Use this in protocol inference to give better candidate failure notes. 2018-10-16 15:27:09 -07:00
Greg Titus
4f8e3f3597 Merge pull request #19879 from gregomni/8757
[Sema] Omit protocol match diagnosis for constructors with differing names.
2018-10-16 09:36:16 -07:00
Slava Pestov
4ef1904e88 AST: Don't allow declarations to shadow generic parameters
Associated type inference can synthesize type aliases with the same name
as a generic parameter. This is all fine since the underlying type of
the alias is the generic parameter type, however it might have been
synthesized in a constrained extension, resulting in bogus diagnostics
that depend on the order in which declarations are type checked, which
can vary between WMO and non-WMO, different batch mode settings, etc.

Instead, let's just check the generic parameter list first.

Fixes <rdar://problem/22587551>, <rdar://problem/44777661>.
2018-10-15 19:24:27 -07:00
Slava Pestov
8a93766633 Merge pull request #19869 from slavapestov/unqualified-lookup-fixes
Unqualified lookup fixes
2018-10-15 13:09:21 -07:00
gregomni
2e23ee5257 Exclude non-matching name diagonses for all candidates. 2018-10-15 07:48:24 -07:00
Greg Titus
d098e8a529 Merge pull request #19873 from gregomni/8934
[Sema][CS] Re-try failedConstraint during salvage
2018-10-15 06:57:09 -07:00
Slava Pestov
6f97923aac Sema: Tweak TypeResolution::areSameType() for when both types are type parameters
We can use a cheaper check; instead of transforming both types and
replacing any type parameters with their anchors, instead just
check if both map to the same equivalence class.

This also fixes a bug, even though it shouldn't, but I'll take it.

Fixes <rdar://problem/35756206>.
2018-10-15 01:52:11 -07:00
Slava Pestov
8acc11f80c Sema: Fix ambiguity resolution when doing unqualified lookup of associated types and type aliases
In structural lookup mode, let's resolve protocol typealiases to
dependent member types also. This is because areSameType() has
no way to see if a type alias is going to be equal to another
associated type with the same name, and so it would return false,
which produced ambiguity errors when there should not be any.

This exposes a deficiency in how we diagnose same-type constraints
where both sides are concrete. Instead of performing the check on
the requirement types, which might be dependent member types that
later on resolve to concrete types, do the check on the actual
equivalence classes further down in the GSB instead.

However, this in turn produces bogus diagnostics in some recursive
cases where we add same-type constraints twice for some reason,
resulting in a warning the second time around. Refine the check by
adding a new predicate to FloatingRequirementSource for requirements
that are explicitly written in source... which is not what
isExplicit() currently means.
2018-10-15 01:52:11 -07:00
Greg Titus
7d0bdb112e Omit protocol match diagnosis for constructors with differing names. 2018-10-14 17:08:50 -07:00
Greg Titus
5f2400580e Merge pull request #19830 from gregomni/8813
[Sema] When resolving type declarations, if there is an error with a typealias,...
2018-10-13 21:39:10 -07:00
gregomni
b7df1ca1df Re-try a failingConstraint during salvage now that attemptFixes is turned on. This enables better missing conforms-to diagnoses. 2018-10-13 20:06:19 -07:00
Slava Pestov
9d131fd5f1 Merge pull request #18999 from hamishknight/location-by-association
[GSB] Avoid emitting associated type diagnostics on the protocol decl
2018-10-13 15:16:40 -07:00
Slava Pestov
3178d6d8ac Merge pull request #19760 from gregomni/8902
[Sema]Allow associated type inference for requirement returning dynamic Self...
2018-10-13 15:14:47 -07:00
gregomni
bb98a0f95f Simplify checking code as much as possible, since this is a hacky diagnosis anyway. 2018-10-12 07:23:56 -07:00
Slava Pestov
64f12ff936 Sema: Allow protocols with 'Self' constraints again
These two declarations are now equivalent:

  protocol P : SomeClass { ... }
  protocol P where Self : SomeClass { ... }

There's a long, complicated story here:

- Swift 4.2 rejected classes in the inheritance clause of a
  protocol, but it accepted the 'where' clause form, even
  though it didn't always work and would sometimes crash

- Recently we got the inheritance clause form working, and
  added a diagnostic to ban the 'where' clause form, because
  we thought it would simplify name lookup to not have to
  consider the 'where' clause

- However, we already had to support looking at the 'where'
  clause from name lookup anyway, because you could write

  extension P where Self : SomeClass { ... }

- It turns out that despite the crashes, protocols with
  'Self' constraints were already common enough that it was
  worth supporting the existing behavior, instead of banning
  it

Fixes <rdar://problem/43028442>.
2018-10-12 03:06:52 -07:00
Slava Pestov
2be8c0085d Sema: Hackaround a crash with lookup inside an invalid extension
An extension might have an extended nominal, even if the extended type
is an error type. This can happen if, for example, the type lookup was
ambiguous, because the declaration lookup more eagerly disambiguates.

This is fine, because even if we bind the extension to a nominal it's
okay to diagnose an error later. However, we do have to deal with this
case here by checking for an error type.

A better solution would be to ensure the extended type is always set
to something, even if we diagnosed an error while resolving it, because
we can always use the declared type of the extended nominal instead.

However when I tried that I ran into more problems, and I don't feel
like shaving this yak right now.
2018-10-12 03:06:52 -07:00
gregomni
d9e4eaa7d0 Add test 2018-10-11 15:33:31 -07:00
gregomni
42a24ebb71 Use hasDynamicSelfType and add another test where the result type is complex and includes the non-dynamic self. 2018-10-11 13:31:56 -07:00