Gwynne Raskind
687585eafa
Docs: Remove all references to long-unused LitRe tool. Also incidentally removes redundant/duplicate check for sphinx-build binary.
2019-01-13 21:15:56 -06:00
Brent Royal-Gordon
9bd1a26089
Implementation for SE-0228: Fix ExpressibleByStringInterpolation ( #20214 )
...
* [CodeCompletion] Restrict ancestor search to brace
This change allows ExprParentFinder to restrict certain searches for parents to just AST nodes within the nearest surrounding BraceStmt. In the string interpolation rework, BraceStmts can appear in new places in the AST; this keeps code completion from looking at irrelevant context.
NFC in this commit, but keeps code completion from crashing once TapExpr is introduced.
* Remove test relying on ExpressibleByStringInterpolation being deprecated
Since soon enough, it won’t be anymore.
* [AST] Introduce TapExpr
TapExpr allows a block of code to to be inserted between two expressions, accessing and potentially mutating the result of its subexpression before giving it to its parent expression. It’s roughly equivalent to this function:
func _tap<T>(_ value: T, do body: (inout T) throws -> Void) rethrows -> T {
var copy = value
try body(©)
return copy
}
Except that it doesn’t use a closure, so no variables are captured and no call frame is (even notionally) added.
This commit does not include tests because nothing in it actually uses TapExpr yet. It will be used by string interpolation.
* SE-0228: Fix ExpressibleByStringInterpolation
This is the bulk of the implementation of the string interpolation rework. It includes a redesigned AST node, new parsing logic, new constraints and post-typechecking code generation, and new standard library types and members.
* [Sema] Rip out typeCheckExpressionShallow()
With new string interpolation in place, it is no longer used by anything in the compiler.
* [Sema] Diagnose invalid StringInterpolationProtocols
StringInterpolationProtocol informally requires conforming types to provide at least one method with the base name “appendInterpolation” with no (or a discardable) return value and visibility at least as broad as the conforming type’s. This change diagnoses an error when a conforming type does not have a method that meets those criteria.
* [Stdlib] Fix map(String.init) source break
Some users, including some in the source compatibility suite, accidentally used init(stringInterpolationSegment:) by writing code like `map(String.init)`. Now that these intializers have been removed, the remaining initializers often end up tying during overload resolution. This change adds several overloads of `String.init(describing:)` which will break these ties in cases where the compiler previously selected `String.init(stringInterpolationSegment:)`.
* [Sema] Make callWitness() take non-mutable arrays
It doesn’t actually need to mutate them.
* [Stdlib] Improve floating-point interpolation performance
This change avoids constructing a String when interpolating a Float, Double, or Float80. Instead, we write the characters to a fixed-size buffer and then append them directly to the string’s storage.
This seems to improve performance for all three types, but especially for Double and Float80, which cannot always fit into a small string when stringified.
* [NameLookup] Improve MemberLookupTable invalidation
In rare cases usually involving generated code, an overload added by an extension in the middle of a file would not be visible below it if the type had lazy members and the same base name had already been referenced above the extension. This change essentially dirties a type’s member lookup table whenever an extension is added to it, ensuring the entries in it will be updated.
This change also includes some debugging improvements for NameLookup.
* [SILOptimizer] XFAIL dead object removal failure
The DeadObjectRemoval pass in SILOptimizer does not currently remove reworked string interpolations as well as the old design because their effects cannot be described by @_effects(readonly). That causes a test failure on Linux. This change temporarily silences that test. The SILOptimizer issue has been filed as SR-9008.
* Confess string interpolation’s source stability sins
* [Parser] Parse empty interpolations
Previously, the parser had an odd asymmetry which caused the same function to accept foo(), but reject “\()”. This change fixes the issue.
Already tested by test/Parse/try.swift, which uses this construct in one of its throwing interpolation tests.
* [Sema] Fix batch-mode-only lazy var bug
The temporary variable used by string interpolation needs to be recontextualized when it’s inserted into a synthesized getter. Fixes a compilation failure in Alamofire.
I’ll probably follow up on this bug a bit more after merging.
2018-11-02 19:16:03 -07:00
practicalswift
cc852042c9
[gardening] Fix accidental trailing whitespace.
2016-10-29 10:22:58 +02:00
Dave Abrahams
5c13e35f29
[stdlib] Suppress noisy warnings
...
We don't have a way yet to say "this is deprecated for users, but let
the stdlib use it without complaining" so we need to do refactoring
shenanigans.
2016-08-28 15:06:42 -07:00
Chris Lattner
f3aec9358b
fix overly pedantic build issue where RST files fail to build if their
...
underline isn't big enough.
2016-07-12 21:58:52 -07:00
Robert Widmann
f97e5dcb0e
[SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
...
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration. A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Dmitri Gribenko
f5153572d7
stdlib: rename count labels in underscored protocols
...
lengthInBytes => utf8CodeUnitCount
numberOfCodeUnits => utf16CodeUnitCount
2016-01-21 17:18:15 -08:00
Dmitri Gribenko
73ce9ae7e9
Collection.count => .length
...
And other API changes that naturally fall out from this, like
Array(repeating:count:) => Array(repeating:length:).
2015-12-17 15:55:29 -08:00
Baptiste HAUDEGAND
059688aac7
Literals.rst: change protocols location
...
While reading the documentation, I found out that the
`StringLiteralConvertible` and `_BuiltinStringLiteralConvertible`
protocols where not present anymore inside the `Policy.swift`
source code file. They are now defined inside the
`CompilerProtocols.swift` source code file.
2015-12-05 13:29:04 +01:00
Dave Abrahams
8e2e7e9bfc
[stdlib] Hide all BuiltinXXXConvertible's
...
During String API review we decided these weren't for user consumption.
Swift SVN r17167
2014-05-01 19:35:50 +00:00
Dmitri Hrybenko
571c9b3c5e
Split 'type' keyword into 'static' and 'class'
...
rdar://15911697
Swift SVN r13908
2014-02-14 14:50:32 +00:00
Doug Gregor
23aeafc195
Finish switching "static" over to "type" in examples, proposals, etc.
...
Swift SVN r12048
2014-01-08 05:28:59 +00:00
Jordan Rose
417b5d3982
Merge TranslationUnit into Module, and eliminate the term "translation unit".
...
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.
Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).
The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)
Swift SVN r10837
2013-12-05 01:51:15 +00:00
Dave Zarzycki
83f953b80a
15242776 docs: Replace "Slice" with "Array"
...
Swift SVN r10710
2013-12-01 08:16:54 +00:00
Dave Abrahams
b1ac7ba7a4
[docs] Fix all ReST/Sphinx warnings, turn sphinx warnings into errors
...
Also revert r10607, which this change obsoletes
Swift SVN r10611
2013-11-20 23:27:13 +00:00
Dmitri Hrybenko
81dc5deee8
Change 'def' keyword back to 'func'
...
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Dmitri Hrybenko
91ce21666d
Change 'func' keyword to 'def'
...
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few. If you find something, please
let me know.
rdar://15346654
Swift SVN r9886
2013-11-02 01:00:42 +00:00
Jordan Rose
75ae10d9b1
[docs] Note that our abstract model for literals has arbitrary precision.
...
Swift SVN r8701
2013-09-26 21:52:56 +00:00
Jordan Rose
8f112c2e47
[docs] Add a side doc describing the literal conversion process.
...
Not yet linked from the top-level because it's just for reference and has
not been vetted by anyone.
Swift SVN r8693
2013-09-26 17:48:17 +00:00