Commit Graph

41 Commits

Author SHA1 Message Date
Keith Smiley
f5fbee2f26 Fix indexing constructors with generic parameters (#65597)
Previously in the case of a constructor like `A<Int>(value: 1)`
`Fn->getLoc()` returned the location of `>(value: 1)` while the actual
location we're looking for is correctly the start of `A<Int>(value: 1)`.
This adjusts the location we're looking up to use the start location of
the constructor instead.

Fixes: https://github.com/apple/swift/issues/54532
2023-05-05 15:20:07 -07:00
Slava Pestov
ea4884725d AST: WhereClauseOwner never visit the obsolete 'where' clause inside a GenericParamList
Otherwise, we'll end up visiting it twice in InferredGenericSignatureRequest.
The GSB uniques requirements seen this way, whereas the Requirement Machine
does not, leading to redundant requirement diagnostics.
2022-04-01 13:54:42 -04:00
Ben Barham
f6db91e3f9 [SourceKit] Ignore references without a location
A keypath using dynamic member lookup results in various `KeyPathExpr`
that have components with no location. Ignore these and any other
references that have a missing location.

Resolves rdar://85237365
2021-11-10 14:52:46 +10:00
Pavel Yaskevich
9526d6f90e [IDE] NFC: Fix test-case which now diagnoses correctly
Behavior changed when it became possible to omit `return` in
single expression functions but it hasn't been diagnosed correctly.
2019-08-13 11:55:08 -07:00
Ben Langmuir
effab8c522 Handle dynamic member lookup in annotation and cursor info
Ensure the various entity walkers handle the implicit subscript
reference correctly (usually by ignoring it) and fall through to the
underlying declarations.

rdar://49028895
2019-04-16 15:37:32 -07:00
Pavel Yaskevich
c2bf3d5ba9 [TypeChecker] NFC: Fix all of the diagnostics improved by conformance tracking 2018-08-02 21:55:16 -07:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Argyrios Kyrtzidis
5c46ed06c6 [IDE] Fix assertion hit when a function call has no argument labels.
rdar://27611931.
2016-08-01 10:20:07 -07:00
Argyrios Kyrtzidis
05d495116d [IDE/test] Distinguish a call argument name appropriately for testing. 2016-08-01 10:20:07 -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
gregomni
78216b2990 Change all remaining tests that use typealias in a protocol to use associatedtype. 2016-03-09 18:08:52 -08:00
practicalswift
9eb2ee0638 [gardening] Fix accidental double spaces 2016-02-14 17:30:44 +01:00
John McCall
1f3b3142b4 Distinguish conformance and superclass generic requirements.
As part of this, use a different enum for parsed generic requirements.

NFC except that I noticed that ASTWalker wasn't visiting the second
type in a conformance constraint; fixing this seems to have no effect
beyond producing better IDE annotations.
2016-01-11 16:07:37 -08:00
Xi Ge
264e91d3c4 [SourceKit] Allow SourceEntityWalker to visit generic type parameters of type decls.
This unlocks SourceKit's "find related identifiers" request on generic type params. rdar://22356526
2015-12-03 15:12:16 -08:00
Doug Gregor
7ba3cd27a9 Stop setting a bound type on top-level IdentTypeReprs.
Swift SVN r32432
2015-10-04 06:18:23 +00:00
Doug Gregor
6af6048c0c AST printing: take more care to only escape 'Self' when needed.
Cleans up AST printing somewhat as well as providing slightly better
type-to-declaration mappings for annotated AST printing and indexing.

Swift SVN r32420
2015-10-03 05:13:52 +00:00
Argyrios Kyrtzidis
012f6cb083 [IDE] Make sure to process the body of a defer statement properly.
Fixes IDE features (except code-completion) not working inside 'defer'.
rdar://22849414.

Swift SVN r32254
2015-09-26 00:50:39 +00:00
Argyrios Kyrtzidis
84e27fa26d [IDE] Properly annotate subscript brackets as references to subscript decls and enable jump-to-definition for them.
rdar://22099838

Swift SVN r30910
2015-08-01 05:36:13 +00:00
Xi Ge
57489ceb0f [SyntaxHighlighting] Give ASTWalker the option to walk into generic params of function decls.
Therefore, generic params can also benefit from syntax highlighting and semantic annotation
in SourceKit. rdar://20529255

Swift SVN r30220
2015-07-15 18:28:09 +00:00
Chris Lattner
107282297f two changes:
1) Teach resolveImmutableBase about SubscriptExprs that have 
resolved the decl that they are referring to.  This fixes case where we'd
generate an imprecise diagnostic because we weren't able to find the
result in the ResolvedOverloadSet list (which is because CSApply rewrite
it to a different expr node and the locator can't find it).

2) Change FailureDiagnosis::typeCheckIndependentSubExpression to have a
   blacklist of expressions that aren't recursed into, along with rationale
   for each node kind, instead of a short white list.  This produces more
   predictable results, e.g. producing the right diagnostic in 
   ClangModules/objc_parse.swift



Swift SVN r30118
2015-07-11 21:40:18 +00:00
Devin Coughlin
c67ac0d63b [Sema] Add source location for synthesized designated initializer overrides.
When synthesizing designated initializer overrides, set the source location
for the synthesized ConstructorDecl to the location of the opening brace of
the containing ClassDecl. This resolves an assertion failure when constructing
type refinement contexts when whole-program optimization is turned on.

rdar://problem/21233342

Swift SVN r29384
2015-06-15 19:46:09 +00:00
Ben Langmuir
c5fbbc0d38 [SourceEntityWalker] Pass module DeclRef through visitModuleReference
This returns to the behaviour we had before ModuleDecl came about.  It
fixes an assertion in SourceKit concerning the kinds of decls we will
visit in visitDeclReference. As the comments indicate, we need this
special case until Swift supports first class submodules.

Swift SVN r28934
2015-05-22 21:17:09 +00:00
Argyrios Kyrtzidis
a6f143b87e [AST] Add AST walking for the TypeLoc of IsPattern.
Fixes rdar://21032179

Swift SVN r28822
2015-05-20 04:06:38 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
Argyrios Kyrtzidis
68bd67fc12 [Parse/AST] Introduce an AST node for editor placeholders in expression contexts.
If the placeholder is a typed one, parse its type string into a TypeRepr,
resolve it during typechecking and set it as the type for the associated EditorPlaceholderExpr.

Swift SVN r26215
2015-03-17 01:53:02 +00:00
Argyrios Kyrtzidis
944e20949a [AST/IDE] Use TypeReprs to keep track of the type components in an ExtensionDecl.
This allows preserving type info and proper annotation of the extension's type components.

Swift SVN r25309
2015-02-16 08:36:16 +00:00
Joe Pamer
e452c87edb If an expression fails to type check because one of its sub-expressions is a failed call expression, make sure that the inner call expression's diagnostic is surfaced. Doing so address rdar://problem/19419422, rdar://problem/19437880 and rdar://problem/19559649.
Swift SVN r24935
2015-02-04 02:03:41 +00:00
Denis Vnukov
844fe7dd77 Fix for rdar://19614869, Fuzzing Swift: AnnotAndDiagASTConsumer crashes in SemaAnnotator::walkToDeclPost(...): Assertion failed: "lazy var not implicitly computed"
Minor: modified assertion to handle invalid getters.



Swift SVN r24896
2015-02-02 19:09:51 +00:00
Doug Gregor
2bf69a0ea0 Require witnesses for @objc requirements to be @objc.
Previously, we attempted to infer @objc-ness based on conformance, but
doing so is fraught with ordering dependencies, and just doesn't work
in the general case. Among other crimes, this allowed us to
retroactively mark a non-@objc method from an imported module as
@objc... even though nobody would ever then emit the @objc entry
points for it.

Fixes the rest of rdar://problem/18383574.

Swift SVN r24831
2015-01-29 22:53:53 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Doug Gregor
8cf718f9f6 Don't allow a generic parameter with a non-@objc protocol requirement to bind to an existential.
We don't properly open up the existential to make this work, which
leads to an IRGen crash. Reject the uses of generics that would cause
such a crash rdar://problem/17491663.


Swift SVN r21946
2014-09-15 17:36:26 +00:00
Argyrios Kyrtzidis
7049168e4b [IDE] Annotate the explicit result type of a closure.
Swift SVN r21808
2014-09-09 16:53:33 +00:00
Doug Gregor
e9037bcfa7 Default swift-ide-test to -implicit-objc-with like the rest of the world.
We require some level of consistency between the way the overlays were
built and what we work with in our mock SDK. The IDE/sdk_sugar.swift
test failure was because the overlay referenced "init(coder:)" while
the test was looking for "init(withCoder:)". Hilarity ensued
<rdar://problem/17791048>.

This only impacts testing.

Swift SVN r20564
2014-07-25 22:13:43 +00:00
Ben Langmuir
2113e3a592 Walk through the initializer for a lazy property in SourceEntityWalker
@lazy foo: Int = {
  // Required for syntax highlighting and quick help here.
}()

Swift SVN r20078
2014-07-17 06:43:02 +00:00
Ben Langmuir
09f465ee64 Don't print sugar or generic parameters in extensions
Before:
extension [T] : P { }
extension Foo<T> : P { }

After:
extension Array : P { }
extension Foo : P { }

<rdar://problem/16613904>

Swift SVN r20057
2014-07-16 22:55:48 +00:00
Chris Lattner
4dd6c6ee2c fix a use of the old range syntax.
Swift SVN r19925
2014-07-14 14:27:57 +00:00
Ted Kremenek
9eea282719 Switch range operators ".." and "...".
- 1..3 now means 1,2
- 1...3 now means 1,2,3

Implements <rdar://problem/16839891>

Swift SVN r18066
2014-05-14 07:36:00 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Argyrios Kyrtzidis
0fe6d45e62 [IDE] Introduce semantic annotation functionality and test.
Swift SVN r8618
2013-09-25 01:35:36 +00:00