Commit Graph

716 Commits

Author SHA1 Message Date
swift-ci
adf83617ec Merge pull request #13526 from DougGregor/remove-conditional-conformances-flag 2017-12-19 11:17:44 -08:00
Doug Gregor
5c831a71ee Revert "[SE-0143] Put conditional conformances behind an "experimental" flag."
This reverts commit b59c30c1af.
2017-12-18 22:54:31 -08:00
Pavel Yaskevich
366356f9ca [Mangling/ABI] NFC: Fix Sema tests to reflect label mangling changes 2017-12-18 15:44:25 -08:00
Robert Widmann
43f06afef2 Defer analysis of large switch bodies
This presents a regression in diagnostic quality that is definitely
worth it not to lie to SILGen about whether a switch is covered or not.

At the same time, disable SIL’s unreachable diagnostic for ‘default’
clauses which would previously cause a warning to be emitted if the
default was proven to be unreachable.  This analysis is incomplete
anyways and can be done by Sema in the future if we desire.
2017-12-13 16:22:48 -05:00
Robert Widmann
8990bd00b6 Stricter enforcement of the "large space" heuristic
The Space Engine includes a heuristic that attempted a combinatorics-
based check to see if a pattern covered an insufficient amount of cases.
In straight-line switches this avoided computing a subspace match that
would have been quite expensive computationally.  However, when
expressive patterns (like tuple patterns) are used, it can fool the
check because the covered space is much larger than the actual size of
the space due to pattern overlap that counting like this simply can't detect.

Instead, just do the right thing and perform a space subtraction after
the existing preconditions for the heuristic are satisfied.

Resolves SR-6316
2017-12-13 14:35:53 -05:00
Mark Lacey
73a492dc4f For Swift 3/4 mode, do not treat IUOs in illegal positions as Optionals.
Instead, just emit a deprecation warning and suggest switching to Optionals.

The old behavior caused several projects to break, so before we change
the behavior here we need to investigate whether we can mitigate most
of those breaks.
2017-12-04 16:15:13 -08:00
Jordan Rose
8f8f00012a Merge pull request #12834 from jrose-apple/restrict-cross-module-struct-initializers-2
Implementation of SE-0189 "Restrict cross-module struct initializers to be delegating"

rdar://problem/34777878
2017-11-30 13:32:45 -08:00
Slava Pestov
e360da57bb Sema: Use the correct source range when emitting fixits for unresolved member expressions
Fixes <rdar://problem/34421732>.
2017-11-29 18:23:17 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
Doug Gregor
ba6f605d47 Fix some tests due to Equatable Optional/Array/Dictionary change. 2017-11-27 21:09:50 -08:00
swift-ci
2eca3aa27a Merge pull request #13045 from DougGregor/se-0143-check-all-conditional-requirements 2017-11-21 22:55:49 -08:00
Doug Gregor
e3a5318b97 [Type checker] Teach conformsToProtocol() to check conditional requirements.
conformsToProtocol() is the main way in which we check whether a given type
conforms to a given protocol. Extend it to check conditional requirements by
default, so that an unmodified caller will get the "does not conform" result
(with diagnostics when a location is present) rather than simply ignoring
the conditional requirements.

Some callers take responsibility for conditional requirements, e.g., to
push them into the constraint system. Allow those callers to opt out of
this checking, and do so wherever appropriate.

Fixes rdar://problem/35518088, where we were ignoring the conditional
requirements needed to verify that Equatable synthesis could be performed.
2017-11-21 21:02:00 -08:00
ematejska
a00b0749c4 Merge pull request #12849 from rudkx/SE-0054
SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
2017-11-18 18:51:39 -08:00
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Pavel Yaskevich
c92b625da3 [TypeChecker] NFC: Add test-case for rdar://problem/35625473 2017-11-17 17:53:06 -08:00
Pavel Yaskevich
cd425af45c [TypeChecker] NFC: Add test-case for rdar://problem/35625339 2017-11-17 17:52:47 -08:00
Pavel Yaskevich
a5e586b68b [TypeChecker] NFC: Add test-case for rdar://problem/35624855 2017-11-17 17:52:33 -08:00
Pavel Yaskevich
71bbbea478 [TypeChecker] NFC: Add test-case for rdar://problem/35623181 2017-11-17 17:52:15 -08:00
Pavel Yaskevich
9eb33a2a4a [TypeChecker] NFC: Add test-case for rdar://problem/33142386 2017-11-17 17:52:00 -08:00
Pavel Yaskevich
6e34121755 [TypeChecker] NFC: Add test-case for rdar://problem/27198177 2017-11-17 17:51:41 -08:00
Pavel Yaskevich
f3346370ae [TypeChecker] NFC: Add test-case for rdar://problem/27033993 2017-11-17 17:51:24 -08:00
Greg Parker
e8475cc130 Revert "Use conditional conformances to implement Equatable for Optional, Array and Dictionary" 2017-11-15 14:17:22 -08:00
Doug Gregor
9f68fdae80 [Conditional conformances] Fix up test cases that changed for the better. 2017-11-14 16:23:20 -08:00
Jordan Rose
ca1979c920 Improve diagnostics for setting a 'let' property in a delegating init 2017-11-09 18:08:01 -08:00
Jordan Rose
9888697544 Correctly check access control for a class's generic superclass (#12629)
The previous code was too clever in trying to avoid work and missed
the fact that ClassDecl::getSuperclass produces an interface type but
the types in the inheritance clause are contextual types.

This actually successfully built:

- in non-WMO builds with a public subclass and an internal base class,
  because the internal class symbol wouldn't get stripped out.

- in WMO builds with an internal subclass and a private base class,
  because 'private' has no distinction at the linkage level for a WMO
  build.

However, it's highly likely that trying to import a library containing
such types would result in instability (read: compiler and debugger
crashes), and it's clearly a mistake to allow this. (If you can't show
your superclass to a user in a library's generated interface,
something's definitely gone wrong.)

https://bugs.swift.org/browse/SR-6206
2017-11-09 13:29:24 -08:00
Mark Lacey
401d046581 More SE-0054 fixes for Swift version 5.
Fix a couple more places where we should not allow IUOs and add
additional tests for these as well as parallel tests for the long
spelling ImplicitlyUnwrappedOptional.
2017-11-06 20:02:57 -08:00
Mark Lacey
b38d967784 Ban IUOs in more places.
We were allowing them in parens in some contexts, but shouldn't have.

Also added tests for function types and tuple return types to ensure
we're not allowing them in these places.
2017-11-03 18:35:01 -07:00
Mark Lacey
cef6c9463c Fix more places where were allowing IUOs but shouldn't.
My previous commit, f9b82bccb7, failed to
ensure that IUOs could not be nested inside of other types in all
positions.
2017-10-31 18:58:55 -07:00
Mark Lacey
f9b82bccb7 Ban IUOs in illegal positions harder under Swift 5 and later.
SE-0054 specified that the use of implicitly unwrapped optionals was
limited to just a few places, but the implementation at the time did not
completely ban the other uses. This is another attempt to do so, but
it's only on for compilations in Swift 5 mode and later.

For earlier versions, we fall back on the existing implementation.

Fixes: rdar://problem/27707015
2017-10-26 22:21:36 -07:00
Mark Lacey
e07a7362cf Add a warning that ImplicitlyUnwrappedOptional is deprecated in 4+.
Per SE-0054, implicitly unwrapped optional is not a distinct type in the
type system, but rather just the notion that certain Optionals (denoted
by the sigil "!" rather than "?") can be implicitly unwrapped.

This is a first step in the direction of implementing this notion by
emitting a warning if the type is spelled out.
2017-10-26 18:09:26 -07:00
Slava Pestov
50fa92c8a7 Merge pull request #12567 from gregomni/diagnosis
[Sema] Better ambiguity diagnosis in overloaded function calls
2017-10-22 22:49:39 -07:00
gregomni
345c4a933d Save unresolved arg number from callee candidate info, use it to diagnose ambiguity sooner and
more specifically.
2017-10-22 10:32:11 -07:00
gregomni
18a113e584 We can produce better diagnostics for subscript candidates by noticing when the
subscript is on the destination side of an assignment and restricting matching
overload candidates to only the set-able members.

Also, if we are left with a single candidate, we can recheck unresolved index
expressions with better parameter info.
2017-10-21 14:02:58 -07:00
Tony Allevato
715ba632dd Merge branch 'master' into synthesize-equatable-hashable 2017-10-09 15:57:36 -07:00
Tony Allevato
a30c218b59 [test] Move executable tests into test/Interpreter 2017-10-09 15:39:40 -07:00
Graydon Hoare
3d8cc2f66a [Diagnostics] s/may/must/ in 'may not be used on subscript parameters' 2017-09-29 16:09:23 -04:00
Graydon Hoare
17aa7aa910 [Diagnostics] s/may/must/ in 'may not be declared mutating' 2017-09-29 16:09:23 -04:00
Graydon Hoare
867224dbde [Diagnostics] s/may/must/ in 'may not be declared both' 2017-09-29 16:09:23 -04:00
Graydon Hoare
bf42def404 [Diagnostics] s/may/must/ in 'may not have multiple' 2017-09-29 16:09:23 -04:00
Mark Lacey
e2999783d8 Merge pull request #12124 from rudkx/fix-diag-typo
Fix typo in diagnostic.
2017-09-26 14:10:09 -07:00
Pavel Yaskevich
3b06f2e897 Merge pull request #12072 from xedin/rdar-33429010
[ConstraintGraph] Don't try to contract edge of parameter bindings with `inout` attribute
2017-09-26 11:51:09 -07:00
Mark Lacey
1f640580f9 Fix typo in diagnostic.
Fixes rdar://problem/25963182.
2017-09-26 11:26:18 -07:00
Doug Gregor
58356f9bf5 Update test case now that we produce fewer redundant diagnostics. 2017-09-24 23:08:17 -07:00
Tony Allevato
de93a8d538 [test] Fix executable_test requirement 2017-09-24 11:33:13 -07:00
Joe Shajrawi
00f44ce24a Revert "Create fewer generic signature builders" 2017-09-22 21:57:53 -07:00
Doug Gregor
eccdedaf97 Merge pull request #12062 from DougGregor/make-fewer-gsbs
Create fewer generic signature builders
2017-09-22 18:38:27 -07:00
Pavel Yaskevich
80e4a2226b [ConstraintGraph] Don't try to contract edge of parameter bindings with inout attribute
Currently edge related to the parameter bindings is contracted
without properly checking if newly created equivalence class has
the same inout & l-value requirements. This patch improves the
situation by disallowing contraction of the edges related to parameter
binding constraint where left-hand side has `inout` attribute set.

Such guarantees that parameter can get `inout` type assigned when
argument gets `l-value` type.

Resolves: rdar://problem/33429010
2017-09-22 17:23:12 -07:00
Doug Gregor
a9873b4d15 Update test case now that we produce fewer redundant diagnostics. 2017-09-22 12:37:49 -07:00
Tony Allevato
aef3d09a1f "yet" was removed from some diagnostics by 21b2073b 2017-09-21 23:55:18 -07:00
Tony Allevato
f2c434a038 Merge branch 'master' into synthesize-equatable-hashable 2017-09-21 22:54:36 -07:00