Commit Graph

11880 Commits

Author SHA1 Message Date
Xi Ge
75abee8f45 ModuleInterface: skip override keywords when overriding an invisible decl from super class
When we are printing Swift interface, we have to skip the override keyword
if the overriden decl is invisible from the interface. Otherwise, an error
will occur while building the Swift module because the overriding decl
doesn't override anything.

We couldn't skip every `override` keywords because they change the
ABI if the overriden decl is also publicly visible.

For public-override-internal case, having `override` doesn't have ABI
implication. Thus we can skip them.

rdar://58562780
2020-03-19 11:47:54 -07:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Nathan Hawes
fd82d87db0 Merge pull request #30402 from nathawes/cross-import-code-completion
[IDE/CodeCompletion] Add code completion support for cross import overlays.
2020-03-18 18:16:03 -07:00
Pavel Yaskevich
2d6170b847 [TypeChecker] Requestify check to determine if closure has explicit result
Determine whether closure body has any explicit `return`
statements which could produce a non-void result.
2020-03-18 17:06:15 -07:00
Joe Groff
72b13e8c65 IRGen: Add a flag to disable mangled name type metadata accessors.
Useful as a workaround for runtime demangler bugs, or in rare cases where there are
performance problems with the demangler.
2020-03-18 13:55:01 -07:00
Nathan Hawes
63636100be [IDE/CodeCompletion] Add code completion support for cross import overlays.
If a cross-import overlay shadows another module and has a name starting with
'_', don't present that overlay in places where module name completions are
offered and present symbols comining from that module as if they came from
the shadowed module instead.

Resolves rdar://problem/59445688
2020-03-18 12:02:20 -07:00
swift-ci
270f734403 Merge pull request #30435 from zoecarver/fix/builtin-is-dead 2020-03-17 20:48:59 -07:00
zoecarver
8f1594685f Polymorphic builtins should have empy attributes 2020-03-17 15:17:10 -07:00
swift-ci
3fa4840561 Merge pull request #30395 from brentdax/two-revisions-for-two-revisions-for-slashing 2020-03-17 14:11:02 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Robert Widmann
ecb58a12d7 Merge pull request #30439 from CodaFi/swift-is-an-untyped-languge-now-i-dont-make-the-rules
[NFC] Break TypeChecker Down Into a Namespace
2020-03-16 21:17:45 -07:00
Robert Widmann
70b6bbcb13 Remove swift::createTypeChecker
Replace it with the "legacy semantic queries" bit. The remaining client
of this bit is SourceKit, which appears to require this bit be set
conditionally so certain semantic property wrapper requests return
a sentinel value.

We should migrate these requests to a syntactic interface as soon as
possible.

rdar://60516325
2020-03-16 19:20:22 -07:00
Robert Widmann
14c073ba0b Remove friend references to TypeChecker
TypeChecker has no friends
2020-03-16 19:19:02 -07:00
Robert Widmann
4be0e4a2bd Strip Forward-Declararations of TypeChecker 2020-03-16 19:19:02 -07:00
Robert Widmann
c3c490efb0 Remove the ability to reference instances of TypeChecker 2020-03-16 19:19:02 -07:00
Robert Widmann
52c808648f Move the defined functions list onto SourceFile 2020-03-16 19:19:01 -07:00
Robert Widmann
52f4aba784 IRGen Requests
Implement the IRGen Request infrastructure and provide the first
request: generating IR from a given SourceFile.
2020-03-16 18:00:33 -07:00
Robert Widmann
3f7c89ae9c Correct diagnostic for plain member constraints
This used to print as just a plain space.

Resolves rdar://60030114
2020-03-16 11:22:18 -07:00
Anthony Latsis
d688710fb3 [Diag] Move invalid where clause on top-level decl diagnostic to Sema 2020-03-15 13:38:49 +03:00
Pavel Yaskevich
5bb2a62b70 Merge pull request #30409 from HassanElDesouky/SR-12309
[CSGen] Force unwrapping 'nil' compiles without warning
2020-03-14 11:41:02 -07:00
Brent Royal-Gordon
5b7a13cf69 Merge pull request #30410 from brentdax/futures-end
Improve diagnostic for broken module interfaces
2020-03-14 01:25:58 -07:00
Brent Royal-Gordon
a7a5e340aa Improve diagnostic for broken module interfaces
Currently, when a swiftinterface file fails to load, we emit the specific diagnostics for the failures, followed by a generic “failed to load module ‘Foo’” message. This PR improves that final diagnostic, particularly when the cause may be that the interface was emitted by a newer compiler using backwards-incompatible syntax.
2020-03-13 20:31:55 -07:00
HassanElDesouky
8195cce1d3 [SR-12309] Cannot force unwrap 'nil' 2020-03-14 01:28:28 +02:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Nathan Hawes
fcf95eae16 Merge pull request #30187 from nathawes/indentation
[SourceKit/CodeFormat] Re-work and improve the indentation implementation
2020-03-13 08:01:29 -07:00
Brent Royal-Gordon
0be8357dcc Merge pull request #29950 from brentdax/less-crossover
Make cross-importing faster
2020-03-13 01:45:02 -07:00
Brent Royal-Gordon
b65a9c6db1 [NFC] Doc and style fixes for #filePath implementation
This addresses some late-breaking review comments left by @hamishknight on apple/swift#29412.
2020-03-12 18:12:09 -07:00
Dmitri Gribenko
be80642fe8 Removed a catch-all default implementation of ASTVisitor::visitTypeRepr
Other AST nodes don't have such functionality now, and it was removed
from them previously. Not having a default implementation means that
users of ASTVisitor have to either explicitly write a catch-all default,
or handle all cases. Making this decision consciously is a good
practice.
2020-03-12 11:29:11 +01:00
Doug Gregor
a3979da1cd Merge pull request #30322 from DougGregor/function-builders-extras
[Function builders] Additional entry points
2020-03-11 16:17:27 -07:00
Nathan Hawes
a368434432 [SourceKit/CodeFormat] Re-work and improve the indentation implementation.
This restructures the indentation logic around producing a single IndentContext
for the line being indented. An IndentContext has:
- a ContextLoc, which points to a source location to indent relative to,
- a Kind, indicating whether we should align with that location exactly, or
  with the start of the content on its containing line, and
- an IndentLevel with the relative number of levels to indent by.

It also improves the handling of:
- chained and nested parens, braces, square brackets and angle brackets, and
  how those interact with the exact alignment of parameters, call arguments,
  and tuple, array and dictionary elements.
- Indenting to the correct level after an incomplete expression, statement or
  decl.

Resolves:
rdar://problem/59135010
rdar://problem/25519439
rdar://problem/50137394
rdar://problem/48410444
rdar://problem/48643521
rdar://problem/42171947
rdar://problem/40130724
rdar://problem/41405163
rdar://problem/39367027
rdar://problem/36332430
rdar://problem/34464828
rdar://problem/33113738
rdar://problem/32314354
rdar://problem/30106520
rdar://problem/29773848
rdar://problem/27301544
rdar://problem/27776466
rdar://problem/27230819
rdar://problem/25490868
rdar://problem/23482354
rdar://problem/20193017
rdar://problem/47117735
rdar://problem/55950781
rdar://problem/55939440
rdar://problem/53247352
rdar://problem/54326612
rdar://problem/53131527
rdar://problem/48399673
rdar://problem/51361639
rdar://problem/58285950
rdar://problem/58286076
rdar://problem/53828204
rdar://problem/58286182
rdar://problem/58504167
rdar://problem/58286327
rdar://problem/53828026
rdar://problem/57623821
rdar://problem/56965360
rdar://problem/54470937
rdar://problem/55580761
rdar://problem/46928002
rdar://problem/35807378
rdar://problem/39397252
rdar://problem/26692035
rdar://problem/33760223
rdar://problem/48934744
rdar://problem/43315903
rdar://problem/24630624
2020-03-10 21:04:21 -07:00
swift-ci
8e39711b35 Merge pull request #30338 from ravikandhadai/oslog-crash-in-unreachable-code 2020-03-10 17:50:48 -07:00
Ravi Kandhadai
020c8281c2 [OSLogOptimization] Prevent the OSLogOptimization pass from crashing
when the log calls are invoked in unreachable code.

<rdar://problem/60014600>
2020-03-10 15:48:56 -07:00
Owen Voorhees
72fba7db8a Merge pull request #30153 from owenv/protocol-can-only-be-used-as-a-constraint-because-it-has-self-or-associated-type-requirements-oh-no
[Diagnostics] Add edu note explaining limitations of protocols with assoc. type reqs.
2020-03-10 14:48:39 -07:00
Pavel Yaskevich
aa35a500a8 Merge pull request #30328 from apple/revert-30164-fix/SR-12290
Revert "[Typechecker] Diagnose key paths with contextual root type but no leading dot"
2020-03-10 11:00:24 -07:00
John McCall
81ba9fd223 Merge pull request #30309 from rjmccall/accessor-subst-function-types
Use pattern substitutions to consistently abstract yields
2020-03-10 13:05:28 -04:00
Pavel Yaskevich
e86558fe4f Merge pull request #30277 from LucianoPAlmeida/SR-12019-dynamically-call-generic-constraint
[SR-12019] Fix assert when dynamicallyCall parameter does not satisfy generic constraint
2020-03-10 09:12:33 -07:00
Pavel Yaskevich
2374502a04 Revert "[Typechecker] Diagnose key paths with contextual type but no leading dot (#30164)"
This reverts commit 13487edd09.
2020-03-10 09:06:50 -07:00
John McCall
07f03bd287 Use pattern substitutions to consistently abstract yields.
The design implemented in this patch is that we lower the types of accessors with pattern substitutions when lowering them against a different accessor, which happens with class overrides and protocol witnesses, and that we introduce pattern substitutions when substituting into a non-patterned coroutine type.  This seems to achieve consistent abstraction without introduce a ton of new complexity.

An earlier version of this patch tried to define witness thunks (conservatively, just for accessors) by simply applying the requirement substitutions directly to the requirement.  Conceptually that should work, but I ran into a lot of trouble with things that assumed that pattern substitutions didn't conceal significant substitution work.  for example, resolving a dependent member in a component type could find a new use of an opaque archetype when the code assumed that such types had already been substituted away.  So while I think that is definiteely a promising direction, I had to back that out in order to make the number of changes manageable for a single PR.

As part of this, I had to fix a number of little bugs here and there, some of which I just introduced.  One of these bugfixes is a place where the substitution code was trying to improperly abstract function types when substituting them in for a type parameter, and it's been in the code for a really long time, and I'm really not sure how it's never blown up before.

I'm increasingly of the opinion that invocation substitutions are not actually necessary, but that --- after we've solved the substitution issues above --- we may want the ability to build multiple levels of pattern substitution so that we can guarantee that e.g. witness thunks always have the exact component structure of the requirement before a certain level of substitution, thus allowing the witness substitutions to be easily extracted.
2020-03-10 01:26:31 -04:00
Doug Gregor
f0530d0a77 [Function builders] Support buildOptional(_:) in lieu of buildIf(_:).
Line up with the function builders pitch, which uses buildOptional(_:)
to build optional values.
2020-03-09 21:48:15 -07:00
John McCall
bac7e6b07b Add some helpers to the SILFunctionType component types. 2020-03-09 22:13:36 -04:00
Owen Voorhees
16e84e3c1c [Diagnostics] Add edu note explaining limitations of protocols with associated type requirements 2020-03-09 15:55:54 -07:00
Doug Gregor
ce97d22f21 [Function builders] Add support for buildFinalResult().
When present in a function builder, buildFinalResult() will be called on
the value of the outermost block to form the final result of the closure.
This allows one to collapse the full function builder computation into
a single result without having to do it in each buildBlock() call.
2020-03-09 00:10:07 -07:00
Hassan El Desouky
d0b6d9f2c1 Improve diagnostic for read-only properties
Make the message within 80 columns width
Improve diagnostic for read-only properties
Improve diagnostic for read-only properties
Improve diagnostic for read-only properties
2020-03-09 04:48:54 +02:00
Luciano Almeida
f796e27b65 [TypeChecker] Requestify DynamicCallableAttribute check 2020-03-08 20:44:23 -03:00
Kuba (Brecka) Mracek
b2edf20a81 Merge pull request #30112 from apple/mracek/arm64e
Add arm64e and pointer authentication support for Swift
2020-03-07 20:38:36 -08:00
John McCall
ceff414820 Distinguish invocation and pattern substitutions on SILFunctionType.
In order to allow this, I've had to rework the syntax of substituted function types; what was previously spelled `<T> in () -> T for <X>` is now spelled `@substituted <T> () -> T for <X>`.  I think this is a nice improvement for readability, but it did require me to churn a lot of test cases.

Distinguishing the substitutions has two chief advantages over the existing representation.  First, the semantics seem quite a bit clearer at use points; the `implicit` bit was very subtle and not always obvious how to use.  More importantly, it allows the expression of generic function types that must satisfy a particular generic abstraction pattern, which was otherwise impossible to express.

As an example of the latter, consider the following protocol conformance:

```
protocol P { func foo() }
struct A<T> : P { func foo() {} }
```

The lowered signature of `P.foo` is `<Self: P> (@in_guaranteed Self) -> ()`.  Without this change, the lowered signature of `A.foo`'s witness would be `<T> (@in_guaranteed A<T>) -> ()`, which does not preserve information about the conformance substitution in any useful way.  With this change, the lowered signature of this witness could be `<T> @substituted <Self: P> (@in_guaranteed Self) -> () for <A<T>>`, which nicely preserves the exact substitutions which relate the witness to the requirement.

When we adopt this, it will both obviate the need for the special witness-table conformance field in SILFunctionType and make it far simpler for the SILOptimizer to devirtualize witness methods.  This patch does not actually take that step, however; it merely makes it possible to do so.

As another piece of unfinished business, while `SILFunctionType::substGenericArgs()` conceptually ought to simply set the given substitutions as the invocation substitutions, that would disturb a number of places that expect that method to produce an unsubstituted type.  This patch only set invocation arguments when the generic type is a substituted type, which we currently never produce in type-lowering.

My plan is to start by producing substituted function types for accessors.  Accessors are an important case because the coroutine continuation function is essentially an implicit component of the function type which the current substitution rules simply erase the intended abstraction of.  They're also used in narrower ways that should exercise less of the optimizer.
2020-03-07 16:25:59 -05:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08:00
Slava Pestov
adbf8da7c2 Merge pull request #23489 from AnthonyLatsis/where-clause-nongeneric-decl
[SE] Allow where clauses on non-generic declarations in generic contexts
2020-03-06 17:53:14 -05:00
Joe Groff
58950a576a Merge pull request #30250 from jckarter/mangle-objc-runtime-names
IRGen: Generate runtime type manglings using ObjC runtime names.
2020-03-06 07:33:19 -08:00