Commit Graph

1137 Commits

Author SHA1 Message Date
Doug Gregor
285b7f173d [AST] Remove LazyLoaderArray; it's all dead code. 2016-12-12 08:38:50 -08:00
Doug Gregor
8852937beb [AST] Optimize lazy-member storage for nominal type and extension declarations.
Save two pointers of storage in IterableDeclContext (a base class of
nominal type and extension declarations) by storing the lazy member
loader + context data in an ASTContext side table. It also makes it
easier to add more lazy context information later on.
2016-12-12 08:27:28 -08:00
Doug Gregor
5cb04f4635 [Serialization] Serialize a typealias' underlying type as an interface type.
We'll lazily map the interface type to a contextual type when requested.
2016-12-10 15:35:09 -08:00
Doug Gregor
1f89886ffa [Serialization] Stop serializing the contextual types of parameter declarations.
Only serialize the interface types of parameter declarations into the
module file, then lazily build the contextual types when
requested. This saves a small amount of space in the Swift module
files (~64k for the Swift standard library) and some effort on load.
2016-12-09 20:48:40 -08:00
Slava Pestov
9a65745f9b AST: Robustness fix 2016-12-09 20:12:28 -08:00
swift-ci
d694e1e6b3 Merge pull request #6164 from eeckstein/mangling-changes 2016-12-09 11:31:25 -08:00
Xi Ge
6bbdf4a837 [Mangler] Check the order of generic type parameters before mangling them to avoid assertion hit. 2016-12-09 09:51:40 -08:00
Erik Eckstein
208018076e Mangling: add a TODO comment 2016-12-09 08:44:18 -08:00
Doug Gregor
61ce45f185 [AST] Use mapTypeIntoContext() in computeNominalType().
We want the archetypes from the innermost generic environment, always.
2016-12-07 08:10:10 -08:00
Slava Pestov
65088cc139 AST: Clean up usages of getDeclaredTypeInContext() and getExtensionType() 2016-12-04 21:15:02 -08:00
Slava Pestov
c1a216137c AST: Remove unnecessary field from ValueDecl
Now that getType() is gone, the pointer part of TypeAndAccess wasn't
used. Stick InterfaceTy there, saving a word of storage.
2016-12-04 00:24:47 -08:00
Slava Pestov
1a991da16d AST: Assign interface types to ParamDecls
First, ensure all ParamDecls that are synthesized from scratch are given
both a contextual type and an interface type.

For ParamDecls written in source, add a new recordParamType() method to
GenericTypeResolver. This calls setType() or setInterfaceType() as
appropriate.

Interestingly enough a handful of diagnostics in the test suite have
improved. I'm not sure why, but I'll take it.

The ParamDecl::createUnboundSelf() method is now only used in the parser,
and no longer sets the type of the self parameter to the unbound generic
type. This was wrong anyway, since the type was always being overwritten.
This allows us to remove DeclContext::getSelfTypeOfContext().

Also, ensure that FuncDecl::getBodyResultTypeLoc() always has an interface
type for synthesized declarations, eliminating a mapTypeOutOfContext()
call when computing the function interface type in configureInterfaceType().

Finally, clean up the logic for resolving the DynamicSelfType. We now
get the interface or contextual type of 'Self' via the resolver, instead
of always getting the contextual type and patching it up inside
configureInterfaceType().
2016-12-04 00:02:21 -08:00
Slava Pestov
9a4c740baf AST: Remove DeclContext::isProtocolSelf() 2016-12-02 12:21:55 -08:00
Slava Pestov
4ba00a0c06 AST: Remove FuncDecl::getDynamicSelf() and getDynamicSelfInterface() 2016-12-01 20:17:58 -08:00
Slava Pestov
b4d11338ec AST: Push ValueDecl::{has,get,set}Type() down to VarDecl
After recent changes, this asserts on all decls that are not VarDecls,
so we can just enforce that statically now. Interestingly, this turns
up some dead code which would have asserted immediately if called.

Also, replace AnyFunctionRef::getType() with
AnyFunctionRef::getInterfaceType(), since the old
AnyFunctionRef::getType() would just assert when called on
a Decl.
2016-12-01 19:28:13 -08:00
Slava Pestov
2ff9994313 Sema: Improve circularity checks
The previous patches regressed a test where we used to diagnose
(poorly) a circular associated type, like so:

  associatedtype e: e

With the error "inheritance from non-protocol, non-class type 'e'".

This error went away, because we end up not setting the interface
type of the associated type early enough. Instead, we return an
ErrorType from resolveTypeInContext() and diagnose nothing.

With this patch, emit a diagnostic at the point where the ErrorType
first appears.

Also, remove the isRecursive() bit from AssociatedTypeDecl, and
remove isBeingTypeChecked() which duplicates a bit with the same
name in Decl.
2016-12-01 13:00:19 -08:00
Slava Pestov
9caaad442b AST: Don't call hasType()/getType()/setType() on TypeDecls 2016-12-01 13:00:19 -08:00
Slava Pestov
07780bd60c AST: Don't call hasType()/getType()/setType() on AbstractTypeParamDecls 2016-12-01 13:00:18 -08:00
Slava Pestov
2d83a79c2c AST: Remove TypeDecl::getDeclaredType()
A pointless use of polymorphism -- the result values are not
interchangeable in any practical sense:

- For GenericTypeParamDecls, this returned getDeclaredInterfaceType(),
  which is an interface type.

- For AssociatedTypeDecls, this returned the sugared AssociatedTypeType,
  which desugars to an archetype.

- For TypeAliasDecls, this returned TypeAliasDecl::getAliasType(),
  which desugars to a type containing archetypes.

- For NominalTypeDecls, this returned NominalTypeDecl::getDeclaredType(),
  which is the unbound generic type, a special case used for inferring
  generic arguments when they're not written in source.
2016-12-01 13:00:18 -08:00
Slava Pestov
8bdbe774e0 AST: Don't call hasType()/getType()/setType() on SubscriptDecls 2016-12-01 13:00:17 -08:00
Slava Pestov
01bb403e55 AST: Prohibit archetypes in setInterfaceType() 2016-11-29 03:05:36 -07:00
Slava Pestov
835472b14f AST: Remove PolymorphicFunctionType 2016-11-29 03:05:35 -07:00
Slava Pestov
fd0f46807e AST: Assert if setType() called on AbstractFunctionDecl or EnumElementDecl 2016-11-29 03:05:34 -07:00
Slava Pestov
0f7a455d7d AST: Don't call setType() on AbstractFunctionDecls and EnumElementDecls 2016-11-29 03:05:33 -07:00
Slava Pestov
1657060d1e AST: hasType() => hasInterfaceType() 2016-11-29 03:05:30 -07:00
Slava Pestov
40b0c5b3e1 AST: More accurate hasInterfaceType() 2016-11-29 03:05:30 -07:00
Slava Pestov
e74d24687b AST: Assert in getInterfaceType() if no interface type is set
All decls except for ParamDecls must now have an interface type.
2016-11-29 03:05:25 -07:00
Slava Pestov
6cbb494ad2 AST: Give all ValueDecls an interface type
Previously, getInterfaceType() would return getType() if no
interface type was set. Instead, always set an interface type
explicitly.

Eventually we want to remove getType() altogether, and this
brings us one step closer to this goal.

Note that ParamDecls are excempt from this treatment, because
they don't have a proper interface type yet. Cleaning this up
requires more effort.
2016-11-29 03:05:25 -07:00
Slava Pestov
530478cebb AST: Set NominalTypeDecls interface types in computeType() rather than getInterfaceType() 2016-11-29 03:05:24 -07:00
Slava Pestov
bd9e9d8600 AST: Refactor TypeDecl::getDeclaredInterfaceType() a bit 2016-11-29 03:05:24 -07:00
Slava Pestov
f6e692198c AST: Remove FuncDecl::getResultType() 2016-11-29 03:05:23 -07:00
Slava Pestov
55ad1800a1 AST: Remove ConstructorDecl::getArgumentType() 2016-11-29 03:05:23 -07:00
Slava Pestov
69e7cca64f AST: Remove ConstructorDecl::getResultType() 2016-11-29 03:05:22 -07:00
Slava Pestov
7d83704bd9 AST: Add ConstructorDecl::getArgumentInterfaceType() 2016-11-29 03:05:22 -07:00
Graydon Hoare
7c1dc18b64 Revert "Give all declarations an explicit interface type" 2016-11-24 09:55:27 -08:00
Slava Pestov
5b8524a9d1 AST: Remove FuncDecl::getResultType() 2016-11-24 02:35:35 -05:00
Slava Pestov
1dc14e2ec6 AST: Remove ConstructorDecl::getArgumentType() 2016-11-24 02:35:35 -05:00
Slava Pestov
6db43138fa AST: Remove ConstructorDecl::getResultType() 2016-11-24 02:35:30 -05:00
Slava Pestov
1b5a84bf5c AST: Add ConstructorDecl::getArgumentInterfaceType() 2016-11-24 02:35:29 -05:00
Slava Pestov
67607c6cff AST: Set NominalTypeDecls interface types in computeType() rather than getInterfaceType() 2016-11-24 02:35:29 -05:00
Slava Pestov
ee56292808 AST: Give all ValueDecls an interface type
Previously, getInterfaceType() would return getType() if no
interface type was set. Instead, always set an interface type
explicitly.

Eventually we want to remove getType() altogether, and this
brings us one step closer to this goal.

Note that ParamDecls are excempt from this treatment, because
they don't have a proper interface type yet. Cleaning this up
requires more effort.
2016-11-24 02:35:21 -05:00
Slava Pestov
021d3fb7ae AST: Refactor TypeDecl::getDeclaredInterfaceType() a bit 2016-11-24 02:34:05 -05:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Slava Pestov
995072ca78 AST: Add FuncDecl/ConstructorDecl::getResultInterfaceType() 2016-11-18 23:53:20 -08:00
Jordan Rose
a7b027df92 Merge pull request #4579 from aleksgapp/sr-2209-access-scope
[SR-2209] Add real AccessScope type.
2016-11-11 11:16:12 -08:00
Doug Gregor
d223a18f20 [AST] Don't leak ProtocolDecl::DefaultWitnesses.
Fixes rdar://problem/26246025.
2016-11-09 22:19:38 -08:00
Aleksey Gaponov
f51b2d12c4 [SR-2209] Make a real AccessScope class and use it in access checking.
1. Add new AccessScope type that just wraps a plain DeclContext.
2. Propagate it into all uses of "ValueDecl::getFormalAccessScope".
3. Turn all operations that combine access scopes into methods on AccessScope.
4. Add the "private" flag to distinguish "private" from "fileprivate"
scope for top-level DeclContext.
2016-11-04 12:42:38 +01:00
Graydon Hoare
9351843d7a Merge pull request #5588 from graydon/rdar-27397701-synthesized-get-set-typechecking-redux
Rdar 27397701 synthesized get set typechecking
2016-11-02 17:57:20 -07:00
Graydon Hoare
166eebeec6 [Gardening] BodyKind::Synthesize implies empty SourceRange 2016-11-02 11:44:41 -07:00
Slava Pestov
f63dff16c7 AST: Don't allow @_transparent on extensions
Quiz: What does @_transparent on an extension actually *do*?

1) Make all members @_transparent?
2) Allow your members to be @_transparent?
3) Some other magical effect that has nothing to do with members?

The correct answer is 1), however a few places in the stdlib defined
a @_transparent extension and then proceeded to make some or all members
also @_transparent, and in a couple of places we defined a @_transparent
extension with no members at all.

To avoid cargo culting and confusion, remove the ability to make
@_transparent extensions altogether, and force usages to be explicit.
2016-11-01 21:14:09 -07:00