Commit Graph

7589 Commits

Author SHA1 Message Date
swift-ci
36a60d253c Merge pull request #7519 from rudkx/dump-source-range 2017-02-16 00:35:47 -08:00
Mark Lacey
58b14ffc2d Update -debug-constraints to dump the source range immediately.
We end up dumping information during constraint generation, and it's
nice to know which range we're dealing with at that point.
2017-02-15 23:21:52 -08:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Slava Pestov
41eba98902 Gardening: Fix some unused variable warnings in no-assert builds 2017-02-15 12:57:35 -08:00
Slava Pestov
32316559f8 AST: Stored property accessors on non-Objective-C derived classes can be transparent
In 74d979f0ac, the policy was changed
so that only value type accessors are ever marked transparent, and
not class accessors.

This was intended to fix a bug where inlining an accessor of an
Objective-C-derived class across module boundaries caused a linker
failure because the accessor referenced a field offset variable,
which has hidden visibility.

However, this also caused a performance regression for Swift native
classes. Bring back the old behavior for Swift native classes in
non-resilient modules.

Fixes <rdar://problem/29884727>.
2017-02-14 22:35:27 -08:00
Mark Lacey
713e5a2135 Merge pull request #7481 from rudkx/fix-rdar30376186
Cache expression types in failure diagnosis.
2017-02-14 21:31:54 -08:00
Mark Lacey
f1f9e88360 Cache expression types in failure diagnosis.
After we call into typeCheckExpression() we need to cache the
resulting types in the constraint system type map because we later
call into code that reads the types out of the type map.

Fixes rdar://problem/30376186 as well as a couple crashers.
2017-02-14 19:22:41 -08:00
Slava Pestov
13d6b183c0 Merge pull request #7370 from llvm-beanz/simplify-add_swift_library
[CMake] Simplify add_swift_library
2017-02-14 19:16:59 -08:00
Slava Pestov
fd40597d90 Sema: Extend prohibition of @_inlineable designated initializers to classes
This check only applied to struct and enum initializers previously,
but that was an oversight.
2017-02-14 15:48:26 -08:00
Slava Pestov
50b5d01dd7 Sema: Tighten up rules for @_inlineable
- Don't allow @_inlineable on stored properties; this generates
  invalid SIL since clients can't know about stored properties of
  resilient types. Accessors for stored properties of non-resilient
  types are already @_inlineable anyway.

- Don't allow @_inlineable on declarations that are not public or
  @_versioned, since it's simply redundant.
2017-02-14 15:48:26 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
swift-ci
25d58af2ad Merge pull request #7452 from DougGregor/sr-3917-unavaiable-reqs 2017-02-13 23:34:57 -08:00
Doug Gregor
769a40c2b5 [Type checker] Don't try to infer @objc from unavailable requirements.
@objc inference was looking at unavailable requirements---for which we
don't ever record witnesses---at a point when it is no longer possible
to record such a witness. This is a targeted fix; we need to tackle
the issue of unavailable and optional requirements more thoroughly.

Fixes SR-3917 / rdar://problem/30474860.
2017-02-13 23:12:14 -08:00
Slava Pestov
46ea929072 Sema: Remove TMF_UnwrappingOptional
We should remove the only remaining TMF flag one day too, since it looks
completely bogus.
2017-02-13 16:59:13 -08:00
Slava Pestov
e9c255bfca Sema: Better fix for banning the '() -> T' => '() -> ()?' implicit conversion
Previously we would check TMF_UnwrappingOptional flag, which does not
stick with the constraint, so it would not always persist. Now, add a
new OptionalPayload locator element, which is more correct.

Fixes <rdar://problem/30429709>.
2017-02-13 16:59:09 -08:00
practicalswift
6daa23fa8e [gardening] Fix a vs an typos 2017-02-13 14:45:16 +01:00
Hugh Bellamy
cb3bdcc2a3 Merge pull request #7408 from hughbe/llvm-fallthrough
Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH
2017-02-13 17:39:59 +07:00
Slava Pestov
f0ecd1c1a3 Sema: Lift unnecessary restriction on initializers defined in extensions of resilient protocols
The restriction only applies to initializers in extensions of
concrete types; protocol extension initializers are OK.

Fixes <rdar://problem/30351393>.
2017-02-13 00:24:13 -08:00
Slava Pestov
0f8932cad1 Sema: Clean up the RequirementEnvironment's SubstitutionMap construction
Instead of calling addSubstitution() and addConformance(), use
GenericSignature::getSubstitutionMap().
2017-02-12 01:42:35 -08:00
Slava Pestov
9331d3f5bb AST: Remove unnecessary SubstOptions() parameters to Type::subst() 2017-02-12 00:51:27 -08:00
Slava Pestov
5296d02485 AST: More include-what-you-use gardening 2017-02-12 00:51:26 -08:00
Slava Pestov
ec4a95be21 AST: Witness stores SubstitutionList instead of SubstitutionMap
This simplifies serialization and removes some calls of
SubstitutionMap::addSubstitution() and addConformance().
2017-02-12 00:51:26 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Doug Gregor
579af863c5 Rename ArchetypeBuilder -> GenericSignatureBuilder 2017-02-10 12:46:34 -08:00
Doug Gregor
5a031d8500 Merge pull request #6154 from DougGregor/generic-env-serialization
[Serialization] Serialize archetypes as generic environment + interface type
2017-02-10 01:30:54 -08:00
Doug Gregor
c6f6c528b1 [Type checker] Keep a type checker alive during name binding.
Name lookup can cause import of some Clang declaration, which in turn
need a type checker. Make sure a type checker exists at this time.

This is a baby step toward having the type checker always available,
which is really the end goal. For now, we need this for better generic
environment (de-)serialization.
2017-02-09 23:50:15 -08:00
Jordan Rose
df63c36b72 When setting a willSet/didSet param's type, also set the TypeLoc (#7377)
We don't actually need the TypeLoc for anything, but it was still
getting type-checked, which means it doesn't get the benefit of
inference from the initial value. In some cases the actual type of the
ParamDecl seems to get reset to the TypeLoc's type as well. Just do
the simple thing and set it directly ahead of time.

Fixes a source compatibility issue with Swift 3.0.

https://bugs.swift.org/browse/SR-3893
2017-02-09 19:15:21 -08:00
Doug Gregor
b412961003 [AST] Maintain type sugar in TypeMatcher. 2017-02-09 15:03:34 -08:00
swift-ci
bb874934f9 Merge pull request #7313 from huonw/requirement-signature-archetype-builder 2017-02-09 12:02:42 -08:00
Joe Groff
7b9015dcd3 Merge pull request #7345 from jckarter/raw-rep-synthesized-conformance
Sema: Treat the implicit RawRepresentable conformance for enums as `Synthesized` again.
2017-02-09 07:10:13 -08:00
swift-ci
1e7a572fe7 Merge pull request #7355 from DougGregor/partial-ordering-labels 2017-02-08 22:18:37 -08:00
Slava Pestov
707083d22f Sema: Fix crash when defining an extension of a nested type with constraints
If the nested type itself has generic constraints, we would
hit an assertion in requirement inference. Refactor some code
so that we can make the assertion more accurate.

Fixes <rdar://problem/30353095>.
2017-02-08 21:51:19 -08:00
Doug Gregor
e25244f3c6 [Type checker] Ignore argument labels when ordering declarations.
When comparing the parameters of two declarations for the purpose of
partial ordering, it doesn't make sense to compare the parameter
labels: they're dealt with separately and aren't conceptually part of
the type.
2017-02-08 20:54:25 -08:00
Huon Wilson
9b68748bdf [Sema] Conformances only need to be verified as used once. 2017-02-08 19:54:24 -08:00
Slava Pestov
a16faae73b AST: Move ProtocolConformance::getTypeWitnessByName() to ProtocolConformanceRef
I need to move some #includes around ("include what you use") to
break circularities for an upcoming refactoring.
2017-02-08 15:33:46 -08:00
Joe Groff
6d9a40f455 Sema: Treat the implicit RawRepresentable conformance for enums as Synthesized again.
This reverts part of #4038 which made the compiler consider it to be an `Explicit` conformance, breaking source code that was accepted in Swift 3.0 which declared a raw type as well as explicit conformance to `RawRepresentable` (reported as rdar://problem/30386658). While I'm here, a couple of spot fixes:

- Ensure an enum's raw value exprs are type-checked before checking conformances of any of its extensions, since the RawRepresentable conformance derivation will blow up if the raw value exprs haven't been checked. Fixes an order dependency issue if `extension Foo: RawRepresentable {}` gets checked before `enum Foo: Int { ... }`.
- Don't display the custom `enum_declares_rawrep_with_raw_type` diagnostic if the source location for the enum's inheritance clause is invalid, so that we don't emit a dislocated diagnostic.
2017-02-08 15:31:17 -08:00
Huon Wilson
74091fbcef [AST] Store and serialize a protocol's requirement signature.
This is the "canonical" representation of the type-level requirements of
a protocol, and we intend to use it pervasively in the compiler.
2017-02-08 13:08:31 -08:00
Slava Pestov
bd4f31025f AST: GenericEnvironment::mapTypeIntoContext() no longer needs to take a ModuleDecl
Now, use LookUpConformanceInSignature instead.
2017-02-07 19:25:34 -08:00
Jacob Bandes-Storch
c98e515734 [QoI] Improvements to function call & closure diagnostics (#7224) 2017-02-07 17:36:11 -08:00
Doug Gregor
575908a0e8 [Parser] Wipe out bogus generic parameters that we parsed in SIL mode.
This lets us remove a hack in the type checker that tried to avoid
looking at such generic parameters.
2017-02-07 16:14:57 -08:00
Doug Gregor
81daa1f53b [Type checker] Be more tolerant of broken initializer declarations. 2017-02-07 15:22:50 -08:00
Doug Gregor
d924849853 [Code completion] Clean up context validation.
… and make sure we validate a function declaration before type-checking it’s body.
2017-02-07 15:22:50 -08:00
Doug Gregor
a9daae2fea [Type checker] Don’t print an erroneous superclass in a diagnostic. 2017-02-07 15:22:50 -08:00
Doug Gregor
efe6175358 [Type Checker] Use GenericSignature::createGenericEnvironment().
New generic environments should be created directly from the generic
signature, without having to explicitly create an archetype
builder. Now, only the canonical archetype builders are ever used to
create a generic environment.
2017-02-07 15:22:50 -08:00
Doug Gregor
a88566cf81 Eliminate TypeChecker::createArchetypeBuilder(). NFC
We don't need this convenience function; archetype builders are easy
to create now.
2017-02-07 11:15:11 -08:00
Doug Gregor
0c76a9d828 [Archetype builder] Clean up PotentialArchetype a bit.
Clean up the representation of PotentialArchetype in a few small ways:

* Eliminate the GenericTypeParamType* at the root, and instead just
  store a GenericParamKey. That makes the potential archetypes
  independent of a particular set of generic parameters.

* Give potential archetypes a link back to their owning
  ArchetypeBuilder, so we can get contextual information (etc.) when
  needed. We can remove the "builder" arguments as a separate step.

Also, collapse getName()/getDebugName()/getFullName() into
getNestedName() and getDebugName(). Generic parameters don't have
"names" per se, so they should only show up in debug dumps.

In support of the former, clean up some of the diagnostics emitted by
the archetype builder that were using 'Identifier' or 'StringRef'
where they should have been using a 'Type' (i.e., the type behind the
dependent archetype).
2017-02-07 11:15:11 -08:00
swift-ci
ec274a1bbd Merge pull request #7298 from DougGregor/early-recursive-constraints 2017-02-06 23:28:51 -08:00
Doug Gregor
def14bfb70 [Archetype builder] Move checking for recursive constraints to finalize().
Rather than waiting until we try to form a contextual type to diagnose
recursion, perform the check while finalizing the archetype builder
itself.
2017-02-06 22:58:44 -08:00
Slava Pestov
85a8a50bee Merge pull request #7295 from slavapestov/introduce-substitution-list
AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
2017-02-06 22:36:03 -08:00
Rintaro Ishizaki
af9d16b4d9 [QoI] Improve diagnostics for unbound generic types (#7178)
Since the type is declared in other modules, we should use Decl instead
of its location.
2017-02-07 15:26:13 +09:00