Commit Graph

227 Commits

Author SHA1 Message Date
Harlan Haskins
511db0c90a [ModuleInterface] Add printing for new attributes
Specially print @_hasMissingDesignatedInitializers and @_inheritsConvenienceInitializers in module interfaces

Fixes rdar://51249311
2020-01-06 10:15:07 -08:00
Rintaro Ishizaki
4eadbaa9f6 Revert "Merge pull request #27466 from rintaro/syntaxparse-type"
This reverts commit a4fcd26b38, reversing
changes made to 88ecae4b9a.
2019-10-14 12:19:04 -07:00
Slava Pestov
044204a5d5 Sema: Don't synthesize null bodies for invalid accessors
We don't want hasBody() == true and getBody() == nullptr.
2019-10-03 17:11:44 -04:00
Rintaro Ishizaki
7b31d2b4fb [SyntaxParse] Finish type parsing
- Type attributes
- SIL types
2019-10-01 15:40:10 -07:00
Slava Pestov
23edbcaf75 Sema: Merge validateAttributes() into checkDeclAttributes() 2019-08-20 14:47:52 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
2ef101c815 Sema: Don't add local functions to TC.definedFunctions
Instead, check them and their error handling right away.

In addition to fixing the crash in the radar, this also causes
us to emit unused variable warnings in functions containing
local functions.

Eventually, TC.definedFunctions should go away altogether.

Fixes <rdar://problem/53956342>.
2019-08-07 00:37:21 -04:00
Slava Pestov
a4bb3101ea Sema: Remove addExpectedOpaqueAccessorsToStorage() 2019-08-06 16:30:13 -04:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Doug Gregor
22c0995046 Allow non-@objc ‘dynamic’ in all language modes.
Non-‘@objc’ ‘dynamic’ has been allowed since Swift 5, but there’s no
reason to tie it to the language mode (Swift >= 5).

Fixes rdar://problem/50348013.
2019-05-21 13:40:04 -07:00
Suyash Srijan
ea555511a8 [typechecker] allow a throwing @objc function to return Unmanaged<T> 2019-04-18 21:14:23 +01:00
Brent Royal-Gordon
473fe7027e Make sure we don’t support @objc class subscripts
Obj-C subscripts don’t work on class objects, but you can declare class methods with the appropriate names. We don’t want to half-support this. Emit an error if you try to write “@objc class subscript” and test that we don’t import the methods as subscripts.
2019-04-10 23:17:04 -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
Jordan Rose
c8acb7e4c2 @objc extension makes even 'private' members '@objc' (#22436)
This regressed in a8fb416f9e, when we started using a helper function
in more places.

rdar://problem/47869562
2019-02-07 10:10:38 -08:00
Suyash Srijan
e65014e1ce [typechecker] allow @objc functions to return dynamic self 2019-01-20 03:49:50 +00:00
swift-ci
bbfc0649ed Merge pull request #21657 from DougGregor/objc-read-modify 2019-01-05 00:28:14 -08:00
Doug Gregor
a8fb416f9e [Type checker] Don't implicitly propagate @objc to read/modify accessors.
Fixes rdar://problem/46699152.
2019-01-04 23:29:57 -08:00
Slava Pestov
2e635e9603 Sema: Add @_hasInitialValue and @_hasStorage in typeCheckDecl() not validateDecl()
We only ever use this in TBDGen and interface printing, and we only ever
generate TBD files or print interfaces for declarations in primary files,
so let's avoid unnecessary work in validateDecl().

Eventually we want validateDecl() to be replaced with a getInterfaceType()
request, so adding new attributes in this path (or other side effects in
general) is a big no-no.
2019-01-02 15:12:02 -05:00
Karoy Lorentey
666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Harlan Haskins
13453109fe [ASTPrinter] Print property observers/private(set) with @_hasStorage 2018-11-26 18:42:02 -08:00
Vinicius Vendramini
318e7bee0b Fix attr_objc test to check AST dump in stdout
Also change the file extensions to `.ast` just to match those in other files.
2018-11-14 13:38:01 -02:00
Azoy
18d2cc5b01 Uninhabited downgrade to warning 2018-11-09 00:21:14 -06:00
Azoy
f085c28865 Not just instance members & better diagnostic
fix some tests
2018-10-23 18:08:00 -05:00
Jordan Rose
3114ed17e1 Allow '@usableFromInline' on 'dynamic' decls
It actually /does/ make sense to enforce the usable-from-inline rules
on dynamic declarations, but that would break source compatibility at
this point. Just allow '@usableFromInline' to be written on 'dynamic'
declarations, so that it'll be compatible with Swift 5.
2018-10-05 12:20:47 -07:00
Harlan
bccca6ad1e [InterfaceGen] Don't print 'final' on accessors (#19399)
We've never allowed overriding specific accessors, and we don't
currently parse this syntax.
2018-09-19 18:53:30 -07:00
Slava Pestov
4069fa68db Sema: Lift restriction on @objc categories of concrete subclasses of generic classes
In-place initialization means the class has a symbol we can reference
from the category, so there's nothing to do on the IRGen side.

For JIT mode, we just need to realize the class metadata by calling an
accessor instead of directly referencing the symbol though.
2018-08-20 16:23:07 -07:00
Huon Wilson
7753383223 [AST] Add @_hasInitialValue to var/lets that have initializers.
The information about whether a variable/property is initialized is lost in the
public interface, but is, unfortunately, required because it results in a symbol
for the initializer (if a class/struct `init` is inlined, it will call
initializers for properties that it doesn't initialize itself). This is
important to preserve for TBD file generation.

Using an attribute rather than just a bit on the VarDecl means this fits into
the scheme for module interfaces: textual/valid Swift.
2018-08-07 09:54:35 +10:00
Jordan Rose
6290d9be60 Introduce DescriptiveDeclKind::Property (#18183)
...and collapse StaticVar/ClassVar and StaticLet/ClassLet into
StaticProperty/ClassProperty.

"var" and "let" aren't great nouns to use in diagnostics to begin with,
especially alongside semantic terms like "instance method". Focus on
the type vs. non-type aspect instead with "property", which better
matches how people talk about member vars (and lets) anyway.
2018-07-30 09:23:59 -07:00
Doug Gregor
d9faa7415c [Type Checker] Add a request kind for ‘dynamic’.
Separate out the semantic state for the ‘dynamic’ check (from the
presence of the attribute), and move all of the computation of the
‘dynamic’ bit into the request-evaluator.

In the process, this fixes a bug where implicitly-synthesized initializers
in subclasses of imported classes would not be implicitly made ‘final’.
2018-07-18 14:50:39 -07:00
Matt Diephouse
35592747db Change "enum element" to "enum case" in diagnostics
From the perspective of the compiler implementation, they're elements. But users will think of these as cases—and many diagnostics already refer to these as enum cases.
2018-07-15 16:01:10 -04:00
Doug Gregor
d4edb3d2e8 [AST] Consistently rely on the “isObjC” bit rather than the presence of ObjCAttr.
The “isObjC” bit, once computed, provides the authoritative answer. The presence of
ObjCAttr is mostly incidental, although an implicitly-created one is sometimes
needed to store additional information (“inferred with Swift 3 rules” and a
specific Objective-C name).
2018-06-28 20:23:08 -07:00
Slava Pestov
0ce6de131e Sema: Explicitly check for 'inout' parameters on @objc functions
Previously we would produce a non-specific diagnostic about the
parameter type not being representable in Objective-C because
VarDecl::getType() wrapped the result in an InOutType.

Now that this is no longer the case we have to check for inout
independently of looking at the type.

Fixes <rdar://problem/41129106>.
2018-06-14 23:44:24 -07:00
Mark Rowe
62eb12b652 Include source ranges for decls in the AST dump. 2018-05-17 10:50:19 -07:00
Ben Langmuir
f20586b3d8 Revert "Include source ranges for statements, declarations, and parameter lists in the AST dump" 2018-05-17 09:53:05 -07:00
Mark Rowe
28af6959b8 Include source ranges for decls in the AST dump. 2018-05-09 11:15:35 -07:00
David Zarzycki
72d96c5e76 [Diag] QoI: Don't prematurely return while reporting diagnostics (#16100) 2018-04-23 16:34:33 -04:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Doug Gregor
02f3c1626e Allow ownership keywords on properties in @objc protocols.
Ownership keywords (weak/unmanaged) in @objc protocols do have an
effect on the generated header, because they get reflected as
weak/assign in the Objective-C `@property`. Therefore, allow these
keywords (again) on properties of @objc protocols.

Fixes SR-7182 / rdar://problem/38418112.
2018-03-15 11:28:01 -07:00
Mark Lacey
a499762445 Do not crash on @objc (Name) extension FancyName {}
We accepted this in Xcode 9.2, but currently crash.

We may want to consider rejecting this entirely, but for now lets not
crash.

Fixes rdar://problem/36798061.
2018-01-23 20:16:01 -08:00
Slava Pestov
e659befcf3 Sema: Clean up wording in some attribute-related diagnostics 2017-11-15 16:26:13 -08:00
Mark Lacey
d83374449b Add a declaration attribute for implicitly unwrapped optional.
Attach this attribute to VarDecls declared as IUO, and to function decls
that have a result type that is an IUO.

NFC at the moment. Eventually we'll use these to determine where to
implicitly unwrap optional values.
2017-11-02 22:44:37 -07:00
Slava Pestov
82999d8177 Sema: Don't allow @_inlinable or @_versioned to be applied to dynamic declarations 2017-10-31 13:37:20 -07:00
Graydon Hoare
e063767091 [Diagnostics] s/may/must/ in 'may not have operator requirements' 2017-09-29 16:09:23 -04:00
Marcelo Fabri
2bf49b0151 [SourceKit] Add range for attributes in a structure (SR-5587) (#11750) 2017-09-20 15:54:42 -07:00
Marcelo Fabri
09ede06f80 [ASTPrinter] Add trailing space after operator declaration (SR-3891) 2017-09-17 16:09:48 -03:00
Doug Gregor
f74dbab453 [AST printer] Print "inheritance" clauses based on the requirement signature.
As we do with "where" clauses, print the "inheritance" clauses of
protocols and associated type declarations using the requirement
signature of the protocol rather than the "inherited" list.
2017-09-08 17:07:09 -07:00
Doug Gregor
ff7bfa8b29 [Type checker] Handle inferred @objc for all accessor kinds.
Due to the wanton use of 'if' rather than 'switch', non-observing,
non-get/set ccessors that got marked '@objc' would cause an
assertion. Fix the materializeForSet case from the bug report as well
as the addressor case.

Fixes SR-5025 / rdar://problem/32426538.
2017-07-11 15:41:19 -07:00
Jordan Rose
485ebefba7 Merge pull request #10083 from jrose-apple/nscoding-diags-take-2
Update and re-enable the diagnostics for unstable runtime names
2017-06-05 19:51:01 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
Doug Gregor
9f50a0ec61 [QoI] Say "'@objc'" rather than the redundant "'@objc' attribute" in diagnostics.
A cleanup Jordan had mentioned a while ago that I'd forgotten about,
which makes the diagnostics slightly shorter.
2017-06-02 08:47:58 -07:00