Commit Graph

14 Commits

Author SHA1 Message Date
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Erik Eckstein
70981cf95f tests: fix misspelled check prefixes
Fix the common error of using underscores instead of dashes.
In the rebranch this is an error (lit got more picky), but it also makes sense to fix the tests in the main branch
2022-11-08 17:27:48 +01:00
Alex Hoppen
5d01a097e1 [CodeCompletion] Don't distinguish convertible and idenical type relation
I think that preferring identical over convertible makes sense in e.g. C++ where we have implicit user-defined type conversions but since we don’t have them in Swift, I think the distinction doesn’t make too much sense, because if we have a `func foo(x: Int?)`, want don’t really want to  prioritize variables of type `Int?` over `Int` Similarly if we have `func foo(x: View)`, we don’t want to prioritize a variable of type `View` over e.g. `Text`.

rdar://91349364
2022-04-13 08:28:17 +02:00
Rintaro Ishizaki
84f0c5723a [CodeCompletion] Calculate type relation when adding type annotation
Calculate and set the type relation in each result building logic which
knows the actual result type.

CodeCompletionResultBuilder couldn't know the actual result type. From
the declaration alone, it cannot know the correct result type because it
doesn't know how the declaration is used (e.g. calling? referencing by
compound name? curried?)
2020-09-16 22:04:50 -07:00
Rintaro Ishizaki
e9c438cdd5 [CodeCompletion] Dont mark type mismatching items 'not recommended'
func foo() {}
let a: Int = #^HERE^#

Previously, we marked 'foo()' as 'NotRecommented' because 'Void' doesn't
have any member hence it cannot be 'Int'. But it wass confusing with
'deprecated'.

Now that we output 'typerelation' which is 'invalid' in this case. So clients
can deprioritize results, or even filter them out.

rdar://problem/57726512
2020-05-05 10:40:05 -07:00
Ben Langmuir
67a0fec06c [test] Remove dead and duplicated check
The check was disabled because of a typo, but was also duplicating a
check two lines above anyway, so remove it.

Credit to David Ungar for spotting it!
2019-07-01 09:56:15 -07:00
Rintaro Ishizaki
c99af83901 [CodeCompletion] Consolidate parameter list processing funcitons
There were 2 functions to output argument list. Consolidate them and
consistently use it from every call like production (i.e. function call,
constructor call, enum with associated values, subscript)
2019-03-05 16:45:48 -08:00
Rintaro Ishizaki
e5d8113eee [CodeCompletion] Pre-remove argument labels from function types
Before checking type relation between candidate types and expected
types. In normal compilation, this removal is done in CSGen. However,
since code-completion directly uses Constraint System, we have to
manually remove argument labels before checking convertibility.

We can remove argument labels unconditionally because function types as
as value cannot have argument labels. (i.e. `let f: (a: Int) -> Int` is
illegal). That means, expected types shouldn't have any argument labels.

This fixes regression revealed in 5e75b1ad3b
rdar://problem/41496748
2018-10-01 17:31:20 +09:00
Slava Pestov
8d4b8e31aa Sema: Remove ScalarToTuple conversion
This either became dead shortly after the removal of Swift 3
compatibility mode from the constraint solver, or even earlier.

Note that the code completion test change is actually correct
because (Any) -> () is not convertible to () -> () in the
language.
2018-08-08 10:18:52 -07:00
Mark Lacey
5e75b1ad3b Remove -swift-version 3 from a handful of tests and update them appropriately.
These are all tests that would otherwise fail if the expression type
checker support for Swift 3 is removed.

I've moved some of the code from deleted Migrator tests into new
Constraints tests that verify that we do not support the constructs.
2018-07-04 20:58:21 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Ben Langmuir
32f131e9ab [code-completion] Handle func-reference syntax for optional expected type
The underlying type-check was correct, but I forgot to consider it in
the outer code, and embarassingly never tested this case.

rdar://problem/28435922
2016-10-28 13:41:45 -07:00
Ben Langmuir
a6934d1e6d [code-completion] Fix type-relation check on implicitly curried instance methods
We strip the first input type on instance methods like,
struct S { func foo(T) -> U } // (S)->(T)->U

but we should not do that when it's actually a curried instance method,
such as S.foo.
2016-10-07 13:55:13 -07:00
Ben Langmuir
d2e2d5fe84 [code-completion] Complete as function reference when the type matches
If we're completing in a context that expects a function type, try to
match methods/functions as function references before trying them as
calls.  This means that

func take(_: (Int)->()) {}
func foo(a: Int) {}
take(#^A^#)  // completes foo(a:)  instead of foo(a: {#value#})

Note: doesn't yet work with generic types.

rdar://problem/28435922
2016-10-05 14:25:38 -07:00