Commit Graph

2666 Commits

Author SHA1 Message Date
Arnold Schwaighofer
5004cee9b0 Merge pull request #62686 from aschwaighofer/testing_debacle
IRGen: Don't treat internal but visible via testable import classes as having fragile layout
2022-12-19 16:08:03 -08:00
Arnold Schwaighofer
20ff4dfc57 IRGen: Don't treat internal but visible via testable import classes as having fragile layout
That does not work if there is a resilient class in the hiearchy from a
different module than the testable imported one.  Rather treat an
internal but testable imported class as having resilient metadata.

The scenario that does not work assuming we can build a fragile layout
is the following.

FrameworkA is resilient and defines a public class `Base` with a stored field.
FrameworkB is resilient and defines an internal class `Sub` that inherits from
the class `Base` in FrameworkA and adds some fields. FrameworkB is compiled
with enable-testing.
The test case testable imports FrameworkB and accesses a field in the
internal class `Base` from FrameworkB. The test case only has access to
FrameworkA's public swiftinterface file and therefore does not know
`Base`'s layout.  The layout computation for `Sub` cannot take the field
from `Base` into account and things fail silently.

rdar://103323275
2022-12-19 07:35:56 -08:00
Luciano Almeida
0db4b43f6d Merge pull request #61863 from LucianoPAlmeida/crash-dump-parse-init
[ASTDumper] Special handling for init kind in pre-typecheck dump
2022-12-16 09:42:31 -03:00
Pavel Yaskevich
7b08b30e84 Merge pull request #62586 from xedin/rdar-103270262
[AST/Sema] TypeWrappers: Fix a couple of issues with attribute inference from protocols
2022-12-15 17:49:19 -08:00
Pavel Yaskevich
778285157f [AST] TypeWrappers/NFC: Move local $storage handling code to TypeWrapper.cpp 2022-12-14 12:29:56 -08:00
Alex Hoppen
58aaa4f111 Merge pull request #62522 from ahoppen/ahoppen/rename-completion
[IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
2022-12-13 16:40:28 +01:00
Alex Hoppen
fe2ae72ad2 [IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
The code completio infrastructure is also being used for cursor info now, so it should no longer be called code completion.

rdar://103251187
2022-12-13 11:41:05 +01:00
Doug Gregor
54625a3a70 Only diagnose a missing external macro definition when we try to expand 2022-12-12 13:18:13 -08:00
Luciano Almeida
70b884cf08 [ASTDumper] Special handling for init kind in pre-typecheck dump 2022-12-06 22:50:00 -03:00
Doug Gregor
3c80b714bf [Macros] Fix end location of macro declarations with where clauses 2022-11-28 18:33:10 -08:00
Doug Gregor
1a124e71d6 [Macros] Implement AST printing and module interface generation for macros 2022-11-28 18:33:10 -08:00
Doug Gregor
b29fcb4e58 [Macros] Parse macro declarations fully, and treat them as normal declarations 2022-11-28 18:32:43 -08:00
Pavel Yaskevich
c17d35dc3e Merge pull request #62146 from xedin/rdar-102085039
[AST] `getParameterAt` should check index before retrieving it
2022-11-28 10:01:51 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Doug Gregor
787af41765 [Macros] Parse generic arguments in macro expansions. 2022-11-17 16:46:43 -08:00
Angela Laar
3b8cfca027 [test] Add more opaque return tests 2022-11-17 11:54:44 -08:00
Angela Laar
bde6a465af [AST] Fix circular reference with implicit some
getPotentiallyOpaqueGenericParams has a redundant call to check if
declarations contain any opaque type representations. We don't need
to check this here. Instead we can simply collect the result type
representaions without the additional checks.
2022-11-17 11:53:50 -08:00
Pavel Yaskevich
7bc1dc59ab [AST] getParameterAt should check index before retrieving it
`getParameterAt` needs to be more defensive about the input
because caller cannot always perform all the checks upfront.

Resolves: rdar://102085039
2022-11-16 15:34:05 -08:00
Doug Gregor
51fcde7b76 Merge pull request #62086 from DougGregor/macro-decl 2022-11-13 20:25:48 -08:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Holly Borla
ee04cea679 [Sema] Fix an issue with existential return types when implicit some is enabled. 2022-11-11 15:16:06 -08:00
Allan Shortlidge
114ee28639 AST: Add a DescriptiveDeclKind for actors. 2022-11-08 19:17:09 -08:00
Pavel Yaskevich
0aa036a495 Merge pull request #61915 from xedin/switch-protocol-checking-to-abi-members
[AST/Sema] Switch protocol requirement inference to use `getABIMembers()`
2022-11-04 16:21:01 -07:00
Pavel Yaskevich
82f34b90c1 [AST] NameLookup: Add a request to gather protocol requirements 2022-11-04 11:11:41 -07:00
Robert Widmann
7944635f2e Merge pull request #61898 from CodaFi/i-write-syns-not-tragedies 2022-11-04 08:20:47 -07:00
Pavel Yaskevich
dd69e11482 [AST/Sema] Switch protocol requirement inference to use getABIMembers()
- `getAssociatedTypeMembers()`;
- inference of defaults for associated types;
- `ConformanceChecker` methods that iterate over type and
   value requirements.
2022-11-03 13:22:53 -07:00
Robert Widmann
2d07f382c5 Delete _InternalSwiftSyntaxParser And Its Build Infrastructure
This is the start of the removal of the C++ implementation of libSyntax
in favor of the new Swift Parser and Swift Syntax libraries. Now that
the Swift Parser has switched the SwiftSyntaxParser library over to
being a thin wrapper around the Swift Parser, there is no longer any
reason we need to retain any libSyntax infrastructure in the swift
compiler.

As a first step, delete the infrastructure that builds
lib_InternalSwiftSyntaxParser and convert any scripts that mention
it to instead mention the static mirror libraries. The --swiftsyntax
build-script flag has been retained and will now just execute the
SwiftSyntax and Swift Parser builds with the just-built tools.
2022-11-02 10:35:29 -07:00
Slava Pestov
36b3f0ee12 AST: Remove AbstractTypeParamDecl 2022-11-01 19:13:46 -04:00
Slava Pestov
0e4ccb21ed AST: Remove various references to AbstractTypeParamDecl 2022-11-01 19:13:46 -04:00
Slava Pestov
ad06d27e88 AST: Remove AbstractTypeParamDecl::getSuperclass()/getConformingProtocols() 2022-11-01 19:13:46 -04:00
Becca Royal-Gordon
75965d0588 Exclude overrides from being member impls
Without this change, an `@_objcImplementation` cannot override parent class methods, because the special access control behavior breaks the access control checks for overrides.
2022-10-27 17:00:43 -07:00
Becca Royal-Gordon
881f1f90a8 Re-allow @objc final
Treating this as forbidden was incorrect; an `@objc final` method is simply one that isn’t a member implementation but does have an ObjC entry point.

Formalize and centralize the definition of what a member implementation is, tweak it so that it’s basically “non-final and internal or greater”, and permit `@objc final`. Also remove the inference of `final` on `let`s in @_objcImpl extensions.
2022-10-27 16:51:13 -07:00
swift-ci
1ebcd13975 Merge pull request #61662 from rxwei/macro-expansion-expr
[Macros] Parse MacroExpansionExpr and MacroExpansionDecl
2022-10-21 06:13:41 -07:00
Richard Wei
56e7cce809 [Macros] Parse MacroExpansionExpr and MacroExpansionDecl
Introduce `MacroExpansionExpr` and `MacroExpansionDecl` and plumb it through. Parse them in roughly the same way we parse `ObjectLiteralExpr`.

The syntax is gated under `-enable-experimental-feature Macros`.
2022-10-21 01:50:35 -07:00
Pavel Yaskevich
5c8c008c8e Merge pull request #61479 from xedin/type-wrappers-init-values-in-user-defined-inits
[SILGen] TypeWrappers:  Support default values in user-defined initializers
2022-10-21 08:48:35 +01:00
Becca Royal-Gordon
a36b52153f Directly access @_objcImpl stored props sometimes
Accessing a stored property from a normal method should send a selector, but accessing it from an initializer or accessor should use the field offset.
2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
ecf0ee65b8 Cache @_objcImpl pointers and diagnose dupes 2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
3a2f12a099 Allow stored properties in @_objcImpls
Stored properties are only allowed in the extension implementing the class's main interface, not its categories. This also means banning `@objc final`, which is unenforceable anyway when ObjC subclasses are allowed, and therefore allowing `@objc let` and `@objc static` properties to be overridden if they're declared in objcImplementations.
2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
e544c21f99 Make all internal-or-more @_objcImpl members impls 2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
f2a0ab79c7 Add basic Sema support for @_objcImplementation
Does not validate members yet; nor does it emit different metadata.
2022-10-18 17:21:56 -07:00
Slava Pestov
a5453f1649 AST: Add new variant of swift::getParameterAt() which takes pack expansions into account 2022-10-16 21:37:25 -04:00
Hamish Knight
48ea933804 Parse an ellipsis T... for type parameter packs
In a generic parameter list, parse an ellipsis
to produce a type parameter pack. This replaces
the previous `@_typeSequence` attribute.
2022-10-14 15:40:12 +01:00
Hamish Knight
b645e63ce5 [AST] NFC: Refactor GenericTypeParamDecl construction
Add distinct overloads for the parser,
deserialization and code synthesis.
2022-10-14 15:40:12 +01:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Pavel Yaskevich
cba7a78605 [AST] Make it possible to check if var decl is for _storage 2022-10-07 17:36:10 -07:00
Holly Borla
54f42b5833 Merge pull request #61445 from hborla/pack-shape-requirements
[RequirementMachine] Implement inference and minimization of same-shape requirements.
2022-10-07 14:49:14 -07:00
Slava Pestov
92f1361b82 Merge pull request #61429 from LucianoPAlmeida/opaque-parameters-crash
[AST] Move generic parameter logic for accessor decl from parser to GenericParamListRequest
2022-10-07 16:52:24 -04:00
Luciano Almeida
a95f60e387 [AST] Refactor generic parameter list parse logic for AccessorDecl 2022-10-07 09:43:08 -03:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Pavel Yaskevich
412915eadd [AST] TypeWrappers: A request to synthesize _storage variable for an initializer
User-defined initializer would populate `_storage` incrementally
so it could be passed to `<TypeWrapper>.init(memberwise:)` call
to initialize the type wrapper.
2022-09-29 20:50:36 -07:00