Commit Graph

52 Commits

Author SHA1 Message Date
Slava Pestov
e9e6a51c82 Unconditionally enable variadic generic types now that SE-0398 has been accepted 2023-05-15 23:32:52 -04:00
Anthony Latsis
3f629315a9 Merge pull request #65731 from AnthonyLatsis/always-print-any
ASTPrinter: Turn on explicit `any` printing for everything and remove the option to disable it
2023-05-16 03:27:36 +03:00
Slava Pestov
4318a36be6 Sema: Availability checking for variadic generic types 2023-05-12 22:50:25 -04:00
Anthony Latsis
7f6d3bcd41 ASTPrinter: Turn on explicit any printing for everything and remove the option to disable it 2023-05-13 02:55:49 +03:00
Holly Borla
234b5dc660 [SE-0393] Require the repeat keyword for generic requirement expansions. 2023-04-12 22:04:01 -07:00
Slava Pestov
6bc2082221 ASTDemangler: Remove overly-zealous validation check when demangling constrained existential types 2023-03-23 00:53:13 -04:00
Sophia Poirier
70cffb06f3 [Variadic Generics] type parameter pack syntax change: T... -> each T 2023-03-02 14:42:28 -08:00
Slava Pestov
7a0cd5a021 ASTDemangler: Correctly demangle generic signature of nominal type in constrained extension 2023-02-25 16:19:07 -05:00
Nate Chandler
8d8577e5b0 [SIL] Removed Indirect_In_Constant convention.
It is no different from @in.

Continue parse @in_constant in textual and serialized SIL, but just as
an alias for @in.
2022-12-09 21:54:00 -08:00
Anthony Latsis
c7281228c5 Gardening: Migrate test suite to GH issues: TypeDecoder 2022-09-06 15:08:57 +03:00
Holly Borla
8713d78704 [PrintOptions] Print explicit 'any' in SIL. 2022-08-18 01:15:12 -04:00
Holly Borla
c2594d1338 [FrontendOptions] Remove the -enable-explicit-existential-types flag. 2022-02-17 17:54:59 -08:00
Slava Pestov
e24031012f RequirementMachine: Disable merged associated types by default
This feature allows the following construct to work:

    protocol P1 {
      associatedtype T : P1
    }

    protocol P2 {
      associatedtype T : P2
    }

    func foo<T : P1 & P2>(_: T) {}

However, I haven't figured out how to make it work with rewrite system
minimization, so it's already disabled when you use the requirement
machine for protocol or generic signature minimization. In addition to
that it adds some complexity.

I haven't found any real-world uses of this pattern yet, so I'm going
to try to turn it off, and if nobody complains, remove the support
altogether.

If people do complain, we'll have to figure out how to make it work with
minimization.
2022-01-25 11:38:50 -05:00
Holly Borla
f96104d2d5 [Test] Duplicate test/TypeDecoder/existentials.swift with explicit
existential types enabled.
2021-12-10 00:11:03 -08:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Richard Wei
fb66de6126 Unify mangling operators for async, @Sendable, @differentiable and @noDerivative.
Repurpose mangling operator `Y` as an umbrella operator that covers new attributes on function types. Free up operators `J`, `j`, and `k`.

```
async ::= 'Ya'                             // 'async' annotation on function types
sendable ::= 'Yb'                          // @Sendable on function types
throws ::= 'K'                             // 'throws' annotation on function types
differentiable ::= 'Yjf'                   // @differentiable(_forward) on function type
differentiable ::= 'Yjr'                   // @differentiable(reverse) on function type
differentiable ::= 'Yjd'                   // @differentiable on function type
differentiable ::= 'Yjl'                   // @differentiable(_linear) on function type
```

Resolves rdar://76299796.
2021-04-07 17:49:10 -07:00
John McCall
a8464dcaf1 Implicitly import _Concurrency under -enable-experimental-concurrency 2020-10-22 00:53:15 -04:00
Doug Gregor
81f0f37acc [Concurrency] (De-)mangling for SIL @async function types. 2020-09-25 22:45:45 -07:00
Slava Pestov
76a81efac9 ASTDemangler: Fix reconstruction of opaque result type defined in a constrained extension
The mangling includes all generic parameters, even non-canonical ones.

Fixes <rdar://problem/67949286>.
2020-08-30 01:39:50 -04:00
tbkka
0855829dc5 Demangling variadic tuples should not crash (#31988)
The TypeDecoder logic had a bug that caused crashes when it saw a tuple type with a variadic marker.  Since variadic tuples aren't supported, this changes the logic to cleanly reject a tuple with a variadic marker.
2020-06-12 10:02:47 -07:00
Slava Pestov
f5258ed9c9 ASTDemangler: Add support for member types of opaque result types
Fixes <rdar://problem/63188053>.
2020-05-22 22:10:30 -04:00
Anthony Latsis
280ce22376 Test reconstruction of non-generic nested types with contextual where clauses 2020-03-21 05:47:54 +03:00
Slava Pestov
22cb6f1176 AST: Introduce ProtocolDecl::get{AssociatedType,ProtocolRequirement}() 2019-09-03 22:39:35 -04:00
Azoy
4e8d6e2de2 Add layout constraint test 2019-08-10 14:19:34 -04:00
Jordan Rose
15861053e2 [test] Verify that TypeDecoder handles same-type constraints properly (#26045)
Follow-up for 4b8068d1df recommended by Slava.
2019-07-24 08:56:16 -07:00
Slava Pestov
198e8d1a1f AST: Introduce a new debug-only mangling for @escaping @convention(block) functions
Our mangling did not encode if an Objective-C block was escaping or
not. This is not a huge problem in practice, but for debug info we
want type reconstruction to round-trip exactly. There was a previous
workaround to paper over this specific problem.

Remove the workaround, and add a new 'XL' mangling for escaping
blocks. Since we don't actually want to break ABI compatibility,
only use the new mangling in DWARF debug info.
2019-06-12 19:10:19 -07:00
Slava Pestov
7890524764 AST: Fix type reconstruction for @convention(c) function types
They're never 'escaping'.

Fixes <https://bugs.swift.org/browse/SR-10335>, <rdar://problem/51646233>.
2019-06-12 17:27:39 -07:00
Joe Groff
0be95f56bd Merge pull request #24798 from jckarter/opaque-type-check-availability
Opaque types require a newer Swift runtime.
2019-05-15 18:05:40 -07:00
Joe Groff
cec9e9e33a Opaque types require a newer Swift runtime.
Check the availability of decls that declare an opaque return type to ensure they deploy to a
runtime that supports opaque types.

rdar://problem/50731151
2019-05-15 11:39:53 -07:00
Brent Royal-Gordon
affcefc1ae [ASTMangler] Mangle nested imported error structs correctly
Error structs synthesized by ClangImporter can be renamed using SWIFT_NAME() to syntactically appear anywhere in the type hierarchy with any name, but they should always be mangled as `__C_Synthesized.related decl ‘e’ of <Objective-C enum name>`. Unforunately, when SWIFT_NAME() was used to nest the error struct inside another type, an ASTMangler bug would cause it to be mangled as `<parent type>.related decl ‘e’ of <Objective-C enum name>`, and an ASTDemangler bug would also require a valid parent type. This created a mismatch between the compiler’s and runtime’s manglings which caused crashes when you tried to match the imported error struct in a `catch`.

This PR corrects the compiler bugs so that it generates the mangling the runtime expects. This is theoretically ABI-breaking, but as far as I can determine nobody has shipped the incorrectly mangled names, presumably because they crash when you try to use them.

Fixes <rdar://problem/48040880>.
2019-05-15 11:28:24 -07:00
Joe Groff
edd30153fa Add TypeDecoder test 2019-05-02 17:28:08 -07:00
Slava Pestov
d0d5fbdf39 ASTDemangler: Introduce new getTypeDeclForMangling()
This will replace getDeclFromMangledSymbolName().

Progress on <rdar://problem/47819208>.
2019-02-22 16:13:02 -05:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Slava Pestov
0ddf475a7e ASTDemangler: Propagate @escaping from function type to function parameter 2019-02-04 16:00:12 -05:00
Slava Pestov
1731a482e4 ASTDemangler: Imported typedefs can be nested inside other types 2019-02-04 16:00:12 -05:00
Slava Pestov
161eba721a ASTDemangler: Fix demangling of SILFunctionTypes with @in_constant parameters 2019-01-30 01:28:48 -05:00
Slava Pestov
36d3f47388 ASTDemangler: Preserve generic arguments for bound generic Objective-C classes
MetadataLookup gives special treatment to imported Objective-C classes,
since there's no nominal type descriptor and metadata is obtained
directly by calling into the Objective-C runtime.

Remote reflection also gives special treatment to imported Objective-C
classes; they don't have field descriptors.

However, the ASTDemangler needs to treat them like ordinary classes,
in particular it wants to preserve the generic arguments here so that
we can round-trip debug info.
2019-01-30 01:28:48 -05:00
Slava Pestov
9c8a5b599e ASTDemangler: Fix demangling of weak/unowned/unowned(unsafe)
The check here was incorrect because we might have an optional of a
reference type as well. Just remove the check to keep things simple.
2019-01-29 21:57:06 -05:00
Slava Pestov
4a74bf4ba1 ASTDemangler: Add support for lowered function types 2019-01-29 21:55:57 -05:00
Slava Pestov
13a50c2d2d ASTDemangler: Add support for lowered metatypes 2019-01-29 19:15:17 -05:00
Slava Pestov
fce933910d ASTDemangler: Implement types in generic local context
If we nest a type inside a local context inside a generic type,
we have to look through the local context(s) to find the outer
generic type when stripping off generic arguments.

We don't support nominal types inside generic local context
right now, but this can happen with type aliases.
2019-01-29 19:15:17 -05:00
Slava Pestov
81aad59644 ASTDemangler: Add test for private type in extension of foreign type
This was one of the cases that TypeReconstruction did not support;
let's make sure its covered by a test.
2019-01-29 19:15:17 -05:00
Slava Pestov
80b225d6e8 Fix test/TypeDecoder/foreign_types.swift for 32-bit
NSSize is not always aliased to CGSize; on 32-bit platforms it is its own type.
Instead, let's just define our own type.
2019-01-28 15:29:12 -05:00
Slava Pestov
b6951932b4 ASTDemangler: Implement type alias types
Debug info uses a special mangling where type aliases can be
represented without being desugared; attempt to reconstruct
the TypeAliasType in this case.
2019-01-25 21:59:48 -05:00
Slava Pestov
d80caceec3 ASTDemangler: Fix local type lookup 2019-01-25 21:45:17 -05:00
Slava Pestov
0f5233dad1 ASTDemangler: Implement extension lookup 2019-01-25 21:44:02 -05:00
Slava Pestov
55605ceab9 ASTDemangler: Implement DynamicSelfType 2019-01-25 21:44:02 -05:00
Slava Pestov
9516575d1c ASTDemangler: Simplify createBoundGenericType()
It's clever how it leverages the type checker to check generic arguments,
but calling checkGenericArguments() would have been simpler, and it doesn't
work for interface types anyway, so we would fail to demangle those.

Let's just cut this all out for now and build a BoundGenericType directly.
2019-01-25 21:44:02 -05:00
Slava Pestov
bbe6a56e22 ASTDemangler: Implement builtin types 2019-01-25 21:44:02 -05:00
Slava Pestov
2d21233378 ASTDemangler: Implement unresolved DependentMemberType
The debug mangling emits these when the type parameter only
conforms to one protocol having an associated type with this
name.
2019-01-25 21:44:02 -05:00