Commit Graph

5778 Commits

Author SHA1 Message Date
swift-ci
a743b1b8fc Merge remote-tracking branch 'origin/master' into master-next 2017-04-11 17:28:32 -07:00
Robert Widmann
5b3c4b6844 [NFC] Use the presence of an argument type to check for associated values (#8679)
* Use the presence of an argument type to check for associated values

hasOnlyCasesWithoutAssociatedValues returns true for any serialized
enum declaration whether or not it has cases.  This never really came
up because it's mostly relevant to Sema's proto-deriving mechanism.  Fix
this by using the presence of the case's argument type instead.

* Separate checks for presence of cases and enum simplicity

Necessary because the old behavior was an artifact of the
implementation.
2017-04-11 20:13:17 -04:00
Doug Gregor
0f0a5906d7 [GSB] Put conformance requirements on the proper potential archetype.
We were putting conformance requirements on the representative of the
equivalence class, rather than directly on the potential archetype on
which the conformance requirement was specified. This violates the
invariant used when forming protocol-requirement sources that we never
reseat a requirement onto the representative (which would
have become a problem when implementing recursive protocol
constreaints) as well as masking a GSB idempotency issue that comes
from same-type requirements where the right-hand side was not
guaranteed to refer to the archetype anchor *within* that subcomponent.
2017-04-11 14:15:46 -07:00
Doug Gregor
5b4f2e64d6 [GSB] More detailed debug dump for GSB idempotency failures. 2017-04-11 14:15:46 -07:00
Doug Gregor
e4d2e37115 [GSB] Eliminate always-true condition. 2017-04-11 14:15:46 -07:00
Doug Gregor
148f6383df [GSB] Basic infrastructure for delaying and reprocessing requirements. 2017-04-11 14:15:46 -07:00
Doug Gregor
10ebdcd50a [GSB] Broaden the Boolean result of "add a constraint" operations.
Rather than true (an error occurred) or false (the constraint was
resolved), introduce ConstraintResult to better model what
happened. NFC for now, but the intent here is to report unresolved
constraints through this mechanism.
2017-04-11 14:15:45 -07:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Arnold Schwaighofer
4d60ec333b AST/SILGen support for constant string literals
rdar://30545013
2017-04-11 11:41:43 -07:00
swift-ci
1c269dc87e Merge remote-tracking branch 'origin/master' into master-next 2017-04-10 18:08:52 -07:00
Slava Pestov
473faf1eed AST: Update TypeBase::getSuperclassForDecl() for subclass existentials
This function takes a member of a class and a base type, and returns
the correct 'self' type to substitute into the member's type.

When accessing a member of a subclass existential, if the member
was found via the superclass constraint, we have to erase the
existential down to the class type to calculate the member's
substituted type.

We already had special logic to handle class-constrained archetypes
in the callers of getSuperclassForDecl(); move this check into the
method, and add a similar check for subclass existentials, which
now support the getSuperclass() method.
2017-04-10 17:05:43 -07:00
Slava Pestov
30cd0a9268 AST: Update TypeBase::getSuperclass() for subclass existentials
The "superclass" of a subclass existential is the superclass
constraint. This makes a bunch of random things work, but is
somewhat unprincipled. It fits with how we already handle
class-constrained archetypes and DynamicSelfType, though.
2017-04-10 17:05:43 -07:00
Slava Pestov
ad417c96ad AST: Update ProtocolCompositionType::requiresClass() for subclass existentials
Whether a protocol composition requires a class is no longer
solely a property of what protocols it contains; now, a
protocol composition consisting of a non-class constrained
protocol and a superclass should return true from requiresClass().

This is done by looking at the ExistentialLayout, instead of
walking the members directly.
2017-04-10 17:05:43 -07:00
Slava Pestov
32a7505847 AST: Update ProtocolCompositionType::get() for subclass existentials
Don't assume all members are existential types; we could have
a class (or a class-constrained existential) also, and this
needs to be handled.

When building a canonical protocol composition, the subclass
requirement always comes first in the list of types. This is
an important invariant allowing ExistentialLayout to be
calculated quickly.

Also, calculate the recursive properties of the composition
type from the recursive properties of its members, since they're
no longer trivial if the composition contains a class member
with generic parameters.
2017-04-10 17:05:42 -07:00
Slava Pestov
d7c1d817e3 AST: Update GenericSignatureBuilder for subclass existentials 2017-04-10 17:04:38 -07:00
Slava Pestov
9c3b514c7e AST: New getExistentialLayout() method on TypeBase and CanType
This consolidates calculations which need to look at every
protocol in an existential type. Soon we will also have to
deal with superclass constrained existentials, so start
updating call sites that look at all protocols to use the
new ExistentialLayout and correctly handle a class constraint
as well.

Also, eventually I will kill off the AnyObject protocol and
model it as a protocol composition with no protocols or
superclass, but the requiresClass() flag set.

This is not quite modeled this way yet and AnyObject still
exists, but the new abstraction is a step in the right
direction.
2017-04-10 17:04:37 -07:00
Slava Pestov
b9494b0798 AST: Add an assertion to MemberRefExpr constructor 2017-04-10 17:04:34 -07:00
swift-ci
5263027303 Merge remote-tracking branch 'origin/master' into master-next 2017-04-10 16:28:35 -07:00
Michael Gottesman
e800823ae9 Merge pull request #8647 from gottesmm/tighten_verification_of_inouttopointer_arraytopointer
[ast-verifier] Verify that inout_to_pointer and array_to_pointer are (almost) immediate children of an ApplyExpr argument.
2017-04-10 16:10:00 -07:00
Michael Gottesman
244f1f60c4 [ast-verifier] Verify that inout_to_pointer and array_to_pointer are (almost) immediate children of an ApplyExpr argument.
Specifically we only allow it as an argument to a TupleExpr and a ParenExpr and
can have the following forms:

  (inject_into_optional (*_to_pointer ...))

or

  (*_to_pointer ...)

This will allow for inout_to_pointer and array_to_pointer to be pattern matched
robustly and then special cased in SILGenApply.

The reason why these expressions need to be special cased is that they can
perform inout_expr accesses while going through code paths in SILGenApply where
it is expected that inout accesses do not occur.

rdar://29870610
2017-04-10 11:59:33 -07:00
swift-ci
5eb44b61e7 Merge remote-tracking branch 'origin/master' into master-next 2017-04-10 11:28:33 -07:00
swift-ci
a36bdff69f Merge pull request #8657 from DougGregor/gsb-dependent-type-cleanup 2017-04-10 11:20:23 -07:00
swift-ci
cf0b1616b2 Merge remote-tracking branch 'origin/master' into master-next 2017-04-10 10:48:30 -07:00
Jordan Rose
c1e4be1ad2 Catch llvm::report_fatal_error and try to emit a proper diagnostic. (#8639)
This only affects the textual output, but should still improve the
experience when we /do/ hit one of these LLVM errors. In addition to
showing up better in Xcode, it'll also give us a proper
PrettyStackTrace because of the call to abort() instead of exit(1).

(There's a bit of finger-crossing that the act of printing the
diagnostic doesn't cause more errors. I only tested the fallback
path a little.)
2017-04-10 10:40:03 -07:00
Doug Gregor
fb8023736f [GSB] Eliminate unnecessary "dependentType" parameters throughout.NFC
Now that ProtocolRequirement sources can compute their own stored
types, stop propagating that information through the GSB.
2017-04-10 10:14:01 -07:00
Doug Gregor
7900decb09 [GSB] Compute the dependent type for ProtocolRequirement sources.
The dependent type that is the subject of a ProtocolRequirement
source is independently computable based on the root potential
archetype of the source and the potential archetype to which the
requirement applies, i.e., it's just the dependent member type that
gets from the former to the later. Compute this directly, rather than
relying on the passed-down dependent type.

This is possible now because we no longer capriciously rebase
requirements onto the representatives of equivalence classes, nor
destroy any other structural information in the formation of potential
archetypes.
2017-04-10 09:21:44 -07:00
Joe Groff
964dc0e174 Sema: (wip) Overload resolution for keypath subscripts.
TODO: Some diagnostic regressions:
test-macosx-x86_64/Compatibility/tuple_arguments.swift
test-macosx-x86_64/Constraints/diagnostics.swift
test-macosx-x86_64/Constraints/tuple_arguments.swift
test-macosx-x86_64/expr/unary/keypath/keypath.swift
test-macosx-x86_64/expr/unary/selector/selector.swift
2017-04-09 16:38:02 -07:00
swift-ci
d6b26e40fa Merge remote-tracking branch 'origin/master' into master-next 2017-04-07 18:28:32 -07:00
Xi Ge
52e289af95 [ASTPrinter] Synthesize protocol extensions introduced by extensions' local conformances. rdar://28725923 (#8632) 2017-04-07 18:27:33 -07:00
swift-ci
8b73c56a13 Merge remote-tracking branch 'origin/master' into master-next 2017-04-07 17:48:33 -07:00
Doug Gregor
7b19bb4c16 [GSB] Use "direct" requirement terminology for same-type requirement handling.
NFC
2017-04-07 16:53:11 -07:00
Doug Gregor
c522bb5239 [GSB] Separate out "unresolved" and "direct" type requirement handling.
As we've done with layout requirements, introduce a new entry point
(addTypeRequirement) that handles unresolved type requirements of the
form `T: U`, resolves the types, and then can

1. Diagnose any immediate problems with the types,
2. Delay the type requirement if one of the types cannot be resolved,
or
3. Break it into one or more "direct" requirements.

This allows us to clean up and centralize a bunch of checking that was
scattered/duplicated across the GSB and type checker.
2017-04-07 16:53:11 -07:00
Doug Gregor
68efffd4b8 [GSB] Separate out the "unresolved" and "direct" layout constraint entrypoints.
More staging for delayed resolution of constraints.
2017-04-07 16:53:10 -07:00
Doug Gregor
6991a8c261 [GSB] Basic infrastructure to allow type resolution to fail.
When we resolve() a type that is being used in a constraint, allow
that resolution to fail. If it does fail, then record the constraint
we were trying to address (via a stub that, currently, just drops it)
and continue on. NFC for now; this is intended to allow us to limit
the explosion of types in recursive systems.
2017-04-07 16:53:10 -07:00
Doug Gregor
25f3b3dd4b [GSB] Remove unused "from generic typealias" hack. 2017-04-07 16:53:10 -07:00
swift-ci
a4193fa3c2 Merge remote-tracking branch 'origin/master' into master-next 2017-04-06 23:48:31 -07:00
Joe Groff
85ad6b355e Merge branch 'master' into keypaths 2017-04-06 18:02:07 -07:00
Doug Gregor
5e7a63f69d [ProtocolConformanceRef] Propagate concrete-lookup hack yet further.
Fixes rdar://problem/31482855.
2017-04-06 15:31:40 -07:00
Bob Wilson
c6e37c1f0a Merge remote-tracking branch 'origin/master' into master-next 2017-04-05 17:26:52 -07:00
Huon Wilson
31b92b1b46 Merge pull request #8473 from huonw/symbol-list-2
Remove dependency on IRGenModule of some linkage computations
2017-04-05 16:39:04 -07:00
swift-ci
a088d92d35 Merge remote-tracking branch 'origin/master' into master-next 2017-04-05 14:28:34 -07:00
Doug Gregor
44c2f849d6 [Type checker] Continue validating requirements after an error.
We want to validate both type in same-type or conformance constraints,
even when the first type is ill-formed, so we don't leave null types
around for later phases to crash on.

Fixes rdar://problem/31093854.
2017-04-05 14:05:59 -07:00
swift-ci
5cdde19a04 Merge remote-tracking branch 'origin/master' into master-next 2017-04-05 12:08:45 -07:00
Doug Gregor
6878538ba1 [AST] Remove GenericEnvironment from SubstitutionMap; it's unnecessary. 2017-04-05 11:21:39 -07:00
Doug Gregor
8748601b26 [SubstitutionMap] Dump generic signature in debug output.
You can't interpret a conformance map without a generic signature, so
add it to the debug output.
2017-04-05 11:21:38 -07:00
Doug Gregor
5c89eb84f0 [AST] Drop substitutions from type witnesses.
Nobody is using the actual substitutions, but we sure did a lot of
work to cope with them.
2017-04-05 11:21:38 -07:00
Huon Wilson
65c6bdca90 [IRGen] Remove IGM argument, factor out conformance fragility logic. 2017-04-05 09:54:19 -07:00
Joe Groff
d42f2049f7 KeyPaths: Implement in-place instantiation of invariant key paths.
For key paths without generic or subscript parameterization, we can turn the compiler-generated key path pattern into a global object in-place.
2017-04-05 08:46:45 -07:00
swift-ci
34cb269d23 Merge remote-tracking branch 'origin/master' into master-next 2017-04-04 23:08:31 -07:00
Doug Gregor
30ef37cb83 [AST] Eliminate "inherited conformances" from NormalProtocolConformance.
All of this information is recoverable from the more-general,
more-sane signature conformances, so stop
recording/serializing/deserializing all of this extra stuff.
2017-04-04 22:20:50 -07:00