When dealing with multiple levels of generic parameters, the mapping
from potential archetypes down to actual archetypes did not have
access to the archetypes for outer generic parameters. When same-type
requirements equated a type from the inner generic parameter list with
one from the outer generic parameter list, the reference to the outer
generic parameter list's type would remain dependent. For example,
given:
struct S<A: P> {
init<Q: P where Q.T == A>(_ q: Q) {}
}
we would end up with the dependent type for A (τ_0_0) in the same-type
constraint in the initializer requirement.
Now, notify the ArchetypeBuilder of outer generic signatures (and,
therefore, outer generic parameters), so that it has knowledge of the
mapping from those generic parameters to the corresponding
archetypes. Use that mapping when translating potential archetypes to
real archetypes. Additionally, when a potential archetype is mapped to
a concrete type (via a same-type constraint to a concrete type),
substitute archetypes for any dependent types within the concrete
type.
Remove a bunch of hacks in the compiler that identified dependent
types in "strange" places and tried to map them back to
archetypes. Those hacks handled some narrow cases we saw in the
standard library and some external code, but papered over the
underlying issue and left major gaps.
Sadly, introduce one hack into the type checker to help with the
matching of generic witnesses to generic requirements that follow the
pattern described above. See ConstraintSystem::SelfTypeVar; the proper
implementation for this matching involves substituting the adoptee
type in for Self within the requirement, and synthesizing new
archetypes from the result.
Fixes rdar://18435371, rdar://18803556, rdar://19082500,
rdar://19245317, rdar://19371678 and a half dozen compiler crashers
from the crash suite. There are a few other radars that I suspect this
fixes, but which require more steps to reproduce.
Swift SVN r24460
Changing the design of this to maintain more local context
information and changing the lookup API.
This reverts commit 4f2ff1819064dc61c20e31c7c308ae6b3e6615d0.
Swift SVN r24432
rdar://problem/18295292
Locally scoped type declarations were previously not serialized into the
module, which meant that the debugger couldn't reason about the
structure of instances of those types.
Introduce a new mangling for local types:
[file basename MD5][counter][identifier]
This allows the demangle node's data to be used directly for lookup
without having to backtrack in the debugger.
Local decls are now serialized into a LOCAL_TYPE_DECLS table in the
module, which acts as the backing hash table for looking up
[file basename MD5][counter][identifier] -> DeclID mappings.
New tests:
* swift-ide-test mode for testing the demangle/lookup/mangle lifecycle
of a module that contains local decls
* mangling
* module merging with local decls
Swift SVN r24426
rdar://problem/17198298
- Allow 'static' in protocol property and func requirements, but not 'class'.
- Allow 'static' methods in classes - they are 'class final'.
- Only allow 'class' methods in classes (or extensions of classes)
- Remove now unneeded diagnostics related to finding 'static' in previously banned places.
- Update relevant diagnostics to make the new rules clear.
Swift SVN r24260
optional callback; retrofit existing implementations.
There's a lot of unpleasant traffic in raw pointers here
which I'm going to try to clean up.
Swift SVN r24123
Previously, this storage required that alignof(void *) >= alignof(Decl). This is
true on 64-bit platforms, where these are both 8, but on 32-bit platforms
alignof(void *) is only 4.
This now allocates enough bytes to match the alignment of the Decl in question.
This does mean that a void * must fit in that alignment, but this is true on 32-
and 64-bit platforms, and a static_assert ensures that this is true at compile
time.
As part of this change, the logic for allocating memory for a Decl has been
refactored into a separate function, so that the logic for allocating space for
a ClangNode can be centralized.
Swift SVN r23990
... now that we have an exquisitely shaved yak.
This provides a simple and uniform model for "let" constants: they are always either
immediately initialized in their declaration, or they are initialized dynamically
exactly once before any use.
This is a simple generalization of our current model for initializers, but enables
the use of let constants in more cases in local context, e.g. patterns like this:
let x : SomeThing
if condition {
x = foo()
} else {
x = bar()
}
use(x)
Previously this would have to be declared a "var" for no good reason: the value is
only ever initialized, never actually mutated.
The implementation of this is reasonably straight-forward now that the infrastructure
is in place: Sema treats 'let' constants as "settable" if they lack an initializer
(either in the declaration or in a non-PBD binding). This exposes them as an lvalue
at the AST level. SILGen then lowers these things to an alloc_stack, and DI enforces
the "initialization only" requirement that it already enforces for uninitialized 'let'
properties in structs/classes.
Swift SVN r23916
as passing self by value, not by inout. This is the correct representation at
the AST level, and we now lower self references as the new @in_guaranteed
parameter convention. This allows SIL clients (like DI) to know that a nonmutating
protocol method does not mutate the pointee passed into the method.
This fixes:
<rdar://problem/19215313> let properties don't work with protocol method dispatch
<rdar://problem/15821762> Self argument of generic curried nonmutating instance methods is inout
Swift SVN r23864
Have them fill out a vector provided by the caller instead.
It is very easy to have callers just go through the array, thus wasting memory, as
the clang importer ended up doing.
The caller should be the one deciding if the array must be copied in ASTContext or not.
Swift SVN r23472
@objc methods, initializers, deinitializers, properties, and
subscripts all produce Objective-C methods. Diagnose cases where two
such entities (which may be of different kinds) produce the same
Objective-C method in the same class.
As a special exception, one can have an Objective-C method in an
extension that conflicts with an Objective-C method in the original
class definition, so long as the original class definition is from a
different model. This reflects the reality in Objective-C that the
category definition wins over the original definition, and is used in
at least one overlay (SpriteKit).
This is the first part of rdar://problem/18391046; the second part
involves checking that overrides are sane.
Swift SVN r23147
Generic function signatures were including outer generic parameters,
but generic type signatures were not. This is a small part of the
problem with nested generics (in general), but also a useful cleanup
for generic signatures.
Swift SVN r23011
allowing some cases of "self.dynamicType" in initializers before self is fully
initialized. There is still more to do.
This is part of:
<rdar://problem/17207456> Unable to access dynamicType of an object in a class initializer that isn't done
Swift SVN r22732
define properties and subscripts with the
get+mutableAddress combination of accessors.
Fix a couple of simple problems this exposes.
rdar://17270560
Swift SVN r22419
properties.
The main design change here is that, rather than having
purportedly orthogonal storage kinds and has-addressor
bits, I've merged them into an exhaustive enum of the
possibilities. I've also split the observing storage kind
into stored-observing and inherited-observing cases, which
is possible to do in the parser because the latter are
always marked 'override' and the former aren't. This
should lead to much better consideration for inheriting
observers, which were otherwise very easy to forget about.
It also gives us much better recovery when override checking
fails before we can identify the overridden declaration;
previously, we would end up spuriously considering the
override to be a stored property despite the user's
clearly expressed intent.
Swift SVN r22381
semantically valid way.
Previously, this decision algorithm was repeated in a
bunch of different places, and it was usually expressed
in terms of whether the decl declared any accessor
functions. There are, however, multiple reasons why a
decl might provide accessor functions that don't require
it to be accessed through them; for example, we
generate trivial accessors for a stored property that
satisfies a protocol requirement, but non-protocol
uses of the property do not need to use them.
As part of this, and in preparation for allowing
get/mutableAddressor combinations, I've gone ahead and
made l-value emission use-sensitive. This happens to
also optimize loads from observing properties backed
by storage.
rdar://18465527
Swift SVN r22298
There are a lot of different ways to interpret the
"kind" of an access. This enum specifically dictates
the semantic rules for an access: direct-to-storage
and direct-to-accessor accesses may be semantically
different from ordinary accesses, e.g. if there are
observers or overrides.
Swift SVN r22290
Use this in calls to TypeBase::getTypeOfMember() that were relying on
archetypes solely because they were using EnumElementDecl::getArgumentType().
Swift SVN r22205
body of a function twice.
This is almost taken care of by careful ordering, but it gets
all screwed up by synthesized accessor functions. Just give
up and keep a bit.
Swift SVN r22019
generates them.
Modify getAsCanonicalGenericSignature to dump same-type requirements last.
Also mix the conformance requirements on assocaited archetypes with the witness
markers.
SILParser used to put witness markers for all assocaited archetypes, then
add same-type requirements, and finally the conformance requirements on
associated archetypes. This causes mismatch types between deserialized
SILFunctionTypes and parsed SILFunctionTypes.
rdar://17998988
Swift SVN r21423
When trying to implement deduplication of results, found and fixed an issue
with loose checks for generic overload checking.
rdar://17995317
Swift SVN r21276
method has the convenience attribute on it when inferring the type of an
init that contains no self.init or super.init method. This allows us to
properly infer that these things are delegating initializers, which trickles
down to emitting:
a.swift:7:3: error: self.init isn't called on all paths in delegating initializer
for:
required convenience init(foo: Int) {
}
instead of doing DI as though the initializer was a root init.
Swift SVN r21120
This is a simple, trivialy, not-even-half-way-there solution to weak
leaking of Objective-C classes introduced after the deployment
target. It only works for Objective-C classes and C global variables
that Clang consideres to be "weak imported". However, this bare
minimum should be enough to develop an app (by jumping through various
hoops) that uses new functionality when its
available. <rdar://problem/17296490>, which I've restricted in scope
to capture this.
Swift SVN r20956
We were checking for exact type equality of the DeclContexts, which
will not hold when extensions have their own archetypes. A near-term
fix would be to use interface types, but checking the nominal types is
a better long-term solution.
Swift SVN r20768
The eventual goal for extensions of generic types is to require them
to specify their generic parameters, e.g.,
extension Array<T> { ... }
rather than today's
extension Array { ... }
Start parsing (optional) generic parameters here, and update the
representation of ExtensionDecl to accomodate this new grammar
production. Aside from the parser changes, there's no intended
functionality change here.
Swift SVN r20682
This adds generic parameters and generic signatures to extension
declarations. The actual generic parameters just mirror what is
available on the extended type; however, it is filled in via extension
validation, which is handled lazily.
This is a NFC step toward decoupling the archetypes of extensions from
the archetypes of the extended types <rdar://problem/16974298>.
Swift SVN r20675
Previously, we were just storing setter accessibility via the accessibility
level on the setter function. However, some Stored properties never actually
have a setter synthesized, which led to the compiler dropping the setter
accessibility at serialization time. Rather than try to hack up something
clever, just store the setter accessibility explicitly in every
AbstractStorageDecl. (We still only serialize it for VarDecls, because
settable SubscriptDecls always have setter functions.)
<rdar://problem/17816530>
Swift SVN r20598