Commit Graph

9699 Commits

Author SHA1 Message Date
Pavel Yaskevich
6754b86507 Merge pull request #22379 from xedin/rdar-47787705
[ConstraintSystem] Detect invalid initializer references early
2019-02-06 17:16:20 -08:00
Xi Ge
a92ea0c256 IDE: print underscored keywords for interface generation
Addressing @airspeedswift's code review feedback.
2019-02-06 14:51:39 -08:00
Xi Ge
c0598b9888 ASTPrinter: add an option to skip keywords with a prefix of underscore.
DocSupport will use set this flag to avoid printing __consuming, __owned, and
__shared.

rdar://47777848
2019-02-06 14:51:39 -08:00
Pavel Yaskevich
9a1e92ec0a [AST] Add getDecl parameter to Expr::isTypeRerefence
So it could be extended to support not yet fully type-checked
AST when used by constraint system solver.
2019-02-05 18:09:51 -08:00
Slava Pestov
cc8236f7d0 AST: ASTMangler should not depend on ASTDemangler
ASTDemangler depends on ClangImporter, etc.
2019-02-05 21:03:33 -05:00
Pavel Yaskevich
1d8cee9cb4 [ConstraintSystem] Detect invalid initializer references early
Currently invalid initializer references are detected and
diagnosed in solution application phase, but that's too
late because solver wouldn't have required information while
attempting to determine the best solution, which might result
in viable solutions being ignored in favour of incorrect ones e.g.

```swift
protocol P {
  init(value: Int)
}

class C {
  init(value: Int, _: String = "") {}
}

func make<T: P & C>(type: T.Type) -> T {
  return T.init(value: 0)
}
```

In this example `init` on `C` would be preferred since it
comes from the concrete type, but reference itself is invalid
because it's an attempt to construct class object using
metatype value via non-required initalizer.

Situations like these should be recognized early and invalid
use like in case of `C.init` should be ranked lower or diagnosed
if that is the only possible solution.

Resolves: rdar://problem/47787705
2019-02-05 10:25:36 -08:00
Robert Widmann
f8a7daa374 [NFC] Silence some Wnewline-eof violations 2019-02-05 12:44:05 -05:00
Slava Pestov
363e47be49 Merge pull request #22260 from slavapestov/round-trip-type-reconstruction
ASTMangler: Verify that debug manglings round-trip
2019-02-05 11:20:41 -05:00
Doug Gregor
de2b75c1c1 Merge pull request #22370 from DougGregor/lazy-known-protocol-kind
[AST] Lazily compute ProtocolDecl::getKnownProtocolKind()
2019-02-05 06:49:42 -08:00
Doug Gregor
cffe92cc8a Merge pull request #22347 from DougGregor/sil-witness-method-self-proto
[SIL] Eliminate SILFunctionType::getDefaultWitnessMethodProtocol().
2019-02-04 22:49:14 -08:00
Doug Gregor
d19d2f2490 [AST] Lazily compute ProtocolDecl::getKnownProtocolKind()
Rather than eagerly doing a bunch of name lookups to establish the known
protocol kind, lazily match the ProtocolDecl to the list of known
protocols as-needed. This eliminates a bunch of up-front unqualified
name lookups when spinning up a type checker.
2019-02-04 21:25:48 -08:00
Slava Pestov
c2029db223 ASTMangler: Verify that debug manglings round-trip
Add an IRGen flag to disable this verification, since it doesn't work from within
lldb itself for some reason, and I don't want to investigate it right now.
2019-02-05 00:07:53 -05:00
Doug Gregor
6609864f4e Drop the ModuleDecl parameter from SILFunctionType::getWitnessMethodClass().
Nothing uses this parameter.
2019-02-04 19:52:16 -08:00
Doug Gregor
2d1fc680ed [SIL] Eliminate SILFunctionType::getDefaultWitnessMethodProtocol().
This method wasn’t returning the protocol on which the that the witness
method would satisfy, as documented. Rather, it was returning the protocol
to which the `Self` type conforms, which could be completely unrelated. For
example, in IndexingIterator’s conformance to IteratorProtocol, this method
would produce the protocol “Collection”, because that’s where the witness
itself was implemented. However, there isn’t necessarily a single such
protocol, so checking for/returning a single protocol was incorrect.

It turns out that there were only a few SIL verifier assertions of it
(that are trivially true) and two actual uses in code:
(1) The devirtualizer was using this computation to decide when it didn’t
need to perform any additional substitutions, but it’s predicate for doing
so was essentially incorrect. Instead, it really wanted to check whether
the Self type is still a type parameter. 
(2) Our polymorphic convention was using it to essentially check whether 
the ’Self’ instance type of a witness_method was a GenericTypeParamType,
which we can check directly.


Fixes rdar://problem/47767506 and possibly the hard-to-reproduce
rdar://problem/47772899.
2019-02-04 16:18:00 -08:00
Slava Pestov
14bbab4d56 Merge pull request #22259 from pschuh/s-3
BooleanLiteralExpr now is lowered directly into SIL.
2019-02-04 18:06:59 -05:00
swift-ci
507783a772 Merge pull request #22344 from compnerd/scalar-size 2019-02-04 14:49:03 -08:00
Brent Royal-Gordon
2bd9eb38d8 Add accessor with potentially unavailable attrs
DeclAttributes::getUnavailable() only cares about attributes which make a declaration definitely unavailable, but you sometimes need a version which will also return a potentially unavailable (i.e. “introduced:”) attribute. This adds that.
2019-02-04 13:53:35 -08:00
Saleem Abdulrasool
210d5836ff AST: remove ScalarTraits<size_t> on Windows
Because `size_t` is the same as `uint64_t` on Windows, this results in a
conflicting definition of the `ScalarTraits`.
2019-02-04 11:59:35 -08:00
Harlan Haskins
48e48f22fe Merge pull request #22302 from harlanhaskins/strings-and-things
[ParseableInterfaces] Re-escape multi-line strings in attribute messages
2019-02-04 10:32:55 -08:00
David Ungar
520b801bf0 Merge pull request #21177 from davidungar/A-exp-dep-graph-12-10-18
First cut at graph-based fine-grained experimental dependencies.
2019-02-03 21:15:17 -08:00
Michael Gottesman
04ec2c86b2 [ownership] Move OME out of the diagnostics pipeline behind a flag.
Once the flag is flipped, ownership stripping will no longer be done in the
diagnostics pipeline. Instead what will happen is that:

* Onone: At -Onone, we run the entire diagnostics pipeline with ownership
enabled and do not strip ownership until after we serialize in the Onone
"optimization" pass pipeline plan.

* -O: At -O, to temporarily work around serialization issues with transparent
functions, we strip ownership from all but transparent functions at the
beginning of the performance pipeline, serialize, and then strip ownership from
transparent functions. For this to work, I needed to make sure that the
performance pipeline passes that do not support ownership SIL, just skip such
functions. So the transparent functions will arrive (mostly) untouched in
serialized SIL and the rest of the pipeline will optimize non-transparent
functions as they should.

The key thing about the -O change is that it /should/ be performance neutral
since after we serialize we re-run the entire pipeline so we can optimize
semantic functions that we only can inline after we serialize.
2019-02-02 22:58:39 -08:00
Parker Schuh
d8bff8ddc9 BooleanLiteralExpr now is lowered directly into SIL.
Instead of constructing calls to ExpressibleByBooleanLiteral.init(booleanLiteral: ...) in CSApply.cpp, just
annotate BooleanLiteralExpr with the selected constructor and do the actual construction during SILGen.

For context, StringLiteralExpr and NilLiteralExpr already behave this way.
2019-01-31 09:56:00 -08:00
David Ungar
7e4a3d2f19 #ifdef out a line that linux requires to be absent. 2019-01-30 21:02:21 -08:00
Pavel Yaskevich
87b66e79a7 Merge pull request #22251 from xedin/change-text-of-fallback-diag
[CSDiagnostics] NFC: Fallback diagnostic shouldn't ask for the project
2019-01-30 17:37:09 -08:00
Harlan Haskins
a61d1f6476 [ParseableInterfaces] Re-escape multi-line strings in attribute messages
Previously, we would print multi-line string literals with single quotes, which were not re-parseable. Instead, re-escape their contents and print them out escaped.
2019-01-30 17:24:48 -08:00
Pavel Yaskevich
52024681e0 [CSDiagnostics] NFC: Fallback diagnostic shouldn't ask for the project 2019-01-30 16:04:44 -08:00
Harlan Haskins
e9d81e1533 Merge pull request #22190 from harlanhaskins/show-me-the-protocol
[ParseableInterfaces] Print @_show_in_interface
2019-01-30 10:58:30 -08:00
Slava Pestov
c14cbe0230 ASTMangler: Add mangleTypeAsUSR()
For now this just duplicates mangleTypeForDebugger(), but the latter's
behavior is going to change.
2019-01-30 01:28:48 -05:00
Slava Pestov
4ab3535948 ASTMangler: Rename mangleTypeAsUSR() to mangleTypeWithoutPrefix() 2019-01-30 01:28:48 -05:00
Slava Pestov
aaf4b88008 AST: Add MangleLocalTypeDeclRequest 2019-01-30 01:28:48 -05:00
Slava Pestov
36d3f47388 ASTDemangler: Preserve generic arguments for bound generic Objective-C classes
MetadataLookup gives special treatment to imported Objective-C classes,
since there's no nominal type descriptor and metadata is obtained
directly by calling into the Objective-C runtime.

Remote reflection also gives special treatment to imported Objective-C
classes; they don't have field descriptors.

However, the ASTDemangler needs to treat them like ordinary classes,
in particular it wants to preserve the generic arguments here so that
we can round-trip debug info.
2019-01-30 01:28:48 -05:00
Slava Pestov
4a74bf4ba1 ASTDemangler: Add support for lowered function types 2019-01-29 21:55:57 -05:00
Slava Pestov
13a50c2d2d ASTDemangler: Add support for lowered metatypes 2019-01-29 19:15:17 -05:00
Harlan Haskins
0a9b8fa37c Merge pull request #22191 from harlanhaskins/fatality
[Diagnostics] Mark invalid ‘@testable import’ as fatal
2019-01-29 15:57:30 -08:00
Harlan Haskins
f4b0e0e7b6 [Diagnostics] Mark invalid ‘@testable import’ as fatal
If this isn’t fatal, this will just end up cascading to a bunch of “could not find member … in …” errors, which hides the real issue.
2019-01-29 14:52:40 -08:00
Harlan Haskins
9c8ed0ba93 [ParseableInterfaces] Print @_show_in_interface
This attribute needs to be preserved in the .swiftmodule, otherwise these declarations will stop showing up in the interface. Print it in the parseable interface.
2019-01-29 11:50:58 -08:00
Jordan Rose
de93ba0992 Merge pull request #22188 from jrose-apple/open-your-heart
Don't fix access of an 'open' override in a 'public' extension

rdar://problem/47557376&28493971
2019-01-29 10:45:48 -08:00
Slava Pestov
ad4cb5fb38 Mangler: Correctly record substitutions when dropping protocols from associated types 2019-01-29 02:15:56 -05:00
Jordan Rose
1f06cd7e6d Tweak diagnostic for a high-access member in a low-access extension
Before: declaring a public instance method in a private extension
After: 'public' modifier conflicts with extension's default access of
       'private'
2019-01-28 18:24:12 -08:00
David Ungar
14ba2a1b60 Format 2019-01-28 15:56:18 -08:00
David Ungar
fc4b7963ee 1st rough cut, frontend tracks defs not uses 2019-01-28 15:32:47 -08:00
Slava Pestov
69f2aba2ff Merge pull request #22158 from pschuh/s-2
NilLiteralExpr now is lowered directly into SIL.
2019-01-28 15:40:10 -05:00
Parker Schuh
6ca70c6720 NilLiteralExpr now is lowered directly into SIL.
Instead of constructing calls to
ExpressibleByNilLiteral.init(nilLiteral: ()) in CSApply.cpp, just
annotate NilLiteralExpr with the selected construtor and do the actual
construction during SILGen.

For context, StringLiteralExpr already behaves this way.
2019-01-28 10:00:52 -08:00
Karoy Lorentey
587a9a824c Merge pull request #22081 from lorentey/hashvalue-fixit
[Sema] Add dedicated fix-it for NSObject.hashValue overrides
2019-01-28 07:50:20 -08:00
David Ungar
bb4239b49a rm most dbg code 2019-01-27 19:15:50 -08:00
David Ungar
ae46aa918a Various fixes + debug unfmt 2019-01-27 19:12:59 -08:00
Doug Gregor
9bf404380f [AST] Hack SourceFile::lookupLocalType() to look through local types.
This is only currently exercised by swift-remoteast-test, so do the
minimum to ensure that we’re getting cached mangled names, but don’t
fret over the linear-time search.
2019-01-25 20:16:31 -08:00
Slava Pestov
b6951932b4 ASTDemangler: Implement type alias types
Debug info uses a special mangling where type aliases can be
represented without being desugared; attempt to reconstruct
the TypeAliasType in this case.
2019-01-25 21:59:48 -05:00
Slava Pestov
0f5233dad1 ASTDemangler: Implement extension lookup 2019-01-25 21:44:02 -05:00
Slava Pestov
55605ceab9 ASTDemangler: Implement DynamicSelfType 2019-01-25 21:44:02 -05:00