Commit Graph

975 Commits

Author SHA1 Message Date
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00
Jordan Rose
3b4bb1960d @_implementationOnly: fix over-eager checking for vars in extensions (#24629)
The logic I had here checked whether an extension used an
implementation-only type whenever there was a declaration within that
extension that needed checking...but unfortunately that included not
just PatternBindingDecls (whose access is filtered at a later step)
but things like IfConfigDecls (#if). Change this to only check
signatures of extensions with ABI-public members, something that is
tested once when visiting an ExtensionDecl.

Additionally, skip AccessorDecls entirely, since they'll be tested
as part of the corresponding subscript or var. This saves a duplicate
diagnostic.

rdar://problem/50541589
2019-05-16 13:13:48 -07:00
Brent Royal-Gordon
3494c0bd88 [TypeChecker] Rephrase platforms in availability diagnostics
This does several different things to improve how platforms are described in availability diagnostics:

• Mentions the platform in diagnostics for platform-specific @available(unavailable) attributes.
• Replaces “OS X” with “macOS”.
• Replaces “fooOS application extension” with “application extensions for fooOS”.
• Replaces “on fooOS” with “in fooOS”.

Fixes <rdar://problem/49963341>.
2019-04-30 16:32:43 -07:00
Sam Lazarus
3d9b6396a1 Merge pull request #24059 from sl/sl/sr-10293
Allow var / let as parameter names but provide a warning and fixit to add backticks.
2019-04-26 09:30:23 -04:00
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Nate Chandler
c21678d34a Corrected tests by removing implicit returns. 2019-04-24 10:04:20 -07:00
Suyash Srijan
a58db50b4f [Diagnostics] Update diagnostics for T! to Any (#23617)
Add a tailored diagnostic for the case where implicitly unwrapped optional is coerced to `Any`
2019-04-18 15:23:52 -07:00
Slava Pestov
a3c15f2f6b Sema: References to TypeDecls should always be TypeExpr
In a few corner cases we built DeclRefExpr and MemberRefExpr
for references to types. These should just be TypeExpr so that
SILGen doesn't have to deal with it.

This also fixes a bug where a protocol typealias with an
unbound generic type could not be accessed properly from
expression context, but that is just so incredibly obscure.
2019-04-14 23:28:13 -04:00
Jordan Rose
326fa14f8b Don't bother checking implementation-only import use for accessors
Their associated AbstractStorageDecl is already being checked, and
will produce a better error.
2019-04-11 16:33:23 -07:00
Jordan Rose
a4606111af Adjust the implementation-only diagnostics to sound more similar
John and I had slightly different styles when adding these; better
to keep them in harmony.
2019-04-11 16:33:23 -07:00
Jordan Rose
bcde0f8292 [test] Add additional implementation-only conformance test cases
...suggested by Brent and Slava. Thanks, both!
2019-04-11 11:07:52 -07:00
Jordan Rose
59974a5e91 Remove accidentally duplicated tests
These are already checked in implementation-only-import-in-decls.swift.
2019-04-11 11:07:52 -07:00
Jordan Rose
7006aa0b9f Check for use of implementation-only conformances in inlinable code
This includes both the types and the values (generic functions, etc)
used in the inlinable code. We get some effectively duplicate
diagnostics at this point because of this, but we can deal with that
at a future date.

Last part of rdar://problem/48991061
2019-04-10 11:09:07 -07:00
Jordan Rose
5c27568738 Check assoc types for conformances from implementation-only imports
Okay, strictly we're checking the "signature conformances" of a newly-
declared conformance, but that wouldn't have fit on one line. This is
making sure that we don't have a requirement on an associated type (or
on the conforming type) that can only be satisfied using a conformance
in an implementation-only import.
2019-04-10 11:09:07 -07:00
Jordan Rose
519fa00adc Check signatures for conformances from implementation-only imports
These also create a dependency on the implementation module, even if
both the type and the protocol are public. As John puts it, a
conformance is basically a declaration that we name as part of another
declaration.

More rdar://problem/48991061
2019-04-10 11:09:07 -07:00
Slava Pestov
e214156abf Sema: Remove escaping capture diagnostics
I'm about to replace all of this with a SIL pass.
2019-04-09 15:02:14 -04:00
Jordan Rose
4972351b3c Fix implementation-only checking for members of frozen structs/classes
...which I had exactly backwards.
2019-04-05 20:10:10 -07:00
Jordan Rose
a9b0a6661a Implementation-only import checking for types used in decls
Based on the existing access checker for types used in decls. There's
a common skeleton here but we can't seem to get it out, so for now
add a third DeclVisitor to this file. On the plus side, checking this
alongside access is an easy way to make sure everything gets checked.

Part of rdar://problem/48991061
2019-04-05 20:10:10 -07:00
John McCall
ae6561c32c Checks for implementation-only imports in @inlinable code.
Part of rdar://48991061
2019-04-05 16:30:25 -04:00
Jordan Rose
d36a7393b0 Fix issue with expression patterns in switch exhaustivity checking (#23804)
Expression patterns (and cast patterns) don't actually contribute to
the exhaustivity of a switch statement---if you're matching against a
String, matching "abc" doesn't meaningfully reduce the full space of
the values you have to match. This was already handled, but didn't do
the right thing in a particular case involving a tuple payload in an
enum after the Space Engine (exhaustivity checker) optimizations that
went out in Swift 5.

https://bugs.swift.org/browse/SR-10301
2019-04-05 09:14:54 -07:00
Slava Pestov
016cb690ae Merge pull request #23730 from slavapestov/assorted-bug-fixes
Assorted bug fixes
2019-04-02 17:38:29 -04: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
Jordan Rose
883fc5b24a Check access control for the generic requirements of typealiases.
Also oops. This one was a little more involved because the requirements
on a generic typealias don't always carry a Type anymore; sometimes all
you have is the TypeRepr. That should still be okay in practice as long
as we don't start doing that for var/let, which can have part of a type
be inferred but not all of it.
2019-04-01 18:34:18 -07:00
Jordan Rose
b4e476e61f Check access control for the generic requirements of subscripts
Oops.
2019-04-01 18:28:33 -07:00
Slava Pestov
e2c9c52c93 AST/Sema/SILGen: Implement tuple conversions
TupleShuffleExpr could not express the full range of tuple conversions that
were accepted by the constraint solver; in particular, while it could re-order
elements or introduce and eliminate labels, it could not convert the tuple
element types to their supertypes.

This was the source of the annoying "cannot express tuple conversion"
diagnostic.

Replace TupleShuffleExpr with DestructureTupleExpr, which evaluates a
source expression of tuple type and binds its elements to OpaqueValueExprs.

The DestructureTupleExpr's result expression can then produce an arbitrary
value written in terms of these OpaqueValueExprs, as long as each
OpaqueValueExpr is used exactly once.

This is sufficient to express conversions such as (Int, Float) => (Int?, Any),
as well as the various cases that were already supported, such as
(x: Int, y: Float) => (y: Float, x: Int).

https://bugs.swift.org/browse/SR-2672, rdar://problem/12340004
2019-03-27 18:12:05 -04:00
David Zarzycki
f99124569b [Diag] Formalize SelfAccessKind printing 2019-03-25 15:40:26 -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
Slava Pestov
9626340d4b Sema: Remove unused -fix-string-to-substring-conversion flag 2019-03-14 22:08:43 -04:00
Arnold Schwaighofer
8f0fbd2c75 Allow dynamic replacement initializers to be non delegating
rdar://48125765
2019-02-18 10:26:59 -08:00
Ding Ye
0f493a68b3 [Sema] Improve diagnostics for access level of protocol witness in extension. (#22235)
If the access level of a protocol witness does not satisfies a requirement,
the compiler suggests marking it as the required level.  This is not suitable
when the witness is in an extension whose specified access level is less than
the required level, since the fixit fights with other warnings in this case.
This patch identifies such case and produces improved diagnostics.

Resolves: SR-9793
2019-02-08 09:31:01 -08:00
Jordan Rose
aabcabfdf3 Merge pull request #21983 from KingOfBrian/bugfix/SR-964-As-Member-master
[Sema] Report unused newValue when getter is accessed in custom setter
2019-02-04 14:46:33 -08:00
Pavel Yaskevich
52024681e0 [CSDiagnostics] NFC: Fallback diagnostic shouldn't ask for the project 2019-01-30 16:04:44 -08:00
Jordan Rose
3c740e4f2e Don't fix access of an 'open' decl in a 'public' extension
This is reasonable to diagnose with a warning, but dropping the 'open'
down to 'public' isn't the right fix, because now it's not a valid
override. The declaration has to get moved to another extension instead,
or the extension has to not set a default access level.

This turned out to be a source compat issue because the same logic
that emits the fix-it also updates the access of the member, which
then resulted in "must be as accessible as the declaration it
overrides" in the /same/ build. It's not immediately clear what caused
this; probably something's just being validated in a different order
than it was before. The change makes sense either way.

Stepping back, it's weird that a warning would change how the compiler
saw the code, and while we could check for 'override' explicitly, we
can't know if the member might be satisfying a protocol requirement.
Better to just not guess at the right answer here.

rdar://problem/47557376&28493971
2019-01-28 18:25:06 -08:00
Jordan Rose
1f06cd7e6d Tweak diagnostic for a high-access member in a low-access extension
Before: declaring a public instance method in a private extension
After: 'public' modifier conflicts with extension's default access of
       'private'
2019-01-28 18:24:12 -08:00
Suyash Srijan
8928431cbe [sema] support weak/unowned variables when checking for conformance 2019-01-26 02:57:45 +00:00
Brian King
613b629941 Add the unused setter argument warning to the self assign unit test 2019-01-18 09:49:23 -05:00
Pavel Yaskevich
65abb49aa7 Merge pull request #21517 from xedin/rdar-38885760
[TypeChecker] Always emit a fallback error if type-check failed witho…
2019-01-08 10:01:34 -08:00
Jordan Rose
4a8f81db2b Special-case diagnostic for when you just need @unknown default (#21695)
This is a new feature of Swift 5 mode, so it deserves at least a
little bit of explanation right in the diagnostic. If you have an
otherwise-fully-covered switch but can't assume the enum is frozen,
you'll now get this message:

    switch covers known cases, but 'MusicGenre' may have additional
    unknown values

Furthermore, if the enum comes from a system header, it looks like
this:

    switch covers known cases, but 'NSMusicGenre' may have additional
    unknown values, possibly added in future versions

...to further suggest the idea that even though your switch is covered
/now/, it might not handle everything in the /future/. This extra bit
is limited to system headers to avoid showing up on C enums defined in
your own project, for which it sounds silly. (The main message is
still valid though, since you can cram whatever you want into a C
enum, and people use this pattern to implement "private cases".)

rdar://problem/39367045
2019-01-08 08:45:23 -08:00
Slava Pestov
3c0206d72e LookupVisibleDecls: Remove RestateFilteringConsumer
It's no longer needed after the previous set of changes, and removing it
fixes a crash.

Fixes <rdar://problem/46853611>.
2019-01-08 00:14:52 -05:00
Pavel Yaskevich
64fa0ee729 [TypeChecker] Add Builtin operation to trigger/test fallback diagnostic 2019-01-07 10:42:00 -08:00
Karoy Lorentey
624135641d Merge pull request #21057 from lorentey/actually-deprecate-hashValue
[Sema] Emit a deprecation warning if a Hashable type only implements hashValue
2018-12-19 22:47:16 +00:00
Harlan Haskins
bf0bb31c53 Merge pull request #21393 from harlanhaskins/oops-indeed
[TBDGen] Allow #warning/#error in protocols
2018-12-18 10:20:44 -08:00
Harlan Haskins
c9980f1b20 [test] Add some more tests for #warning
It should support multi-line strings and strings with custom delimiters, as long as they’re not interpolating.
2018-12-17 18:05:17 -08:00
Harlan Haskins
7bd2061bbd [TBDGen] Allow #warning/#error in protocols
Resolves [SR-9519](https://bugs.swift.org/browse/SR-9519)
2018-12-17 18:05:17 -08:00
Doug Gregor
e21a96f4ab [SIMD] Update tests to reflect the SIMD operators in the standard library
Introducing the SIMD operators back into the standard library regresses
one test (SR-139 goes exponential against without the designated types
for operatores feature). Split that part of the test out.
2018-12-17 11:43:45 -08:00
Robert Widmann
3102ed0a7a Remove regression tests for the dead size heuristic 2018-12-15 23:38:35 -05:00
Robert Widmann
6115ed9f7c Test for SR-6652, SR-6316 2018-12-15 23:21:18 -05:00
Robert Widmann
04c88aa822 Drop the coverage size heuristic
In light of the invocation limits placed on space subtraction, this grossly incorrect check is being dropped.

Resolves a source of miscompiles in mostly machine-generated code
including SR-6652 and SR-6316.
2018-12-15 23:19:04 -05:00