Commit Graph

12650 Commits

Author SHA1 Message Date
Slava Pestov
1ca81c42b4 AST: Factor out GenericParamList::configureGenericParamDepth() 2018-12-11 17:48:52 -05:00
Slava Pestov
8a8b569acd Sema: Don't call prepareGenericParamList() on extension generic parameter lists
We've already set up the depth in bindExtensionToNominal(), and if
we forget we'll hit asserts later.
2018-12-11 17:48:52 -05:00
Slava Pestov
585733476b Sema: validateExtension() builds a generic signature even if the extension is invalid
Otherwise, we crash later in code that assumes the presence of a
generic parameter list implies the presence of a generic signature
(and vice versa).

Fixes <rdar://problem/46604393>.
2018-12-11 17:48:52 -05:00
Slava Pestov
1cd8613580 Sema: Do a better job with creating generic parameter lists in extension binding
No test case, but it fixes a regression with the next patch.
2018-12-11 17:48:52 -05:00
Pavel Yaskevich
ebbfa85388 Merge pull request #21203 from xedin/rdar-46459603
[ConstraintSystem] Erase `InOutExpr` from member base
2018-12-11 11:18:32 -08:00
Suyash Srijan
fa82965a7d [CSApply] Fix an issue with the @objc selector fix-it incorrectly being applied (#20949)
Special-case the diagnostic for members of non-@objc protocols that are referenced in #selector expressions.
2018-12-11 13:19:46 -05:00
Pavel Yaskevich
b429d5a28a [ConstraintSystem] Erase InOutExpr from member base
Diagnostics could introduce type-checked expressions into AST during
it's bottom up re-typechecking in attempt to find a problem.

To minimize number of AST permutations solver has to handle
let's just strip away implicit `InOutExpr` introduced by previous
successful type-checks, which is not really important anyway.

Resolves: rdar://problem/46459603
2018-12-10 23:23:22 -08:00
Slava Pestov
47b7d4389d Merge pull request #21162 from slavapestov/random-crap
A grab-bag of cleanups
2018-12-10 13:28:57 -05:00
Slava Pestov
392071e702 Sema: Peel off more code from the TypeChecker instance 2018-12-10 00:00:49 -05:00
Jordan Rose
45eac2cffb Fix a hole in access control checking for var/let
Previously if a declaration had both a Type and a TypeRepr available,
we would only check the access of the TypeRepr. However, this is
incomplete when the type is partially inferred, as in

  public var inferredGenericParameters: Optional = PrivateStruct()

The new algorithm is to the Type first, then:
- if the Type is okay, move on to check the TypeRepr
- if the Type is not okay and we're in pre-Swift-5 mode, check the
  TypeRepr, and if /that's/ okay downgrade the whole thing to a
  warning.

Unfortunately, we can't /just/ check the Type in the "good" case,
because we don't always properly preserve sugar when going from a
TypeRepr that represents a typealias to the corresponding Type, and we
want to be able to fix those cases in the future. So we have to check
both.
2018-12-08 22:38:16 -08:00
Ankit Aggarwal
92d09f4e19 Extend @available to support PackageDescription
<rdar://problem/46548531> Extend @available to support PackageDescription

This introduces a new private availability kind "_PackageDescription" to
allow availability testing by an arbitary version that can be passed
using a new command-line flag "-swiftpm-manifest-version". The semantics
are exactly same as Swift version specific availability. In longer term,
it maybe possible to remove this enhancement once there is
a language-level availability support for 3rd party libraries.

Motivation:

Swift packages are configured using a Package.swift manifest file. The
manifest file uses a library called PackageDescription, which contains
various settings that can be configured for a package. The new additions
in the PackageDescription APIs are gated behind a "tools version" that
every manifest must declare. This means, packages don't automatically
get access to the new APIs. They need to update their declared tools
version in order to use the new API. This is basically similar to the
minimum deployment target version we have for our OSes.

This gating is important for allowing packages to maintain backwards
compatibility. SwiftPM currently checks for API usages at runtime in
order to implement this gating. This works reasonably well but can lead
to a poor experience with features like code-completion and module
interface generation in IDEs and editors (that use sourcekit-lsp) as
SwiftPM has no control over these features.
2018-12-08 09:38:40 +05:30
Slava Pestov
e34d67340a Merge pull request #21134 from slavapestov/circular-conformance-check-fail
Sema: Fix failure to emit a diagnostic when a protocol witness is being validated already
2018-12-07 22:54:41 -05:00
Slava Pestov
06c2e980cb Merge pull request #21133 from slavapestov/lazy-implicit-inits
Lazy synthesis of implicit constructors in non-primary files
2018-12-07 22:45:40 -05: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
Slava Pestov
a55283d704 Sema: Lazy synthesis of implicit constructors in non-primary files 2018-12-07 20:39:27 -05:00
Slava Pestov
6c012b2aec AST: Remove some unnecessary LazyResolver * parameters from ASTContext methods 2018-12-07 20:39:27 -05:00
Slava Pestov
aa747dcd81 Remove property behaviors 2018-12-07 20:38:33 -05:00
Slava Pestov
e160b85f8f Merge pull request #21117 from slavapestov/accessor-synthesis-cleanup
Accessor synthesis cleanup (NFC)
2018-12-07 19:53:26 -05:00
Harlan Haskins
c829506aca Merge pull request #21033 from harlanhaskins/trouble-at-the-roller-rink
[Sema] Diagnose internal(set) from @inlinable functions
2018-12-07 15:33:18 -08:00
Slava Pestov
a76012dc72 Sema: Tiny cleanup for createImplicitConstructor() 2018-12-07 17:11:30 -05:00
Slava Pestov
a6f6dc01bc Sema: Fix order dependency between lazy getter body synthesis and capture computation
If we computed captures before completing a lazy getter body, we would fail to
consider the 'self' capture properly. Instead make it resilient to such ordering
issues by checking in capture computation if the lazy property has a getter yet
or not.
2018-12-07 17:10:15 -05:00
Slava Pestov
ac53f89ffb Sema: Use a more specific type for ClosuresWithUncomputedCaptures 2018-12-07 17:10:08 -05:00
Slava Pestov
809a6dc3ed Sema: Remove dead code for 'lazy' properties that's no longer used 2018-12-07 17:10:08 -05:00
Slava Pestov
7aed494bf3 Sema: Move accessor synthesis to the callback mechanism
Also change some TypeChecker usages to ASTContext.
2018-12-07 17:10:08 -05:00
Slava Pestov
6f243d4ab3 AST: Plumb a 'context' parameter through to AbstractFunctionBody's body synthesizer 2018-12-07 17:10:08 -05:00
Harlan Haskins
1abeeb8b92 [Sema] Diagnose internal(set) from @inlinable functions
This patch mainly consolidates the functions used to check accessors vs.
other decls, and makes sure we check setter access as well as regular
decl access.

rdar://45217648
2018-12-07 12:46:19 -08:00
Argyrios Kyrtzidis
d235fdc582 Merge pull request #21116 from akyrtzi/break-dependency-cycles
[AST] Break dependency cycles of swiftAST against swiftSema and swiftClangImporter
2018-12-07 12:06:07 -08:00
Slava Pestov
94b167db75 Merge pull request #21112 from slavapestov/on-demand-accessor-fix
Force SILGen emission of on-demand synthesized accessors
2018-12-07 02:04:10 -05:00
Argyrios Kyrtzidis
75ab0a5f36 [AST] Break dependency cycle between swiftAST and swiftSema
AST/LookupVisibleDecls.cpp has a dependency on swiftSema by having doGlobalExtensionLookup call into swift::isExtensionApplied,
and doGlobalExtensionLookup is ultimately used by the other global functions in that file.
Break the cycle by moving the file into the swiftSema library.
2018-12-06 22:52:38 -08:00
Slava Pestov
77215ef5b7 Sema: Force SILGen emission of on-demand synthesized accessors
When an on-demand accessor is synthesized while checking a conformance,
make sure it ends up in the 'external declarations' list so that SILGen
can emit it.

Fixes <rdar://problem/46503121>, and part of <rdar://problem/46186045>.
2018-12-06 23:58:46 -05:00
Slava Pestov
8503de4d66 Sema: Synthesize function bodies before type checking external declarations 2018-12-06 23:32:50 -05:00
Pavel Yaskevich
694c89c090 [ConstraintSystem] Handle InOut base introduced by diagnostic re-typecheck
While trying to lookup member reference on some base type, handle
base being an `InOutType`, which could be a result of previous
sub-expression re-typechecks made by diagnostics.

Resolves: rdar://problem/45771997
2018-12-06 16:02:28 -08:00
swift-ci
39161d5b36 Merge pull request #20600 from adrian-prantl/36032653 2018-12-05 17:01:58 -08:00
Pavel Yaskevich
a093691114 Merge pull request #21043 from xedin/rdar-40537782
[CSDiagnostics] Diagnose invalid optional unwrap via fixes
2018-12-05 16:06:05 -08:00
Adrian Prantl
d63debeb60 Experimental: Extend ClangImporter to import clang modules from DWARF
When debugging Objective-C or C++ code on Darwin, the debug info
collected by dsymutil in the .dSYM bundle is entirely
self-contained. It is possible to debug a program, set breakpoints and
print variables even without having the complete original source code
or a matching SDK available. With Swift, this is currently not the
case. Even though .dSYM bundles contain the binary .swiftmodule for
all Swift modules, any Clang modules that the Swift modules depend on,
still need to be imported from source to even get basic LLDB
functionality to work. If ClangImporter fails to import a Clang
module, effectively the entire Swift module depending on it gets
poisoned.

This patch is addressing this issue by introducing a ModuleLoader that
can ask queries about Clang Decls to LLDB, since LLDB knows how to
reconstruct Clang decls from DWARF and clang -gmodules producxes full
debug info for Clang modules that is embedded into the .dSYM budle.

This initial version does not contain any advanced functionality at
all, it merely produces an empty ModuleDecl. Intertestingly, even this
is a considerable improvement over the status quo. LLDB can now print
Swift-only variables in modules with failing Clang depenecies, and
becuase of fallback mechanisms that were implemented earlier, it can
even display the contents of pure Objective-C objects that are
imported into Swift. C structs obviously don't work yet.

rdar://problem/36032653
2018-12-05 13:54:13 -08:00
adrian-prantl
bf2a4712ec Merge pull request #21017 from adrian-prantl/debrief
Remove \brief commands from doxygen comments.
2018-12-05 10:40:53 -08:00
Karoy Lorentey
e0495a7e0b [Sema] Emit a deprecation warning when hashValue is provided by hash(into:) isn’t
SE-206 deprecated hashValue as a protocol requirement. We should gently encourage people to migrate to hash(into:), for its more secure, easier and faster hashing.

Emit a compiler warning whenever hashValue has an explicit implementation, but hash(into:) doesn’t.
2018-12-05 18:01:20 +00:00
Pavel Yaskevich
202234f325 [CSDiagnostics] Diagnose invalid optional unwrap via fixes
Detect and fix situations when (force) unwrap is used on
a non-optional type, this helps to diagnose invalid unwraps
precisely and provide fix-its.

Resolves: [SR-8977](https://bugs.swift.org/browse/SR-8977)
Resolves: rdar://problem/45218255
2018-12-05 08:10:07 -08:00
Doug Gregor
58e855ec50 [Type checker] Make sure we wire up generic parameters of a context.
The attempt to short-circuit wiring up generic parameters of a context
didn’t work when one of the inner types didn’t itself have generic
parameters. Make sure we still wire up generic parameters in this case.

Fixes a crasher encountered while investigating rdar://problem/43406595.
2018-12-04 21:12:45 -08:00
Doug Gregor
f469928c24 [Type checker] Drop verbose conformance-access-path debugging dumps.
Under -debug-generic-signatures, we were computing and emitting
conformance access paths for one test. Given that conformance access
paths are used ubiquitously now, this test isn't providing any value
(nor is the debug dump), stop dumpoing them.
2018-12-04 20:01:14 -08:00
Pavel Yaskevich
e043e2b2b3 [CSFix] Add a fix to remove invalid optional unwrap
If the base type is not optional, trying to unwrap it is
incorrect. Introduce a fix to make it look like base was
an optional type which leads solver to move forward
towards possible solution.
2018-12-04 18:40:04 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Pavel Yaskevich
8c126603cb Merge pull request #20993 from xedin/rdar-46377919
[CSDiag] Verify that @autoclosure param has function type before casting
2018-12-04 00:07:13 -08:00
Pavel Yaskevich
138105bd98 [CSDiag] Verify that @autoclosure param has function type before casting
When parameter refers to something undefined its type is going to
be `ErrorType`, so diagnostic path needs to make sure that parameter
has a valid function type before trying to extract result from it.

Resolves: rdar://problem/46377919
2018-12-03 18:20:41 -08:00
Slava Pestov
f871b0e661 Merge pull request #20948 from Azoy/remove-_getBool
[SILGen][stdlib] Remove _getBool
2018-12-03 21:00:31 -05:00
Rintaro Ishizaki
ba0e5756e3 Merge pull request #20904 from rintaro/ast-lookupvisibledecls-forward
[AST] Don't suggest unusable values for typo correction and code completion
2018-12-04 09:26:23 +09:00
Azoy
65217a71de Cache bool builtin init
remove newline
2018-12-02 22:38:24 -06:00
Slava Pestov
fc8f122336 AST: Remove FuncDecl::getReturnTypeLoc() 2018-12-02 18:41:39 -05:00
Azoy
28fc1ca296 tc.Context is shorter 2018-12-01 18:57:02 -06:00
Azoy
a2dafc3d26 Remove _getBool 2018-12-01 18:51:25 -06:00