Commit Graph

12650 Commits

Author SHA1 Message Date
Pavel Yaskevich
0d164383a6 Merge pull request #23217 from theblixguy/fix/SR-6400
[Typechecker] Warn when casting from an existential type to a concrete type
2019-03-26 19:57:21 -07:00
Slava Pestov
8ecb83e29a Sema: Diagnose unsupported '@objc' on classes and members of extensions of classes with resilient ancestry
Unless -enable-resilient-objc-class-stubs is passed in, these cases
are not supported, so now we diagnose them instead of asserting or
failing to link.

Note the behavior change here; classes with resilient ancestry were
previously isObjC(). However this is wrong since isObjC() means
"statically visible to Objective-C via the generated header".

After this patch, isObjC() only returns true for a class with resilient
ancestry if -enable-resilient-objc-class-stubs is passed in.
2019-03-26 18:58:12 -04:00
Slava Pestov
1864f6f679 AST: Introduce ClassDecl::isSuperclassOf() 2019-03-26 18:42:59 -04:00
Slava Pestov
cece98b2ed AST: Generalize ClassDecl::checkObjCAncestry() to ClassDecl::checkAncestry()
This replaces ClassDecl::hasObjCMembers() and some hand-coded walks.
2019-03-26 18:42:59 -04:00
Slava Pestov
a2049972ca AST: Add ModuleDecl::isResilient()
This cleans up some code. I'm keeping the ResilienceStrategy enum around
though, in case we want to use it to version the ABI in the future.
2019-03-26 18:42:59 -04:00
Pavel Yaskevich
8420a00ed8 Merge pull request #23563 from xedin/rdar-49159472
[CSSimplify] Teach disjunction filtering that some enum cases have curried self
2019-03-26 01:24:07 -07:00
Pavel Yaskevich
fe7ea486a1 [CSSimplify] Teach disjunction filtering that some enum cases have curried self
Cases with arguments form `(Self.Type) -> (Arg...) -> Self`
function types, so `areConservativelyCompatibleArgumentLabels`
should remove curried self before trying to match argument/parameter
labels.

Resolves: rdar://problem/49159472
2019-03-25 19:37:05 -07:00
Ted Kremenek
fe215edb9b Merge pull request #19743 from Azoy/smarter-struct-init
[Sema] Synthesize default values for memberwise init
2019-03-25 17:31:01 -07:00
Rintaro Ishizaki
232e4a459c Merge pull request #23332 from rintaro/ide-completion-conformance-rdar36594731
[AST] Don't return decls from unsatisfied conformance
2019-03-25 16:30:22 -07:00
swift-ci
35f5c7afb3 Merge pull request #23538 from davezarzycki/diag_qoi_SelfAccessKind 2019-03-25 14:23:42 -07:00
Joe Groff
797839f197 Merge pull request #23497 from theblixguy/fix/SR-10146
[CSApply] Fix a KeyPath crash in SIL when base type is AnyObject
2019-03-25 14:13:41 -07:00
David Zarzycki
f99124569b [Diag] Formalize SelfAccessKind printing 2019-03-25 15:40:26 -04:00
Michael Gottesman
86888ceec7 Merge pull request #23499 from gottesmm/pr-7c99cd81f730147d0e6b637f864da32d1511a450
[parse/sema] Give all case bodies their own var decls without using t…
2019-03-25 12:14:54 -07:00
Pavel Yaskevich
1ee66cd653 Merge pull request #23500 from theblixguy/fix/SR-9267
[CSDiag] Improving the fix-it for defining computed variables
2019-03-25 11:02:45 -07:00
Michael Gottesman
b50d878f5d [parse/sema] Give all case bodies their own var decls without using those var decls for anything.
This is a step in the direction of fixing the fallthrough bug. Specifically, in
this commit I give case stmts a set of var decls for the bodies of the case
statement. I have not wired them up to anything except the var decl
list/typechecking.

rdar://47467128
2019-03-25 10:30:57 -07:00
Suyash Srijan
56b0c55dfb [cs] make tryComputedPropertyFixIts() a private instance method 2019-03-25 01:33:41 +00:00
Suyash Srijan
5a8e1fa955 [cs] extract computed property fix-it into separate method 2019-03-25 00:07:41 +00:00
John Holdsworth
f89f28c361 Intermediate variable 2019-03-24 12:59:48 +00:00
John Holdsworth
40016d5284 Don't exclude Self on properties of Value types. 2019-03-23 12:41:51 +00:00
Suyash Srijan
9750762b75 [csdiag] missing function call failure here as a backup 2019-03-23 02:11:13 +00:00
Suyash Srijan
1b62039c76 [cssimplify] add a fix for contextual type conversion for function type 2019-03-22 23:40:43 +00:00
Suyash Srijan
cad60ba08b [csdiag] offer a fix-it to turn a stored property into a computed property if needed 2019-03-22 21:21:17 +00:00
Suyash Srijan
676d914e7c [csapply] do not proceed with a key path whose base type is AnyObject 2019-03-22 20:42:58 +00:00
John Holdsworth
cd1656cfd8 Exclude properties with type Self 2019-03-22 13:21:46 +00:00
Michael Gottesman
0680ce1bab Merge pull request #23448 from nathawes/fix-case-var-for-relatedidents-cursorinfo-and-rename
[sourcekitd] Improve CursorInfo, RelatedIdents, and local rename to better handle VarDecls involved in case fallthroughs
2019-03-21 15:52:59 -07:00
Slava Pestov
428c709491 AST: Remove argument list-specific parts of TupleShuffleExpr
Before extending TupleShuffleExpr to represent all tuple
conversions allowed by the constraint solver, remove the
parts of TupleShuffleExpr that are no longer needed; this is
support for default arguments, varargs, and scalar-to-tuple and
tuple-to-scalar conversions.
2019-03-21 02:18:41 -04:00
Slava Pestov
d470e9df4d AST: Split off ArgumentShuffleExpr from TupleShuffleExpr
Right now we use TupleShuffleExpr for two completely different things:

- Tuple conversions, where elements can be re-ordered and labels can be
  introduced/eliminated
- Complex argument lists, involving default arguments or varargs

The first case does not allow default arguments or varargs, and the
second case does not allow re-ordering or introduction/elimination
of labels. Furthermore, the first case has a representation limitation
that prevents us from expressing tuple conversions that change the
type of tuple elements.

For all these reasons, it is better if we use two separate Expr kinds
for these purposes. For now, just make an identical copy of
TupleShuffleExpr and call it ArgumentShuffleExpr. In CSApply, use
ArgumentShuffleExpr when forming the arguments to a call, and keep
using TupleShuffleExpr for tuple conversions. Each usage of
TupleShuffleExpr has been audited to see if it should instead look at
ArgumentShuffleExpr.

In sequent commits I plan on redesigning TupleShuffleExpr to correctly
represent all tuple conversions without any unnecessary baggage.

Longer term, we actually want to change the representation of CallExpr
to directly store an argument list; then instead of a single child
expression that must be a ParenExpr, TupleExpr or ArgumentShuffleExpr,
all CallExprs will have a uniform representation and ArgumentShuffleExpr
will go away altogether. This should reduce memory usage and radically
simplify parts of SILGen.
2019-03-21 02:18:41 -04:00
Azoy
dcedba73f0 fix lazy vars
clean up lazy vars

more docs
2019-03-20 23:01:38 -05:00
Pavel Yaskevich
8fcd4e6ee3 Merge pull request #23311 from theblixguy/fix/throw-in-defer
[Diag] [Typechecker] Diagnose throw in defer properly
2019-03-20 20:44:38 -07:00
Suyash Srijan
e446ae726b [typechecker] if we're casting to a nominal type that's a protocol, then skip the check 2019-03-21 00:57:04 +00:00
Nathan Hawes
9291201e32 [sourcekitd][Refactoring] Fix renaming of var decls in fallthrough case statements
We weren't renaming all occurrences of 'x' in the cases like the below:

  case .first(let x), .second(let x):
    print("foo \(x)")
    fallthrough
  case .third(let x):
    print("bar \(x)")

We would previously only rename occurrences within the case statement the query
was made in (ignoring fallthroughs) and for cases with multiple patterns (as in
the first case above) we would only rename the occurrence in the first pattern.
2019-03-20 14:38:08 -07:00
Arnold Schwaighofer
168c4f948c Merge pull request #23426 from aschwaighofer/sema_cdecl_not_dynamic
Sema: Don't implicitly mark functions with a cdecl as dynamic
2019-03-20 12:23:02 -07:00
Suyash Srijan
524790eb07 [typechecker] remove call to getAllConformances() and add some new test cases 2019-03-20 19:03:19 +00:00
Suyash Srijan
952111b582 Merge branch 'master' into fix/SR-6400 2019-03-20 18:16:34 +00:00
Ben Langmuir
f5a216fc04 Merge pull request #23411 from benlangmuir/cc-1-close
[code-completion] Add type context for single-expression closures
2019-03-20 06:56:49 -07:00
Suyash Srijan
8f79bb8912 Merge branch 'master' into fix/throw-in-defer 2019-03-20 11:25:35 +00:00
Suyash Srijan
814d0abbf2 [typechecker] diagnose throw in defer the same way as other control flows 2019-03-19 19:54:33 +00:00
Arnold Schwaighofer
6b807d9cc4 Sema: Don't implicitly mark functions with a cdecl as dynamic
This does not work without more work.
2019-03-19 12:43:53 -07:00
Arnold Schwaighofer
d4088e9722 Merge pull request #23420 from aschwaighofer/defer_body_not_dynamic
Sema: Don't add dynamic to defer bodies
2019-03-19 11:35:19 -07:00
Rintaro Ishizaki
1d4e66616c Merge pull request #23408 from rintaro/ide-completion-availableoverload-rdar47408946
[AST] Prefer available member in lookupVisibleDecls()
2019-03-19 10:44:32 -07:00
Ben Langmuir
2b5a8a5be7 Fix assertion failure in validation test
Seen in validation-test/IDE/crashers_fixed/019-swift-vardecl-emitlettovarnoteifsimple.swift
2019-03-19 09:35:25 -07:00
Arnold Schwaighofer
da3155249b Sema: Don't add dynamic to defer bodies 2019-03-19 08:53:52 -07:00
Jordan Rose
ce0178fc13 Merge pull request #23357 from theblixguy/fix/SR-10108
[Sema] Fix a crash when attempting to synthesise raw representable conformance
2019-03-19 07:30:48 -07:00
Pavel Yaskevich
96085141be Merge pull request #23399 from xedin/rdar-45535925
[ConstraintSystem] Introduce a fix for inaccessible members
2019-03-19 00:08:47 -07:00
Jordan Rose
09847e6066 Merge pull request #23346 from theblixguy/fix/SR-10115
[Typechecker] Dont infer @objc for typealiases inside @objc protocol
2019-03-18 17:37:12 -07:00
swift-ci
611534cc77 Merge pull request #23378 from gottesmm/pr-5d07f093c8b0891046d822d507c526e7ec6cfc1d 2019-03-18 16:23:24 -07:00
Rintaro Ishizaki
c01799cbcf [AST] Prefer available member in lookupVisibleDecls()
'init?()' and 'init()' are considerd conflicting. But user can declare
both if only one of them is available.

rdar://problem/47408946
2019-03-18 16:08:21 -07:00
Michael Gottesman
b1a7b488fd [sema] Wire up VarDecl parent pointers for case stmt related Var Decls
This is in preparation for fixing issues around SILGenPattern fallthrough
emission and bad rename/edit all in scope of case stmt var decls. Specifically,
I am going to ensure that we can get from any VarDecl in the following to any
other VarDecl:

switch x {
case .a(let v1, let v2), .b(let v1, let v2):
  ...
  fallthrough
case .c(let v1, let v2), .d(let v1, let v2):
  ...
}

This will be done by:

1. Pointing the var decls in .d at the corresponding var decls in .c.
2. Pointing the var decls in .c at the corresponding var decls in .b.
3. Pointing the var decls in .b at the corresponding var decls in .a.
4. Pointing the var decls in .a at the case stmt. Recognizing that we are asking
for the next VarDecl, but have a case stmt, we check if we have a fallthrough
case stmt. If so, follow down the fallthrough case stmts until you find a
fallthrough case stmt that doesn't fallthrough itself and then return the
corresponding var decl in the last case label item in that var decl (in the
above .d).

In a subsequent commit I am going to add case body var decls. The only change as
a result of that is that I will insert them into the VarDecl double linked list
after the last case var decl of each case stmt.
2019-03-18 14:13:10 -07:00
Pavel Yaskevich
688042becf [Diagnostics] Add inaccessible member diagnostic 2019-03-18 13:48:08 -07:00
Pavel Yaskevich
196f732cc8 [CSFix] Introduce a fix for inaccessible members
If there are no other choices, let's attempt to
use any available inaccessible candidates.
2019-03-18 13:44:30 -07:00