Commit Graph

58361 Commits

Author SHA1 Message Date
Marc Rasi
5772ddda7e fix autocomplete crash 2020-03-20 14:43:46 -07:00
Robert Widmann
0c3efe7975 Merge pull request #30524 from CodaFi/neo-compl-cache
[NFC] Requestify Code Completion's Second Pass
2020-03-20 14:26:57 -07:00
Andrew Trick
1a2e8611a8 Merge pull request #30491 from atrick/add-array-semantic-api
Add getArraySemanticsKind API.
2020-03-20 13:26:50 -07:00
Rintaro Ishizaki
021cbbb668 Merge pull request #30530 from AnthonyLatsis/member-lookup-protocols
[CodeCompletion] Optimize member lookup in protocols being conformed to
2020-03-20 13:17:24 -07:00
Roopesh Chander
b63e73e1eb [Property wrappers] Rename hasPropertyWrapper() for clarity
GetterSetterComponent::hasPropertyWrapper() now checks for more
stuff than just whether there's a property wrapper or not.

It's therefore renamed to canRewriteSetAsPropertyWrapperInit().
2020-03-20 12:21:50 -07:00
Roopesh Chander
8ee83fdf28 [Property wrappers] Avoid assign_by_wrapper when autoclosure is involved
When assigning to a wrapped variable in 'init()', if the property wrapper's
'wrappedValue:' parameter is an escaping autoclosure, the initializer and
setter have incompatible types -- the setter takes a value, and initializer
takes a closure returning that value.

An assign_by_wrapper with incompatible types causes SIL verification to fail.

This commit makes the SIL not use assign_by_wrapper in such cases, and use the
setter directly, resulting in a definitive initialization (DI) error instead.

    struct S {
      @Lazy var n: Int // Lazy.init(wrappedValue: @autoclosure ... )
      init() {
        n = 1 // error: 'self' used before all stored properties are initialized
      }
    }
2020-03-20 12:20:53 -07:00
Roopesh Chander
9c2dca7d6a [Property wrappers] Fix handling of @autoclosure in init(wrappedValue:)
If the 'wrappedValue:' parameter is an escaping autoclosure, and a
struct property is marked with that property wrapper, the memberwise
initializer of the struct is now synthesized with an escaping
autoclosure for that property.
2020-03-20 12:20:52 -07:00
Robert Widmann
a078a4b41e [NFC] Remove duplicated stats tracer 2020-03-20 12:15:01 -07:00
Robert Widmann
59106636bf [Gardening] Remove unused ASTContext variable 2020-03-20 12:14:48 -07:00
Rintaro Ishizaki
80848682cc [LookupVisibleDecls] Tweak unquialified lookup
- Show static var decls in non-qualified metatype lookup
- Show enum element decls in non-qualified metatype lookup
- Never show initializers in non-qualified lookup
- Perform instance lookups in lazy var initializer
- Perform non-qualified metatype lookup inside static func

rdar://problem/57622639
2020-03-20 10:44:24 -07:00
Anthony Latsis
be4ad49b56 Address suggestions 2020-03-20 20:31:44 +03:00
Pavel Yaskevich
d673ed0989 Merge pull request #30519 from xedin/rdar-52204414
[ConstraintSystem] Don't allow explicit closure result to be implicitly converted to `Void`
2020-03-20 09:36:17 -07:00
Anthony Latsis
137ef220f6 [CodeCompletion] Optimize member lookup in protocols being conformed to 2020-03-20 18:12:07 +03:00
Arnold Schwaighofer
26af2d7569 Merge pull request #30516 from aschwaighofer/silgen_fix_assign_by_wrapper_objc_dynamic
SILGen: Fix assign_by_wrapper of ``@objc dynamic`` properties
2020-03-20 06:51:39 -07:00
eeckstein
70971b58e4 Merge pull request #30508 from eeckstein/combine-enum
SILCombine: optimize creating enums with tuple payloads.
2020-03-20 09:10:57 +01:00
Robert Widmann
7abbe701ff Merge pull request #30522 from CodaFi/skeleton-key
[NFC] Don't Mutate Flags; Just Read ASTContext::isAccessControlDisabled
2020-03-20 01:09:42 -07:00
Pavel Yaskevich
4876996b8c Merge pull request #30510 from HassanElDesouky/SR-12309-FollowUp
[CSGen] Diagnose `nil` with any number of parentheses
2020-03-20 00:13:50 -07:00
Robert Widmann
ee9bf600b3 [NFC] Requestify Code Completion's Second Pass
Code Completion operates on a CompilerInstance that passes a primary
file down for type checking. This means it creates and registers
dependencies in the referenced name trackers. Despite the fact that
those dependencty edges are unused,
because the would-be swiftdeps file is never written to disk,
it is still a dependency source that should participate in the
request-based dependency tracking refactor.
2020-03-19 23:25:38 -07:00
Robert Widmann
55241243f7 Defensively copy obligation keys 2020-03-19 19:23:12 -07:00
Nathan Hawes
b3f296d590 [SourceKit/InterfaceGen] Also print the cross-import overlays of a module in its interface.
When printing the generated interface of a module, also print the decls from
any underscored cross-import overlays it is the direct, or indirect underlying
module of. Declarations are grouped by overlay, with a descriptive `MARK:`
comment introducing each overlay, and a regular comment above each decl listing
the required bystander modules that must be imported for the decl to be
available.

In addition in each overlay:
- import declarations of any underlying modules are filtered out, since they
  are either other underscored cross-import overlays, or the target module they
  are being presented as being part of.
- import declarations that are also in the target module are filtered out, since
  the overlay is being presented as a conditional part of the target module.

Resolves rdar://problem/59445385
2020-03-19 18:15:42 -07:00
Robert Widmann
31cfab854a [NFC] Don't Mutate Flags; Just Read ASTContext::isAccessControlDisabled
Make configureLookup a little easier to reason about by pushing the read
of this flag down into lookup instead of mutating the lookup flags
beforehand.
2020-03-19 18:05:10 -07:00
Arnold Schwaighofer
4dec4abcd0 Merge pull request #30472 from aschwaighofer/irgen_typelayout_use_heuristic
IRGen: Only use type layouts when we expect the generated IR to be faster
2020-03-19 17:44:04 -07:00
Xi Ge
f92d2ca9d6 Merge pull request #30517 from nkcsgexi/58544718
ModuleInterface: print function-builder custom attribute only on parameters
2020-03-19 17:30:28 -07:00
Robert Widmann
ea3ef98139 Merge pull request #30302 from CodaFi/all-the-fixins
Teach the Dependency Verifier to Emit Fixits
2020-03-19 17:14:26 -07:00
Pavel Yaskevich
89933c67da [ConstraintSystem] Don't allow explicit closure result to be implicitly converted to Void
It's allowed to convert a single statement closure from `(...) -> T` to `(...) -> Void`
_only_ if there is no explicit `return` in the body.

Resolves: [SR-12277](https://bugs.swift.org/browse/SR-12277)
Resolves: rdar://problem/52204414
2020-03-19 16:59:17 -07:00
Doug Gregor
ddc22a3dc3 Merge pull request #30511 from DougGregor/driver-batch-mode-disable-pch-validation
[Driver] Disable PCH validation in batch mode, too.
2020-03-19 15:48:02 -07:00
Xi Ge
b00698d977 ModuleInterface: print function-builder custom attribute only on parameters
Printing this attribute on other definitions isn't necessary.

rdar://58544718
2020-03-19 15:41:08 -07:00
Arnold Schwaighofer
57c6c59ad6 SILGen: Fix assign_by_wrapper of `@objc dynamic` properties
Insert a thunk. Objc method calls might need bridging.

rdar://60038084
2020-03-19 15:09:19 -07:00
Rintaro Ishizaki
4bd753c141 Merge pull request #30506 from rintaro/ide-completion-rdar51504896
[CodeCompletion] Don't ignore CovariantReturnConversionExpr
2020-03-19 14:57:25 -07:00
Robert Widmann
6abf057dc7 Teach the verifier to emit fixits
Emit nicely formatted fixits that contain the expectations the user should have written.
2020-03-19 14:16:53 -07:00
Xi Ge
b717fafedb Merge pull request #30509 from nkcsgexi/58562780
ModuleInterface: skip override keywords when overriding an invisible decl from super class
2020-03-19 14:11:10 -07:00
Pavel Yaskevich
0ebdba06b5 [ConstraintSystem] Add a new locator element - type for body of a closure 2020-03-19 13:48:07 -07:00
Robert Widmann
21cfcfef2c Merge pull request #30505 from CodaFi/ligated-legacy
[NFC] Remove the Legacy Semantic Queries Bit
2020-03-19 13:45:27 -07:00
Hassan El Desouky
5ff6fe20a9 Remove incorrect comment 2020-03-19 22:31:01 +02:00
Doug Gregor
06196e09c0 Merge pull request #30496 from DougGregor/contextual-pattern-binding-decl
[Constraint system] Use the PatternBindingDecl context when possible.
2020-03-19 13:21:50 -07:00
Doug Gregor
a04260b82a [Driver] Disable PCH validation in batch mode, too.
When building in batch mode with a precompiled bridging header, tell
the frontends to disable PCH validation. We have always done this for
incremental, non-batch builds, but forgot to update this check when we
added batch mode.

Fixes SR-11986 / rdar://problem/58455465
2020-03-19 12:54:27 -07:00
Hassan El Desouky
a72ea640e6 Handle nil with any number of parentheses 2020-03-19 21:41:22 +02:00
Joe Groff
faec5866a4 Merge pull request #30489 from jckarter/swift-52-opaque-type-mangling
IRGen: Use mangled names to access opaque type associated types in Swift >=5.2.
2020-03-19 12:01:49 -07:00
Joe Groff
b4abd44e03 Merge pull request #30479 from jckarter/disable-mangled-name-metadata
IRGen: Add a flag to disable mangled name type metadata accessors.
2020-03-19 12:01:38 -07:00
Slava Pestov
fcf3118417 Merge pull request #30499 from slavapestov/remove-curried-declrefs
SIL: Remove curried SILDeclRefs
2020-03-19 14:59:47 -04:00
Xi Ge
75abee8f45 ModuleInterface: skip override keywords when overriding an invisible decl from super class
When we are printing Swift interface, we have to skip the override keyword
if the overriden decl is invisible from the interface. Otherwise, an error
will occur while building the Swift module because the overriding decl
doesn't override anything.

We couldn't skip every `override` keywords because they change the
ABI if the overriden decl is also publicly visible.

For public-override-internal case, having `override` doesn't have ABI
implication. Thus we can skip them.

rdar://58562780
2020-03-19 11:47:54 -07:00
Erik Eckstein
95cacf84b7 SILCombine: optimize creating enums with tuple payloads.
Convert sequences of

  %payload_addr = init_enum_data_addr %enum_addr
  %elem0_addr = tuple_element_addr %payload_addr, 0
  %elem1_addr = tuple_element_addr %payload_addr, 1
  ...
  store %payload0 to %elem0_addr
  store %payload1 to %elem1_addr
  ...
  inject_enum_addr %enum_addr, $EnumType.case

to

  %tuple = tuple (%payload0, %payload1, ...)
  %enum = enum $EnumType, $EnumType.case, %tuple
  store %enum to %enum_addr

Such patterns are generated for example when using the stdlib enumarated() function.

Part of rdar://problem/33438123
2020-03-19 19:07:11 +01:00
Rintaro Ishizaki
cbeffb69cd [CodeCompletion] Don't ignore CovariantReturnConversionExpr
in typechecked AST. This is needed to correctly get the type of the
parsed expression when the expression is a calling to a method in super
class returning 'Self'.

rdar://problem/51504896
2020-03-19 11:05:04 -07:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Doug Gregor
f2e581c7fc [Type checker] Look through reference storage types for typed patterns.
Fixes a regression caused by properly setting the context for checking
the type in a typed pattern.
2020-03-19 11:01:56 -07:00
Ben Langmuir
f30102e959 Fix Ubuntu 16.04 master-next build
Two more pair of string conversion fixes. With this, I was able to build
swift master-next on Ubuntu 16.04 (didn't try anything downstream of
swift, and not sure if the tests pass).
2020-03-19 09:51:39 -07:00
martinboehme
fa7155073d Don't import C++ class members that are protected or private (#30233)
* Don't import C++ class members that are protected or private.

We omit protected members in addition to private members because Swift
structs can't inherit from C++ classes, so there's effectively no way to
access them.

* Check access specifiers centrally in importDeclImpl().

* Fix macOS build by using <stddef.h> instead of <cstddef>.

Apparently, the macOS toolchain doesn't provide <cstddef>.

<stddef.h> is used in test/Inputs/clang-importer-sdk/usr/include/macros.h,
so I'm assuming it will be OK. (I don't unfortunately have a macOS
machine to test on.)

* Add comment explaining why we skip private and protected C++ class
members.
2020-03-19 08:20:36 -07:00
omochimetaru
3ccec26390 [Diagnostics] Fix range of fix-its in verify mode 2020-03-19 18:47:57 +09:00
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Michael Gottesman
8682002244 [ownership] Rename BorrowScopeOperandKind -> BorrowingOperandKind.
I missed this when I was doing the original refactoring. This was again done
using Xcode's refactoring functionality!
2020-03-18 23:05:40 -07:00