Commit Graph

186 Commits

Author SHA1 Message Date
Doug Gregor
c0fea1f224 Disable printing of #ifs from the AST
The option to print #ifs defaulted to "on", but was disabled in most of
the actual compiler inputs that mattered, and the results weren't ever
actually used. Remove the option so we never print #ifs.
2024-09-08 09:52:37 -07:00
Manu
02b5fa2c8e Fix some typos in the codebase 2023-08-31 18:50:10 -03:00
QuietMisdreavus
60ef958116 don't break a doc comment with a regular comment (#66136)
rdar://95307936
2023-05-30 08:44:02 -06:00
Alexis Laferrière
cc3d2ecc32 [Test] Update test to be tolerant to attribute order changes 2022-12-21 14:11:42 -08:00
Anthony Latsis
6637c18954 Address a few stale FIXMEs & replace some commented-out test cases with verifications 2022-10-06 16:39:18 +03:00
Slava Pestov
b93717cbae RequirementMachine: Enable flags directly in LangOptions
This enables requirement machine minimization for all tools (SourceKit, etc)
not just the frontend.
2022-03-18 15:19:57 -04:00
Doug Gregor
ffd435d4b2 Update test cases for @MainActor inference 2021-11-08 17:13:25 -08:00
Alex Hoppen
380db634fa [Serialization] Serialize internal closure labels
Since 865e80f9c4 we are keeping track of internal closure labels in the closure’s type. With this change, wer are also serializing them to the swiftmodules.

Furthermore, this change adjusts the printing behaviour to print the parameter labels in the swiftinterfaces.

Resolves rdar://63633158
2021-04-13 08:53:46 +02:00
Slava Pestov
a7f2e5c50b GSB: Use explicit requirement list in enumerateRequirements() 2021-03-26 01:29:42 -04:00
Doug Gregor
5897dbed5c Update tests for deterministic serialization/printing of members 2021-01-20 13:40:48 -08:00
Nathan Hawes
9bcb54910e [AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
This affects module interfaces, interface generation in sourcekitd, and
diagnostics. Also fixes a fixit that was assuming the 'OSX' spelling when
computing the source range to replace.

Resolves rdar://problem/64667960
2020-07-08 13:51:25 -07:00
Anthony Latsis
403004b4c7 [ASTPrinter] Account for contextual where clauses when printing requirements 2020-03-26 04:48:39 +03:00
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
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
9dd835c71b Sema: Replace the finalizeDecl() mechanism with ClassDecl::getEmittedMembers()
The only thing remaining in finalizeDecl() is synthesis of
certain class members. Let's turn that into a request.
2019-08-09 19:08:47 -04:00
Harlan Haskins
7fd8649d30 [AST] Handle printing default values for tuples of nils
If a var has optional type, e.g.

```
var x: Int?
```

It will be implicitly initialized to `nil`. However, there's a second,
undocumented behavior: tuples of optional type, potentially nested infinitely,
will also be initialized, to tuples of nil.

So this var

```
var w: ((Int?, (), Int?), (Int?, Int?))
```

Will be default-initialized to

```
((nil, (), nil), (nil, nil))
```

We need to handle this inside getDefaultValueStringRepresentation,
otherwise we will crash while emitting partial modules.

Fixes one instance of rdar://51560190
2019-08-06 11:58:50 -07: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
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Brent Royal-Gordon
eb0d343ea7 [ASTPrinter] Print staticness of subscripts 2019-04-10 23:17:04 -07:00
Jordan Rose
883fc5b24a Check access control for the generic requirements of typealiases.
Also oops. This one was a little more involved because the requirements
on a generic typealias don't always carry a Type anymore; sometimes all
you have is the TypeRepr. That should still be okay in practice as long
as we don't start doing that for var/let, which can have part of a type
be inferred but not all of it.
2019-04-01 18:34:18 -07:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Saleem Abdulrasool
0a4bce94ea test: improve IDE test coverage for Windows
This improves the test pass rate for the IDE tests on Windows.  Some
failures remain.  Tests which expect the compiler to be built with
libxml2 cause 2 failures.  Another set of tests fail due to `stdint.h`
not being accessible to Windows due to include path ordering.  Some
other failures seem to stem from incomplete processing of sources.
2019-01-17 16:58:10 -08:00
Brent Royal-Gordon
57916e4f84 Loosen RawRepresentable test ordering requirements
Several tests implicitly depended on the order of declarations in RawRepresentable. This change loosens their requirements.
2018-12-18 16:25:12 -08:00
Xi Ge
93ec9901bb Sourcekit/DocSupport: avoid substituting generic types when printing where clauses. rdar://43820510
This makes the printed requirements agree with separately reported generic parameters and requirement.
2018-12-05 14:03:56 -08:00
Karoy Lorentey
811d3d710e [test] Update for RawRepresentable hashing changes 2018-11-22 17:16:07 +00:00
Mark Lacey
5094376677 Do not restore the precedencegroup name when deserializing them.
We only need to have the identifier during type checking of operator
declarations, so we do not need to restore it from the
PrecedenceGroupDecl during deserialization. We can just use the
deserialized name from the PrecedenceGroupDecl directly if needed.

This does result in one change in behavior. When printing modules, we
previously didn't print 'DefaultPrecedence' for items that had no
precedence specified, but now we will as seen in the test update for
IDE/print_ast_tc_decls.swift.
2018-10-08 21:19:37 -07:00
Jordan Rose
0e10f89964 Preserve default argument text through serialization (#18579)
This allows us to dump it in the generated interface, though it's
still not syntax-highlighted. This is necessary for textual module
interfaces, but it's also just a longstanding request for Xcode's
"Generated Interface" / "Jump to Definition" feature.

rdar://problem/18675831
2018-08-09 11:06:22 -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
Doug Gregor
f39fe1a755 [Tests] Put NSObject Equatable/Hashable back in the ObjectiveC module.
Technically, these operations belong in the ObjectiveC module, where NSObject
is defined. Keep them there. However, we need to build the mock ObjectiveC
overlay with `-disable-objc-attr-requires-foundation-module` now.
2018-08-01 09:25:28 -07:00
Slava Pestov
eeb5c953aa Sema: Ban protocol where clauses that place constraints on 'Self'
These will never work properly because of phase ordering issues with
the current declaration checker design. Since we can always express
the same thing with the protocol inheritance clause instead, just
diagnose this as an error instead of trying to hack around it.

Fixes <rdar://problem/38077232>, <https://bugs.swift.org/browse/SR-5581>.
2018-07-10 00:34:02 -07: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
Ben Langmuir
9496c63edc Merge pull request #15918 from johnfairh/typealias-where
[ASTPrinter] Print typealias generic requirements
2018-04-25 09:57:05 -07:00
Karoy Lorentey
130bcfd32d [SE-0206][test] Fix tests that look at Hashable requirements
hash(into:) needs to be included in expectations; tests looking at synthesized Hashable implementation bodies need to be updated for resilient hashing.
2018-04-24 17:42:42 +01:00
John Fairhurst
6e38a636aa [ASTPrinter] Print typealias where clause 2018-04-14 12:04:29 +01:00
Slava Pestov
509d293560 Sema: DeclChecker::visitClassDecl() does everything in the 'first pass' 2018-04-02 23:18:00 -07:00
John Fairhurst
87015e46d8 Print out param type attributes in more places 2017-11-20 19:36:50 +00:00
Davide Italiano
64dfc22fb1 [IDE] XFAIL some tests on FreeBSD. They're broken on non-mac OS. 2017-11-19 15:24:16 -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
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
Slava Pestov
7a04fc9ef2 ASTPrinter: Don't print redundant 'where Self : AnyObject' 2017-09-04 18:11:13 -05:00
Slava Pestov
50e7c066f7 Parse: Simpler handling of 'class' in protocol inheritance list
Instead of treating this as its own thing, just parse it as if
the user wrote 'AnyObject'.
2017-09-04 17:52:34 -05:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Graydon Hoare
e6027eeb4e Derive @_implements(Equatable, ==(_:_:)) _DerivedEnumEquals, not func==. 2017-04-18 23:21:44 -07:00
Doug Gregor
0be028acf6 [AST Printer] Swap the order of "Self == Self.A" requirements associated with A
It looks better this way.
2017-03-19 22:55:38 -07:00
Doug Gregor
994a5daec1 [AST Printer] Associate "Self == Self.Foo requirements with "Foo". 2017-03-19 22:38:58 -07:00
Doug Gregor
9aed438f27 [GSB] Use isDerivedRequirement() for same-type connected components 2017-03-19 22:26:39 -07:00
Huon Wilson
e4fb40ce9b [AST] Print where clauses on protocols and associated types.
In the general case, this is done by reverse engineering the "best"
places for requirements to go from the requirement signature.

Conformance/superclass requirements like Self: Foo and Self.T: Bar defer
to the inheritance clause if they appear there, or are attached to the
protocol where clause or T (respectively) if not. A conformance
requirement like Self.T.U: Baz will go on T (if T is declared in the
protocol being printed).

Same-type requirements always go in where clauses, and specifically a
where clause of an associated type that is mentioned in them, so
something simple like Self.T.U == Int goes on the T associated type
definition, and similarly Self.T.U == Self.V will go on V (it's kinda
nonsense, but also more directly connected to V). There's a left-bias
for cases without an "obvious" choice, meaning something more
complicated like Self.T.U == Foo<Self.V> will end up on T.

Requirements that don't fit elsewhere will go on the
protocol (e.g. Self.AssocTypeFromSuperProtocol == Int).
2017-03-14 14:22:07 -07:00
Roman Levenstein
9a7d28a084 [ast-printer] Don't emit 'infix' attribute for decls
Textual SIL containing something like: `infix static func ==(a: T, b: T) -> Bool` cannot be parsed and results in an error like:
```
error: 'infix' modifier is not required or allowed on func declarations
```

Interestingly enough, `prefix` and `postfix` attributes do not result in the same kind of errors.
2017-02-07 21:30:19 -08:00
Doug Gregor
f7f703ad04 [Archetype builder] Canonicalize and minimize same-type constraints.
Introduce an algorithm to canonicalize and minimize same-type
constraints. The algorithm itself computes the equivalence classes
that would exist if all explicitly-provided same-type constraints are
ignored, and then forms a minimal, canonical set of explicit same-type
constraints to reform the actual equivalence class known to the type
checker. This should eliminate a number of problems we've seen with
inconsistently-chosen same-type constraints affecting
canonicalization.
2017-02-01 10:51:02 -08:00