Commit Graph

172 Commits

Author SHA1 Message Date
Max Moiseev
e48f452a2e Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-api-guidelines 2016-02-29 12:15:33 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Daniel Duan
780b58a9a5 [Parser] update tests for 'inout' syntax adjustment 2016-02-26 01:33:22 -08:00
Jordan Rose
b319e3da32 stdlib: Adjust to insert(contentsOf:at:) and append(contentsOf:)
instead of insertContents(of:at:) and appendContents(of:),
originally insertContentsOf(_:at:) and appendContentsOf(_:)
per internal discussion.
2016-02-25 12:50:39 -08:00
Max Moiseev
4b9eab6288 appendContentsOf => appendContents(of:) 2016-02-22 18:02:04 -08:00
Max Moiseev
481bcabcba [stdlib] API naming guidelines applied to split and join
- `separator` label for first argument of `split`
- `join` and related types are renamed to `joined`
2016-02-22 15:43:33 -08:00
Dmitri Gribenko
98561f6137 stdlib: joinWithSeparator(_:) => join(separator:) 2016-02-18 22:30:57 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
gregomni
37d05ea0dc Improved handling of mixed lvalues & rvalues in tuple exprs
My previous commit here didn’t work correctly for nested tuples, both
because it didn’t recurse into them to propagate access kind correctly
and because an outer TupleIndex overload (when indexing into the nested
tuple) could still be expecting an lvalue type.

This fix is much better. ConstraintSystem::resolveOverload now
correctly always expects rvalue types from rvalue tuples. And during
applyMemberRefExpr, if the overload expects an rvalue but the tuple
contains lvalues, coerceToType() correctly does any recursive munging
of the tuple expr required.
2016-02-15 20:59:53 -08:00
Chris Lattner
6552361c20 Remove 4 constraint solver fixits that were not pulling their weight anymore:
- 3 related to OptionSet migration for Swift 1 -> Swift 2.
- 1 related to calling a non-function type, which is now handled by CSDiags.
2016-02-12 21:12:19 -08:00
Max Moiseev
55fde4c923 making tests pass 2016-02-10 16:08:40 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Chris Lattner
0619e57a61 Switch the stdlib to use #file instead of __FILE__, and deprecate the __FILE__ identifiers.
This also updates the tests that would otherwise fail.
2016-02-04 15:08:31 -08:00
gregomni
6d54eecd67 Mixing lvalues and rvalues in tuple exprs is very unhappy.
In SR-628 in particular, the problem was an assert that an AccessKind
was being set on a non-lvalue, but there were lots of asserts here in
various scenarios, the most common other ones being an AccessKind not
being set assertion by the ASTVerifier or lvalue-ness not matching
between tuple expr and tuple element expr.

This checks for lvalues in the tuple when a tuple indexing expr is built,
and if there are any, inserts load exprs into the lvalue elements to make all rvalues.
2016-01-29 08:15:03 -08:00
Austin Zheng
77918a86ac [SR-88] Reinstate Mirror migration changes, fix test issues
This reverts commit 182bb7f812.
2016-01-27 20:40:52 -08:00
Andrew Trick
182bb7f812 Revert "Merge pull request #1058 from austinzheng/az-port-mirror"
This pull request broke the following tests on several build configurations
(eg --preset=buildbot,tools=RA,stdlib=DA)

    1_stdlib/Reflection.swift
    1_stdlib/ReflectionHashing.swift
    1_stdlib/UnsafePointer.swift.gyb

This reverts commit c223a3bf06, reversing
changes made to 5c2bb09b09.
2016-01-27 10:43:08 -08:00
Austin Zheng
10d5b23c30 [SR-88] Reinstate mirror migration commit
Changes:
- Reverted commit reverting original SR-88 commit
- Removed mirror children helper collections and related code
- Rewrote some tests to keep them working properly
- Wrote two more tests for the three pointer APIs to ensure no crashes if created using a value > Int64.max

This reverts commit 8917eb0e5a.
2016-01-26 19:28:32 -08:00
Chris Lattner
995506a5e2 Improve the generic "expression...is ambiguous without more context" error in a few ways:
- Improve the specific cases of nil and empty collection literals.
- Improve cases of contextual member lookup where the result type of the looked up member disagrees with context.
- Add some fixme's to the testsuite for cases of this diagnostic that should be diagnosed in other ways.
2016-01-22 22:58:26 -08:00
Mark Lacey
8917eb0e5a Revert "[Runtime][StdLib] Migrate mirrors to use CustomReflectable API, rewrite dump()"
This reverts commit 9798dfd4aa because it
broke the stdlib build.
2016-01-22 08:41:07 -08:00
Austin Zheng
9798dfd4aa [Runtime][StdLib] Migrate mirrors to use CustomReflectable API, rewrite dump()
Jira: SR-88
Changes:
- Removed stdlib type conformances to _Reflectable
- Conformed stdlib types to CustomReflectable, CustomPlaygroundQuickLookable
- Rewrote dump() function to not use _reflect()
- CGRect, CGPoint, CGSize now conform to CustomDebugStringConvertible
- Rewrote unit tests for compatibility with new API
2016-01-21 09:44:15 -08:00
Chris Willmore
983a674e0c Make use of curried function declaration syntax an error.
<rdar://problem/23111018>
2016-01-20 21:57:38 -08:00
Doug Gregor
7d70b704e4 Merge commit '5e11e3f7287427d386636a169c4065c0373931a8' into swift-3-api-guidelines 2016-01-19 23:18:20 -08:00
Chris Lattner
e30cd939d9 Fix rdar://20395243 QoI: type variable reconstruction failing for tuple types
ASTPrinter of type variables was trying to dig an original type out of the
locator and archetype that opened the type variable in the first place.  This
was prone to failure and never helped, so just always print type vars as _.

The affected diagnostics always come out better and this saves a word of storage
for each type variable.
2016-01-11 22:20:19 -08:00
Chris Lattner
13d96b3eeb Spell out these diagnostics more, they are embarassing, but we should fix that not hide it. 2016-01-11 20:45:11 -08:00
Chris Lattner
8d81349fe1 fix rdar://24029542 "Postfix '.' is reserved" error message" isn't helpful
This adds some heuristics so we can emit a fixit to remove extraneous
whitespace after a . and diagnose the case where a member just hasn't
been written yet better.  This also improves handling of tok::unknown
throughout the parser a bit.

This is a re-commit of ff4ea54 with an update for a SourceKit test.
2016-01-11 15:11:20 -08:00
Erik Eckstein
acc243a002 Revert "fix rdar://24029542 "Postfix '.' is reserved" error message" isn't helpful"
It's probably the cause for the fail of SourceKit/SyntaxMapData/syntaxmap-edit-del.swift

This reverts commit ff4ea54614.
2016-01-11 10:43:39 -08:00
Chris Lattner
ff4ea54614 fix rdar://24029542 "Postfix '.' is reserved" error message" isn't helpful
This adds some heuristics so we can emit a fixit to remove extraneous
whitespace after a . and diagnose the case where a member just hasn't
been written yet better.  This also improves handling of tok::unknown
throughout the parser a bit.
2016-01-10 15:28:03 -08:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Chris Lattner
443af4ad91 In the deprecation warnings for ++/-- on index types, emit a fixit hint to rewrite into
the correct call to .successor() or .predecessor().

This wraps up <rdar://problem/23708702> Emit deprecation warnings for ++/-- in Swift 2.2
2015-12-22 21:04:48 -08:00
Chris Lattner
6a63c77fce Produce fixit hints for deprecated ++/--, rewriting them into (e.g.) += 1.
This handles the case when we have int/fp uses that ignore the result of
the expression.  Index types are coming next.
2015-12-22 15:40:35 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Chris Lattner
be53728691 Mark the ++ and -- operators in the standard library as deprecated for Swift 2.2,
to be removed in Swift 3.0.  I plan to improve the QoI of this deprecation in a
subsequent commit.
2015-12-21 22:10:25 -08:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -08:00
Chris Willmore
18938ac2ef Fix single-arg-for-tuple-param check
In matchTypes(), we check whether a type variable representing an
argument could potentially be bound to a single param in a TupleType
rather than the whole TupleType, but this check has been pretty
heuristic and ad hoc so far. Replace with an explicit check to see if
it's possible for exactly one of the parameters in the tuple type can be
bound to a single unlabeled argument.

<rdar://problem/22913570>
2015-12-17 16:58:39 -08:00
Max Moiseev
786e1ea2b1 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-11 15:19:02 -08:00
Maxim Moiseev
2c95bb6d51 BooleanType => Boolean 2015-12-10 14:56:32 -08:00
Frederick Kellison-Linn
0bfba2972e Fix lexer to properly handle single quote strings
Lexer now suggests escaping unescaped double quotes and unescaping escaped single quotes in single quote strings..
2015-12-09 20:09:04 -05:00
Chris Lattner
aad3cf9e10 Factor out structural error diagnostics out to a helper method (allowing
the code to be actually readable since it unnests it greatly), and call it
both before and after argument type validation.  This allows us to capture
many more structural errors than before, leading to much better diagnostics
in a lot of cases.  This also fixes the specific regressions introduced by
96a1e96.
2015-12-07 23:48:29 -08:00
Chris Lattner
96a1e96dea Improve printing of "too few" or "too many" arguments in generic or
overloaded argument list mismatches.  We printed them in simple cases
due to "Failure" detecting them in trivial situations.  Instead of
doing that, let CSDiags do it, which allows us to pick things out of
overload sets and handle the more complex cases well.

This is a progression across the board except for a couple of cases
where we now produce "cannot convert value of type 'whatever' to
expected argument type '(arglist)'", this is a known issue that I'll
fix in a subsequent commit.
2015-12-07 23:09:08 -08:00
Chris Lattner
25e310c46f Add a testcase for a fixed issue, remove a fixme that has been fixed. NFC. 2015-11-17 21:09:25 -08:00
Chris Lattner
4b8ccacf63 Fix <rdar://problem/22243469> QoI: Poor error message with throws, default arguments, & overloads
and probably others.

When we're type-checking a failed ApplyExpr that has an overload set that
prevents getting a specific type to feed into the initial typechecking of
the argument list, ranking can often narrow down the list of candidates
further, to the point where there is only one candidate left or where all
candidates agree that one argument is wrong.

In this case, re-type-check the subexpr with the expected type.  In the case of
rdar://problem/22243469 we now produce:

t.swift:6:11: error: invalid conversion from throwing function of type '() throws -> ()' to non-throwing function type '() -> Void'
  process {
          ^

instead of:

t.swift:6:3: error: cannot invoke 'process' with an argument list of type '(() throws -> ())'
  process {
  ^
t.swift:6:3: note: overloads for 'process' exist with these partially matching parameter lists: (UInt, fn: () -> Void)
  process {
  ^

Which is a heck of a lot less specific.  Similarly, in the testcase from rdar://23550816, instead
of producing:

  takeTwoFuncsWithDefaults { $0 + 1 }
error: cannot invoke 'takeTwoFuncsWithDefaults' with an argument list of type '((Int -> Int)?)'
note: expected an argument list of type '(f1: (Int -> Int)?, f2: (String -> String)?)'

we now produce:
error: cannot convert value of type '_ -> Int' to expected argument type '(String -> String)?'

which is a lot closer to what we want to complain about.
2015-11-17 20:27:47 -08:00
Chris Lattner
85501b436e Remove some weird hacks that added special case behavior for operators. This
code had the effect of squishing the note that printed the overload candidate
set for the operators in question.  While these are not generally helpful given
how many overloads we have of (e.g.) the + operator, it doesn't do us any good
to have special cases like this, because methods can have tons of overloads as
well.
2015-11-15 21:24:57 -08:00
Chris Lattner
2f04cb13f1 Fix <rdar://problem/23550816> QoI: Poor diagnostic in argument list of "print" (varargs related)
When passing a contextual type to a call, if we have a scalar element
initializing a varargs parameter list, we need to use the varargs element type
contextually.  Fixing this improves some confusing diagnostics.
2015-11-15 15:13:21 -08:00
Chris Willmore
a79c1c9bf4 Don't allow conversion from inout argument to Any parameter.
<rdar://problem/23249098>
2015-11-03 19:00:46 -08:00
David Farler
93b6962478 Warn when using 'var' bindings in function parameters
These will no longer be allowed in a future Swift release.

rdar://problem/23172698
2015-11-03 17:24:20 -08:00
Chris Willmore
30af42fda9 Add warning that curried function decl syntax is going away.
<rdar://problem/23111018>
2015-11-02 15:45:11 -08:00
Chris Willmore
6d7d45a0a4 When clearing type data for failure diagnosis, reset the lvalue access kind too.
That way, re-typechecking doesn't complain about the lvalue access kind
bit already having been set.

<rdar://problem/23185177> Compiler crashes in Assertion failed: ((AllowOverwrite || !E->hasLValueAccessKind()) && "l-value access kind has already been set"), function visit

Swift SVN r32854
2015-10-24 00:44:23 +00:00
Chris Willmore
4b8a5cf894 Lex single-quote string literals but emit an error if they're encountered.
Emit a fix-it replacing them with double-quote string literals.

<rdar://problem/21950709> QoI: Parse single-quoted literals like double-quoted literals

Swift SVN r31973
2015-09-15 22:24:18 +00:00
Chris Lattner
96eaa14f3b Fix an arbitrary restriction where we would not propagate the result type of
call expression onto a callee when it was a binary expression.  Doing this
requires improving the diagnostics for when the contextual result type is
incompatible with all candidates, but that is general goodness all around.

This fixes:
<rdar://problem/22333090> QoI: Propagate contextual information in a call to operands

and improves a number of diagnostics where the problem is that an operator
is used in a context that expects a type that it cannot produce.



Swift SVN r31891
2015-09-11 06:12:05 +00:00
Chris Lattner
72c5c3e4fe Two changes:
- Enhance the branch new argument label overload diagnostic to just
   print the argument labels that are the problem, instead of printing
   the types inferred at the argument context.  This can lead to confusion
   particularly when an argument label is missing.  For example before:

error: argument labels '(Int)' do not match any available overloads
note: overloads for 'TestOverloadSets.init' exist with these partially matching parameter lists: (a: Z0), (value: Int), (value: Double)

after:

error: argument labels '(_:)' do not match any available overloads
note: overloads for 'TestOverloadSets.init' exist with these partially matching parameter lists: (a: Z0), (value: Int), (value: Double)


Second, fix <rdar://problem/22451001> QoI: incorrect diagnostic when argument to print has the wrong type
by specifically diagnosing the problem when you pass in an argument to a nullary function.  Before:

error: cannot convert value of type 'Int' to expected argument type '()'

after:
error: argument passed to call that takes no arguments
print(r22451001(5))
                ^




Swift SVN r31795
2015-09-09 00:26:37 +00:00