Commit Graph

73 Commits

Author SHA1 Message Date
Slava Pestov
392a5c2bcb AST: @usableFromInline and @inlinable are no longer user inaccessible 2018-04-26 22:58:56 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Davide Italiano
b4a19cc6ac [Mangler] Fix mangling for associated types. 2018-03-27 11:06:15 -07:00
Pavel Yaskevich
4b05449c37 [GSB] Eliminate concrete potential archetypes by early substitution
To make generic signature builder more robust it's imperative to
eliminate possibility of out-of-order typealias substitution.

These changes try to make it so potential archetypes could only be
constructed with associated types by doing early concrete type (typealias)
subsitution while trying to resolve equivalence class.
2018-03-06 23:34:19 -08:00
Slava Pestov
cb1c8c8f16 AST: Simplify printExtendedTypeName() 2018-03-06 19:41:44 -08:00
Bartosz Polaczyk
c28302836b [SIL] Print full nested enum type name
ASTPrinter should print an extended type for enums,
(same as structs and classes) along with enum parents.
2018-02-18 16:14:42 +01:00
Huon Wilson
cb60dbeee2 [IDE] Teach type checker about conditional conformance extensions.
Before conditional conformances, the archetypes in conformance
extensions (i.e. extension Foo: SomeProtocol) were equivalent to those
in the type decl, with the same protocol bounds and so on. The code for
printing "synthesized" members relied on this fact. This commit teaches
that code to deal with archetypes in the conditional conformance
extension when required.

Fixes rdar://problem/36553066 and SR-6930.
2018-02-13 17:37:15 +11:00
Pavel Yaskevich
533171debf [Mangling/ABI] NFC: Fix SourceKit tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Nathan Hawes
01e538951f [SourceKit][DocInfo] Avoid outputing identifier annotations for ranges already covered by parameter/argument annotations
Resolves rdar://problem/20799943
2017-11-16 18:25:03 -08:00
Nathan Hawes
7403e779ad [ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
Also handle requirements in non-trailing where clauses (for -swift-version 3)
Resolves rdar://problem/34859742
2017-11-16 16:02:12 -08:00
Nathan Hawes
351238a199 [ASTWalker/index] Walk into the trailing where clause on extension decls so we don't miss the type references there. 2017-10-27 19:27:10 -07:00
Doug Gregor
6e6b6b9837 [Mangler] Only mangle new requirements for constrained extensions.
Rather than mangling the complete generic signature of a constrained
extension, only mangle the requirements not already satisfied by the
nominal type. For example, given:

    extension Dictionary where Value: Equatable {
      // OLD: _T0s10DictionaryV2t3s8HashableRzs9EquatableR_r0_lE3baryyF
      // NEW: _T0s10DictionaryV2t3s9EquatableR_rlE3baryyF
      public func bar() { }
   }

In the existing mangling, we mangle the `Key: Hashable` requirement that’s
part of the generic signature. With this change, we only mangle the new
requirement (`Value: Equatable`).

This is a win for constrained extensions *except* in the case of a
constrained extension of a nominal type with a single, unconstrained
generic parameter:

    extension Array where Element: Equatable {
      // OLD: _T0Sa2t3s9EquatableRzlE3baryyF
      // NEW would be: _T0Sa2t3s9EquatableRzrlE3baryyF
      public func bar() { }
    }

Check explicily for this shortcut mangling and fall back to the old
path, so this change is a strict improvement.
2017-10-11 19:23:58 -07:00
Max Moiseev
0a69646df4 [test] Address the sourcekit test failures 2017-09-29 11:26:56 -07:00
Marcelo Fabri
09ede06f80 [ASTPrinter] Add trailing space after operator declaration (SR-3891) 2017-09-17 16:09:48 -03:00
Slava Pestov
696694b61d Update some IDE tests 2017-09-14 01:15:31 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Arnold Schwaighofer
f442dd93bd CompilerInvocation: If no optimization flag is set default to Onone
I noticed in a follow-up patch that if you just swiftc without passing Onone
these flags are not set and sometimes happen to default to right thing ... or
not; as can be seen by the test cases modified. For example, at Onone we are
supposed to include an extra swift module "SwiftOnoneSupport".
2017-08-04 11:49:16 -07:00
Doug Gregor
be5bc3fd07 [GSB] Eliminate two more uses of ArchetypeResolutionKind::AlwaysPartial.
We don't need to force the creation of potential archetypes when
finding anchors, because new potential archetypes will only be created
by this process in ill-formed generic signatures. Tolerate failure
whenever this happens (for now) and the failure paths will become dead
once AlwaysPartial is eliminated fully.
2017-06-28 06:23:52 -07:00
Doug Gregor
9ff7ff73ef Fix up order-dependent test cases 2017-05-15 22:17:19 -07:00
Argyrios Kyrtzidis
9b9c84a708 Merge pull request #8972 from akyrtzi/index-external-symbol-namespacing
[index] Use a #pragma to apply module namespacing for exported ObjC header and match Swift namespaced USRs with the clang side
2017-04-24 21:13:12 -07:00
Argyrios Kyrtzidis
792d7c06a5 [test/SourceKit/DocSupport] Fix test for @objc USR change 2017-04-24 14:13:37 -07:00
Jordan Rose
129fd372d5 ASTPrinter: Qualify names when printing nested declarations.
That is, if you have this declaration:

    struct Outer {
      struct Inner {
        // ...
      }
    }

and you're just printing 'Inner', print it like this:

    struct Outer.Inner {
      // ...
    }

This comes up with the ClangImporter's import-as-member feature, and
is also about to affect how error code enums are imported as well.

This is currently only enabled in certain contexts: always when
printing interfaces, and for types (but not other members) when
printing declarations for Quick Help.

rdar://problem/28208090
2017-04-24 09:57:40 -07:00
Max Moiseev
8ca814cc8c Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-04-17 14:40:20 -07:00
Jordan Rose
2d84981fc2 Improve the mangling of typealiases.
- Allow them to use substitutions.
- Consistently use 'a' as a mangling operator.
- For generic typealiases, include the alias as context for any generic
  parameters.

Typealiases don't show up in symbol names, which always refer to
canonical types, but they are mangled for debug info and for USRs
(unique identifiers used by SourceKit), so it's good to get this
right.
2017-04-17 11:31:15 -07:00
Max Moiseev
835b8809d2 Merge branch 'master' into new-integer-protocols 2017-03-07 16:18:54 -08:00
Erik Eckstein
a04a29af4f mangling: efficient mangling of repeated substitutions
Instead of appending a character for each substitution, we now prefix the substitution with the repeat count, e.g.
AbbbbB -> A5B

The same is done for known-type substitutions, e.g.
SiSiSi -> S3i

This significantly shrinks mangled names which contain large lists of the same type, like
  func foo(_ x: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int))

rdar://problem/30707433
2017-03-05 17:41:43 -08:00
Erik Eckstein
7995d3d35a SourceKit: Use new mangling for USR generation. 2017-02-23 12:47:10 -08:00
Nathan Hawes
444775f58a Merge pull request #7670 from nathawes/rdar16271632
Use clang-style USRs for swift decls that are exposed to Objective C
2017-02-21 17:00:28 -08:00
David Farler
450028fbe8 [ASTPrinter] Restore printing generic requirement contexts
cfe9e6a3de removed calls to pre/post
printing of PrintStructureKind::GenericRequirement, so SourceKit DocInfo
requests started droping the markers for generic requirements, causing
some weirdness with documentation rendering and post-processing.

Restore the calls to printStructPre/Post when printing generic
requirements.

rdar://problem/30561880
2017-02-21 12:46:08 -08:00
Nathan Hawes
c9758c2c0f Use clang-style USRs for swift decls that are exposed to Objective C 2017-02-21 09:42:33 -08:00
Doug Gregor
90f021485d [Serialization] Serialize archetypes as generic environment + interface type.
Rather than serializing the complete structure of all archetypes
(which is completely redundant), serialize a reference to their owning
generic environment as well as their interface type. The archetype
itself will be reconsituted by mapping the interface type into that
generic environment.
2017-02-09 23:50:17 -08:00
Max Moiseev
aecccc7e48 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-09 17:38:04 -08:00
Max Moiseev
6a06b667da Fixing some and XFAILing other failing tests 2017-01-06 17:56:20 -08:00
Xi Ge
264057dc04 [DocSupport] Ensure synthesized target is correct for enclosed nominal decls inside extension declarations. rdar://29857103 2017-01-06 15:40:14 -08:00
Xi Ge
6c115a4d0a [ASTPrinter] Properly limit the decl context of synthesized extensions to avoid crash. rdar://29857103 2017-01-04 17:34:19 -08:00
Slava Pestov
0948506cc2 ASTPrinter: Refactor usages of ArchetypeType::getSelfProtocol()
This fixes an issue where a 'Self' return type from a protocol
extension prints the USR of the protocol and not the extension.
2016-11-19 00:27:44 -08:00
Xi Ge
be3910d5a7 [AST] Put DeclKind::Subscript to the value decl bucket because it is one. rdar://28780008 2016-10-25 11:26:23 -07:00
Xi Ge
64082e122f SourceKit: checking context match before calling TypeBase::getMemberSubstitutions(const DeclContext *dc). rdar://28780008
TypeBase::getMemberSubstitutions(const DeclContext *dc) collects type
substitution information when a decl context can be treated as part of the
type definition. However, we call it without checking whether the
part-of-whole relationship really holds. This patch checks the
pre-condition before calling it to fix a crash.
2016-10-24 13:28:13 -07:00
Slava Pestov
cfe9e6a3de IDE: Use GenericSignatures and interface types (mostly)
There was a ton of complicated logic here to work around
two problems:

- Same-type constraints were not represented properly in
  RequirementReprs, requiring us to store them in strong form
  and parse them out when printing type interfaces.

- The TypeBase::getAllGenericArgs() method did not do the
  right thing for members of protocols and protocol extensions,
  and so instead of simple calls to Type::subst(), we had
  an elaborate 'ArchetypeTransformer' abstraction repeated
  in two places.

Rewrite this code to use GenericSignatures and
GenericFunctionType instead of old-school GenericParamLists
and PolymorphicFunctionType.

This changes the code completion and AST printer output
slightly. A few of the changes are actually fixes for cases
where the old code didn't handle substitutions properly.
A few others are subjective, for example a generic parameter
list of the form <T : Proto> now prints as <T where T : Proto>.

We can add heuristics to make the output whatever we want
here; the important thing is that now we're using modern
abstractions.
2016-10-02 23:49:15 -04:00
Rintaro Ishizaki
229beac813 [SE-0081][ASTPrinter] Move where clause to the end of declaration 2016-09-04 02:42:56 +09:00
Xi Ge
64efa48c65 [SourceKit][DocInfo] When the underlying type of a type alias decl exists, report the conformances of the underlying type. rdar://26408167 (#3394)
Showing only the conforming associated types provides
little information to doc viewers. This patch digs the
underlying type of an associated type to report the
conformance info of those.
2016-07-07 16:24:01 -07:00
Jorge Bernal
0a3f913b20 SE-0070: Make Optional Requirements Objective-C-only.
Optional protocol requirements now require an explicit @objc attribute.

Fixes SR-1395
2016-05-06 11:05:52 +02:00
Xi Ge
c4d7b1a185 ASTPrinter: never synthesize extensions for raw types of enum decls.
Even thought raw types are specified in inheritance clauses, their
members are not usable through an enum instance. Thus, there is no
point to synthesize their members.
2016-04-22 22:52:46 -07:00
Jordan Rose
7ad6a8bd61 [test] Fix SourceKit tests for 2e38280.
Also filed <rdar://problem/25858559> "SourceKit response info for
enum shouldn't include members of the raw type" to keep it from
happening again.
2016-04-21 11:50:27 -07:00
Michael Buckley
daa4714864 Merge branch 'master' into int-from-unsafepointer 2016-04-13 20:44:08 -07:00
Michael Buckley
8e8e61b0bc Add inititializers to Int and UInt which take UnsafePointers and UnsafeMutablePointers 2016-04-12 20:03:11 -07:00
David Farler
fbc220a036 Revert "Revert "Enable cmark smart punctuation in doc comments""
This reverts commit f723b86614 and
updates the IDE tests that incidentally included some punctuation.
No new tests are necessary - the character level tests are exercised
in cmark itself.
2016-04-10 13:32:43 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Xi Ge
ca93fa6d1b [SourceKit] DocInfo: Explicitly report the optionality of protocol members in response. rdar://25129725 2016-04-01 14:55:11 -07:00