Commit Graph

510 Commits

Author SHA1 Message Date
Chris Lattner
a230d402d2 simplify some code to eliminate unnecessary tests, NFC. 2016-01-20 18:08:29 -08:00
Chris Lattner
5957a9274e Reapply Simplify resolveLocatorToDecl to return a ConcreteDeclRef instead of
having it return a ResolvedLocator, allowing us to remove ResolvedLocator

The previous commit accidentally dropped the hunk in CSApply.cpp.  NFC.
2016-01-20 18:08:29 -08:00
Doug Gregor
fd3f03f3be Remove UnresolvedConstructorExpr.
UnresolvedConstructorExpr is not providing any value here; it's
essentially just UnresolvedDotExpr where the name refers to an
initializer, so use that instead. NFC
2016-01-20 17:09:02 -08:00
Doug Gregor
5f07f6b12f Remove all vestiges of UnresolvedSelectorExpr. NFC 2016-01-20 17:09:01 -08:00
Doug Gregor
ecfde0e71c Start parsing names with argument labels.
Basic implementatation of SE-0021, naming functions with argument
labels. Handle parsing of compound function names in various
unqualified-identifier productions, updating the AST representation of
various expressions from Identifiers to DeclNames. The result doesn't
capture all of the source locations we want; more on that later.

As part of this, remove the parsing code for the "selector-style"
method names, since we now have a replacement. The feature was never
publicized and doesn't make sense in Swift, so zap it outright.
2016-01-20 17:09:01 -08:00
Max Moiseev
9a018bd77d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-20 14:38:22 -08:00
Mark Lacey
061c7776d8 Revert "Simplify resolveLocatorToDecl to return a ConcreteDeclRef instead of"
This reverts commit 5ce503c886 because it
breaks the stdlib build with:
  Assertion failed: (!isPolymorphic() && "no args for polymorphic substitution"), function substGenericArgs
2016-01-20 13:23:04 -08:00
Chris Lattner
5ce503c886 Simplify resolveLocatorToDecl to return a ConcreteDeclRef instead of
having it return a ResolvedLocator, allowing us to remove ResolvedLocator.
2016-01-20 10:57:33 -08:00
Chris Lattner
69ba5bc876 Remove shouldDiscardFailures() from ConstraintLocator,
remove shouldRecordFailures() from ConstraintSystem.  NFC.
2016-01-20 10:38:37 -08:00
Chris Lattner
a1112b3c7d Remove Failure and some of the supporting infrastructure. NFC. 2016-01-20 10:28:21 -08:00
Doug Gregor
7d70b704e4 Merge commit '5e11e3f7287427d386636a169c4065c0373931a8' into swift-3-api-guidelines 2016-01-19 23:18:20 -08:00
Chris Lattner
4341ef35cd Move CalleeCandidateInfo to using NameLookupFlags::IgnoreAccessibility
for initializer lookup, allowing it to produce more specific diagnostics
when referring to a private initializer that the compiler can see.

In addition to improving diagnostics, this allows us to eliminate the
NoPublicInitializers failure kind.
2016-01-19 22:52:26 -08:00
Chris Lattner
5a4464fbca Fix <rdar://19935319> QoI: poor diagnostic initializing a variable with a non-class func
It is a common point of confusion that property initializers cannot access self, so
produce a tailored diagnostic for it.

Also, when building implicit TypeExprs for the self type, properly mark them implicit.
2016-01-18 22:37:22 -08:00
Doug Gregor
c4a6902589 Abstract the set of known Foundation entities into a .def-driven enum. NFC
Specifically, we don't want to hard-code the Swift names of these
Objective-C entities, because the importer renaming will affect them.
2016-01-17 23:40:14 -08:00
Chris Lattner
8a41d14b2d Fix <rdar://problem/21429694> QoI: diagnostic for accessing private methods could be improved
When member lookup completely fails and when CSDiags is the one performing
the lookup, reissue another lookup that ignores access control.  This allows
it to find inaccessible members and diagnose them as such, instead of pretending
we have no idea what the user wants.  We now produce an error message like this:

main.swift:1:6: error: 'foo' is inaccessible due to 'private' protection level
 C().foo()
     ^
test.swift:1:35: note: 'foo' declared here
  internal class C { private func foo() {} }
                                  ^

instead of:

main.swift:1:2: error: value of type 'C' has no member 'foo'
 C().foo()
 ^~~ ~~~
2016-01-17 17:13:07 -08:00
Chris Lattner
849ec50a12 Fix <rdar://problem/21269142> Diagnostic should say why enum has no .rawValue member
If someone is trying to refer to the rawValue of an enum that has no
raw type, give them a hint that they need to go do that.
2016-01-17 15:35:22 -08:00
Chris Lattner
85231a20ed Merge pull request #943 from practicalswift/typo-fixes-20160112
[gardening] Fix recently introduced typos
2016-01-11 23:17:15 -08:00
practicalswift
ec113a35b4 Fix recently introduced typos. 2016-01-12 07:45:50 +01:00
Chris Lattner
4a22cfe07a enhance diagnoseGeneralConversionFailure to handle conversions between tuple
types with mismatched labels better, even if the element types cannot be
resolved.
2016-01-11 22:20:19 -08:00
Chris Lattner
a5a988e726 Fix rdar://22509125 QoI: Error when unable to infer generic archetype lacks greatness
Rearrange diagnoseGeneralConversionFailure to diagnose structural problems
even if we have some UnresolvedTypes floating around, then reject constraint
failures with UnresolvedTypes in them even harder.  This keeps us giving
good errors about failures where we have a structural problem (with buried
irrelevant details) while not complaining about cases that are actually
ambiguous.

The end result of this is that we produce a lot better error messages in the
case of failed archetype inference.  This also highlights the poor job we do
handling multi-stmt closureexprs...
2016-01-11 20:45:11 -08:00
Chris Lattner
3085094441 fix <rdar://problem/23942743> [QoI] Bad diagnostic when errors inside enum constructor
On something like this:
  let x = .Tomato(cloud: .None)

we previously emitted a "type of expression is ambiguous without more context" error
while pointing to .None.  With a previous fix, we now produce the same error pointing
to the .Tomato.  With this fix, we now produce:

error: reference to member 'Tomato' cannot be resolved without a contextual type

to really drive the problem home.
2016-01-11 19:37:12 -08:00
Chris Lattner
26b51bfaee Fix rdar://19710848 QoI: Friendlier error message for "[] as Set"
This makes diagnoseGeneralConversionFailure more conservative: it
now never diagnoses a failed conversion when it involves a type that
has unresolved type in it.  These types could not be resolved, so it
is better to let ambiguity resolution handle the problem.

On "[] as Set", we would previously get:
  error: 'Set<_>' is not convertible to 'Set<Element>'
now we get:
  error: generic parameter 'Element' could not be inferred
2016-01-11 19:19:06 -08:00
Chris Lattner
b5500b8600 Generalize the conditions in which we'll accept an ambiguous solution to
a constraint system in "allowFreeTypeVariables" mode.  Previously, we
only allowed a few specific constraints, now we allow any relational and
member constraints.  The later one is a big deal because it means that we
can allow ".Foo" expressions as ambiguous solutions, which CSDiags can
handle well.

This unblocks solving 23942743 and enables some minor improvements across
the board, including diagnosing things like this better:
  Optional(.none)  // now: generic parameter 'T' could not be inferred

That said, it also just permutes some non-awesome diagnostics.
2016-01-11 17:04:46 -08:00
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -08:00
Chris Lattner
d9b2fe601b fix a compiler crash in error recovery that @practicalswift just reported. 2016-01-09 20:17:56 -08:00
Chris Lattner
675ca03b12 fix a compiler crasher that practicalswift recently found. 2016-01-08 23:03:18 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
Chris Lattner
3f19714479 James Campbell pointed out on swift-evolution that the [:] literal syntax
for dictionaries is non-discoverable.  Fix that by having the compiler
suggest a fixit hint to rewrite [] in a dictionary context to [:].
2016-01-05 10:57:39 -08:00
Mark Lacey
3c614922e5 Revert "Rework the interface to coerceParameterListToType to make it obvious"
This reverts commit 420bedaae1 because it
appears to have unintentionally made some previously accepted code
involving casts of variadic parameters to closures no longer compile.
2016-01-04 19:24:06 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Chris Lattner
420bedaae1 Rework the interface to coerceParameterListToType to make it obvious
that it is specific to ClosureExprs.  Also, consolidate some logic
in CSDiags into the now shared coerceParameterListToType, which
makes a bit more sense and simplifies things a lot.  NFC.

There are still unanswered questions.  It isn't clear to me why
we support API names on closures, when we don't implement proper
semantic analysis for them. This seems like an accidentally supported
feature that should be removed.
2016-01-03 19:24:25 -08:00
Chris Lattner
3c1965ef4c Merge the AST walker for "ExprTypeSaver" and "TypeNullifier" into a single
AST walk that saves the types, then nukes them.  This saves a pass over the
AST and makes sure the two walks stay in sync.  NFC.
2016-01-03 16:18:50 -08:00
Chris Lattner
6afe77d597 Eliminate the Parameter type completely - now ParameterList is just
an overblown array of ParamDecl*'s that also keeps track of parenlocs
and has helper methods.
2016-01-03 14:45:38 -08:00
Chris Lattner
2af78aede1 forward declare ASTWalker in ASTNode.h instead of including its header, NFC. 2015-12-31 21:05:13 -08:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
021a186c23 Fix typos. 2015-12-28 18:30:15 +01:00
practicalswift
fd70b26033 Fix typos in comments. 2015-12-28 02:15:34 +01:00
practicalswift
fa0b339a21 Fix typos. 2015-12-26 17:51:59 +01:00
Chris Lattner
5d6c20b0b6 fix 058-swift-constraints-constraintsystem-diagnosefailureforexpr.swift
CSDiag's wasn't considering the case when an operator was invalid and had ErrorType.
2015-12-23 17:28:08 -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
2bfb788ef2 remove the logic for upgrading Swift 1's print that used "appendNewline"
to Swift 2 syntax that uses "terminator".  It is legacy, and removing it
allows simplifications.
2015-12-22 14:42:18 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
practicalswift
36d7072013 Remove immediately adjacent repeated words ("the the", "for for", "an an", etc.). 2015-12-21 22:16:04 +01:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -08:00
Chris Lattner
eefc5df1bb Fix the major case of <rdar://problem/23641896> QoI: Strings in Swift cannot be indexed directly with integer offsets
This adds special tuned diagnostics to handle the case when someone attempts to index
a string with an integer value, which is pretty common to do for people new to Swift.o
That said, this only handles one special case, if there are other cases that are
common, I'd love to hear about them.  Subscripts are already handled with a different
approach, I'm not sure which is better, but I added a testcase for both of them.
2015-12-17 23:10:46 -08:00
Max Moiseev
3fe0c60d7f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-17 11:00:02 -08:00
Chris Willmore
49a7e5d5ae Improved diagnostic when using object literal without AppKit/UIKit
If you use a color literal without first having imported AppKit or
UIKit, the diagnostic is poor. Instead, recommend importing one of those
two modules as appropriate.
2015-12-16 18:10:17 -08:00
Max Moiseev
806be29941 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-14 12:05:35 -08:00