Commit Graph

20516 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
5a6a110f16 Merge pull request #24227 from akyrtzi/gyb-syntax-def-element-name
[utils/gyb_syntax_support] Add `collection_element_name` for when specifying a `Child`
2019-04-24 00:19:49 -07:00
Argyrios Kyrtzidis
3612cd3d72 [utils/gyb_syntax_support] Add collection_element_name for when specifying a Child
This is useful to provide `add<ELEMENT_NAME>` APIs for SwiftSyntax that are better named
and without having name conflicts.
2019-04-23 18:14:39 -07:00
ravikandhadai
faa6693eec Merge pull request #24004 from ravikandhadai/constexpr-diagnostics-refactoring
[Const evaluator] Improve diagnostics for unknown symbolic values
2019-04-23 17:10:43 -07:00
Doug Gregor
faa176f3ef Record and walk the semantic initializer for a custom attribute. 2019-04-23 14:15:41 -07:00
Arnold Schwaighofer
f55d68db83 Remove SpecializeOpaqueArchetypes for now 2019-04-23 12:26:13 -07:00
Doug Gregor
99d4e8090c [Index] Handle memberwise initializers with defaulted arguments. 2019-04-23 11:32:29 -07:00
Doug Gregor
7df695536e [Property delegates] Fix printing of memberwise initializer default arguments 2019-04-23 11:32:28 -07:00
Doug Gregor
261b879b54 [Property delegates] Rename storageValue to delegateValue 2019-04-23 11:32:28 -07:00
Doug Gregor
2e9f8cf981 Capture a placeholder opaque value expression when needed. 2019-04-23 11:32:28 -07:00
Doug Gregor
f187d9218e [Type checker] Don't allow a 'let' to have a property delegate. 2019-04-23 11:32:28 -07:00
Doug Gregor
4f56db2653 [Property delegates] Implement support for storageValue 2019-04-23 11:32:28 -07:00
Erik Eckstein
86fb74a34e DI: support assign_by_delegate instruction 2019-04-23 11:32:28 -07:00
Erik Eckstein
2e01b0edeb SIL: add assign_by_delegate instruction
Used for property delegates.
2019-04-23 11:32:28 -07:00
Doug Gregor
9e22400117 Add missing header file 2019-04-23 11:31:59 -07:00
Doug Gregor
cc68b12d1a [SILGen] Initialization of instance properties with property delegates
The initialization of an instance property that has an attached
property delegate involves the initial value written on the property
declaration, the implicit memberwise initializer, and the default
arguments to the implicit memberwise initializer. Implement SILGen
support for each of these cases.

There is a small semantic change to the creation of the implicit
memberwise initializer due to SE-0242 (default arguments for the
memberwise initializer). Specifically, the memberwise initializer will
use the original property type for the parameter to memberwise
initializer when either of the following is true:

  - The corresponding property has an initial value specified with the
    `=` syntax, e.g., `@Lazy var i = 17`, or
  - The corresponding property has no initial value, but the property
    delegate type has an `init(initialValue:)`.

The specific case that changed is when a property has an initial value
specified as a direct initialization of the delegate *and* the
property delegate type has an `init(initialValue:)`, e.g.,

```swift
struct X {
  @Lazy(closure: { ... })
  var i: Int
}
```

Previously, this would have synthesized an initializer:

```swift
init(i: Int = ???) { ... }
```

However, there is no way for the initialization specified within the
declaration of i to be expressed via the default argument. Now, it
synthesizes an initializer:

```swift
init(i: Lazy<Int> = Lazy(closure: { ... }))
```
2019-04-23 11:31:59 -07:00
Doug Gregor
6526cfa8d4 Memberwise initializer synthesis for properties with attached delegates. 2019-04-23 11:31:58 -07:00
Doug Gregor
b18a2902e5 Implement access control for property delegates 2019-04-23 11:31:58 -07:00
Doug Gregor
b8061eab34 Synthesize backing storage property for properties with attached delegates.
When a property has an attached property delegate, a backing storage
property of the corresponding delegate type will be
synthesized. Perform this synthesis, and also synthesize the
getter/setter for the original property to reference the backing
storage property.
2019-04-23 11:31:58 -07:00
Doug Gregor
7f293f66b3 [Parser] Allow use of $ declarations in all modes.
Allow the use of declarations whose names start with $ in all
modes. However, normal code cannot define new entities with names that
start with $: only the implementation can do that, e.g., for property
delegates.
2019-04-23 11:31:58 -07:00
Doug Gregor
9c62420809 [AST] Generalize PatternBindingEntry's "Lazy" flag to "Subsumed"
The initializer associated with a lazy property should not be executed
directly, because it is subsumed by code synthesized into the
getter. Generalize the terminology here so we can re-use this path for
property delegate initialization.
2019-04-23 11:31:58 -07:00
Doug Gregor
53b9e25502 Implement initialization of properties with attached delegates.
A property with an attached delegate can be initialized in one of two ways:

* By directly specifying initialization arguments on the attribute,
  e.g., "@SomeDelegate(x: 17, y: 42) var a".
* By initializing the original property itself, which goes through the
  delegate type's init(initialValue:) initializer, e.g.,
  "@Lazy var x = 17".

Implement support for both forms of initialization, including type
inference and checking for inconsistencies (e.g., if the annotation on
the property type doesn't match what the delegate type would
provide).
2019-04-23 11:31:58 -07:00
Doug Gregor
96279c7044 Use custom attributes to apply property delegates to variables.
A custom attribute can be resolved to a property delegate type. Allow
this for property declarations (only), and diagnose the various places
where properties cannot have property delegates.
2019-04-23 11:31:58 -07:00
Doug Gregor
f9c716df87 Add support for the @propertyDelegate attribute.
Add the @propertyDelegate attribute, enforcing all of the semantic
requirements that are placed on property delegate types.
2019-04-23 11:31:58 -07:00
Mike Ash
8b0ab1cc49 [RemoteMirror] Mark swift_reflection_classIsSwiftMask as a weak import.
Also have swift-reflection-test check if the symbol exists. This allows swift-reflection-test to work with older Remote Mirror dylibs that don't have it.

rdar://problem/50030805
2019-04-23 11:37:37 -04:00
Doug Gregor
a97a51956f Merge pull request #24209 from DougGregor/opaque-result-types-mangling-fixes
[Opaque result types] Fix mangling issues with opaque result types.
2019-04-23 06:26:39 -07:00
Slava Pestov
3f5a06bc3e AST: Always diagnose request evaluator cycles 2019-04-22 22:22:23 -04:00
Slava Pestov
015e8f72a8 Merge pull request #24211 from slavapestov/declutter-ast-context
Declutter ASTContext by moving @objc diagnostics to Sema
2019-04-22 21:50:06 -04:00
Slava Pestov
5cb1c6aa88 Merge pull request #24196 from AnthonyLatsis/diag-proto-multiple-superclass
Diag: Correct message for protocols with multiple superclass requirements
2019-04-22 20:58:05 -04:00
Slava Pestov
949fe16da5 AST: Move a bunch of random @objc diagnostics to Sema 2019-04-22 20:42:08 -04:00
Slava Pestov
07ce01d96d AST: Replace ASTContext's ObjCMethodConflicts list with a per-SourceFile list 2019-04-22 20:42:08 -04:00
Slava Pestov
0fae7e8669 AST: Replace ASTContext's ObjCUnsatisfiedOptReqs list with a per-SourceFile list 2019-04-22 20:42:08 -04:00
Slava Pestov
e97fc4e0c2 AST: Replace ASTContext's ObjCMethods list with a per-SourceFile list 2019-04-22 20:42:07 -04:00
Doug Gregor
e29469b9c0 [Opaque result types] Fix mangling issues with opaque result types.
Fix a trio of issues involving mangling for opaque result types:
* Symbolic references to opaque type descriptors are not substitutions
* Mangle protocol extension contexts correctly
* Mangle generic arguments for opaque result types of generic functions

The (de-)serialization of generic parameter lists for opaque type
declarations is important for the last bullet, to ensure that the
mangling of generic arguments of opaque result types works across
module boundaries.

Fixes the rest of rdar://problem/50038754.
2019-04-22 17:10:45 -07:00
Brent Royal-Gordon
814d50c7e6 Merge pull request #24163 from brentdax/line-line-line-line
Add -debug-constraints-on-line flag
2019-04-22 16:54:00 -07:00
Brent Royal-Gordon
79cee8daad Add -debug-constraints-on-line flag 2019-04-22 13:59:50 -07:00
Arnold Schwaighofer
1fbf5f1cc3 Add AllowCompatibleOpaqueTypeArchetypes as a Type.match flag 2019-04-22 13:37:46 -07:00
adrian-prantl
ecebf70745 Merge pull request #24173 from adrian-prantl/memorybufferloader
Factor out the pre-registered MemoryBuffer functionality
2019-04-22 11:32:06 -07:00
Arnold Schwaighofer
7d0bcdac2e Add comments 2019-04-22 11:21:54 -07:00
Rintaro Ishizaki
73d3fd6631 Merge pull request #24177 from rintaro/sourcekit-opaque-result-types
[SourceKit] SourceKit support for opaque result types
2019-04-22 09:58:47 -07:00
Adrian Prantl
b244b0928e Factor out the pre-registered MemoryBuffer functionality
form SerializedModuleLoader into its own ModuleLoader class. (NFC-ish)

This gives better control over the order in which the various module
load mechanisms are applied.
2019-04-22 09:17:08 -07:00
Arnold Schwaighofer
a0387eea40 Opaque result types: Dynamic replacement fixes for computed properties 2019-04-22 08:32:43 -07:00
Arnold Schwaighofer
7ccdd00fb1 Add a pass to specialize opaque type archetypes.
Clones functions containing opaque type archetypes replacing the opaque
type by a concrete type.

rdar://46140751
2019-04-22 07:38:09 -07:00
Arnold Schwaighofer
84c7b77d02 Make opaque type descriptors dynamically replaceable
This is to support dynamic function replacement of functions with opaque
result type.

This approach requires that all state is thrown away (that could contain the
old returned type for an opaque type) between replacements.

rdar://48887938
2019-04-22 07:31:07 -07:00
fischertony
70f8c84af7 Diag: Correct message for protocols with multiple superclass requirements 2019-04-21 17:04:31 +03:00
Xi Ge
ddd643fe89 syntax: perform rename to avoid name collision in syntax builder. NFC 2019-04-20 16:04:41 -07:00
Xi Ge
a9ba1ced6c Merge pull request #24176 from nkcsgexi/syntax-disambiguity
Syntax: use child name instead of type name for gyb-generated functions. NFC
2019-04-19 19:27:30 -07:00
Xi Ge
1015a6024d Syntax: use child name instead of type name for gyb-generated functions
ParsedSyntaxBuilder has a convenient function to add member to a syntax-collection
child. The function name uses the type name of the collection's members,
which can lead to name collision. This patch renames it.
2019-04-19 18:16:13 -07:00
Rintaro Ishizaki
b5351a154c [CursorInfo] UID for opaque result type.
rdar://problem/49819227
2019-04-19 17:34:08 -07:00
Rintaro Ishizaki
3a2454c2c7 [CodeCompletion] Use opaque type for override completion if preferable
rdar://problem/49354106
2019-04-19 17:34:08 -07:00
Rintaro Ishizaki
8055583ddf [IDE] Print opaque result type as protocol composition
rdar://problem/49354663
2019-04-19 17:34:08 -07:00