Commit Graph

1923 Commits

Author SHA1 Message Date
Ahmed Elrefaey
1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01:00
Hamish Knight
ff200137a8 [AST] Add ErrorType originator for PlaceholderType 2025-08-30 16:05:01 +01:00
Slava Pestov
1716832a7a AST: Remove most usages of AbstractFunctionDecl::hasDynamicSelfResult() 2025-08-27 15:34:26 -04:00
Allan Shortlidge
0bba9bbc26 AST: Make the decl associated with an AvailabilityDomain a ValueDecl.
A decl that represents an `AvailabilityDomain` should always be a `ValueDecl`.
2025-08-14 11:35:00 -07:00
Allan Shortlidge
dacd986f1b AST: Introduce a warning group for a versioned #if canImport diagnostic.
This allows developers to control whether these diagnostics are considered
errors when `-warnings-as-errors` is specified.

Resolves rdar://157694667.
2025-08-11 16:06:06 -07:00
John McCall
9a3ba0e0fc Assert immediately if someone tries to build a SILFunctionType with
multiple isolated parameters.
2025-07-31 18:21:09 -04:00
Slava Pestov
ee440f3c91 AST: Remove MakeAbstractConformanceForGenericType
While the intent behind this functor was noble, it has grown in complexity
considerably over the years, and it seems to be nothing but a source of
crashes in practice. I don't want to deal with it anymore, so I've decided
to just subsume all usages with LookUpConformanceInModule instead.
2025-07-15 16:34:11 -04:00
Allan Shortlidge
96d0450d62 Merge pull request #82940 from tshortli/silgen-custom-availability-domain-query
ClangImporter: Generate and call custom availability domain predicates
2025-07-10 13:16:14 -07:00
Allan Shortlidge
3d722e1919 ClangImporter: Generate and call custom availability domain predicates.
When importing custom availability domains with dynamic predicates from Clang
modules, synthesize predicate functions for `if #available` queries and call
them when generating SIL.

Resolves rdar://138441312.
2025-07-10 08:15:01 -07:00
Slava Pestov
3c6b2a20a5 AST: Allocate BuiltinFixedArrayType in the solver arena if needed 2025-07-09 22:16:14 -04:00
Anthony Latsis
ad8c52237c Sema: Fix the insertion location for conformances attributes 2025-06-24 14:49:03 +01:00
Hamish Knight
6257828593 [AST] Replace type variables and placeholders in original ErrorTypes
Turns out we can also get solver-allocated original ErrorTypes through
type resolution. Given the original type is only used for
printing/debugging, let's just fold away any type variables and
placeholders into UnresolvedType (which print as placeholders). This
matches what `Solution::simplifyType` does.
2025-06-17 12:09:25 +01:00
Hamish Knight
215d63923b [AST] Enforce we don't get solver-allocated ErrorTypes
I don't believe we ever form these types, and if we did we aren't
correctly handling them in `Solution::simplifyType`. Let's just
enforce we don't get them.
2025-06-12 12:11:19 +01:00
Slava Pestov
0e1561f05a Sema: Change a couple of Identifier usages to DeclName instead 2025-05-30 14:43:48 -04:00
Hamish Knight
edca7c85ad Adopt ABORT throughout the compiler
Convert a bunch of places where we're dumping to stderr and calling
`abort` over to using `ABORT` such that the message gets printed to
the pretty stack trace. This ensures it gets picked up by
CrashReporter.
2025-05-19 20:55:01 +01:00
Slava Pestov
be860a8e9c AST: Fix latent bug in TypeTransformer::transformPackElementType() 2025-05-15 12:22:21 -04:00
Ian Anderson
a6e517e943 [Driver][Frontend] -nostdimport and -nostdlibimport should remove the default framework search paths
-nostdimport and -nostdlibimport only remove the toolchain and usr/lib/swift search paths, and they leave the framework search paths intact. That makes it impossible to get a fully custom SDK environment. Make their behavior match clang's -nostdinc/-nostdlibinc behavior: treat framework and non-framework paths the same. In other words, -nostdinc removes *all* compiler provided search paths, and -nostdlibinc removes *all* SDK search paths.

Rename SkipRuntimeLibraryImportPaths to SkipAllImportPaths, and ExcludeSDKPathsFromRuntimeLibraryImportPaths to SkipSDKImportPaths to reflect their updated behavior.

Move the DarwinImplicitFrameworkSearchPaths handling from SearchPathOptions to CompilerInvocation, where RuntimeLibraryImportPaths is managed. Rename it to just ImplicitFrameworkSearchPaths, and filter for Darwin when it's set up so that all of the clients don't have to do Darwin filtering themselves later.

rdar://150557632
2025-05-12 22:33:48 -07:00
Hamish Knight
b53c411655 [Frontend] Avoid storing StringRef values in ModuleAliasMap
Previously we would insert StringRefs that reference the keys in the
map, but that breaks if the invocation ever gets copied. Switch to
`std::string`.

rdar://148130166
2025-05-09 19:49:50 +01:00
Erik Eckstein
774d869517 Fix some compiler warnings 2025-05-06 12:32:56 +02:00
Artem Chikin
a448cef35f Include system-ness of framework and import search paths in the PCH hash
This hash is also used for the dependency scanning hash. In both cases, PCH contents may differ based on whether a certain module they depend on is found in a system or non-system search path. In dependency scanning, systemness should cause a full change of scanning context requiring a from-scratch scan.

Resolves rdar://150334077
2025-05-01 16:39:12 -07:00
John Hui
b2fe628228 Merge pull request #81016 from j-hui/swift-function-as-template-arg
[cxx-interop] Allow C++ function templates to be instantiated with Swift closures
2025-04-30 14:15:11 -07:00
Slava Pestov
6b4710ed22 Merge pull request #81142 from slavapestov/more-type-subst-cleanup
Clean up duplicated opened existential archetype handling in SIL and more
2025-04-30 02:42:57 -04:00
John Hui
fee1dd3e49 [NFC] Make templateArgument a template argument
This Boolean flag is used in ClangTypeConverter to indicate whether
a type is being converted in the context of a template type parameter.
This parameter can be made a template parameter because it is always
a compile-time constant.
2025-04-29 23:17:23 -07:00
John Hui
284de98744 [cxx-interop] Allow C++ function templates to be instantiated with Swift closures
Swift started to explicitly forbid the instantiation of C++ function
templates with arbitrary types in #77430, because many types cause the
Swift compiler to crash. However, those checks prevented them from being
instantiated with Swift closures (which were previously fine), causing
a regression.

This patch relaxes the convertTemplateArgument() function to also allow
converting Swift function types, and adds some tests to make sure doing
so is fine.

This patch also does some cleanup of existing tests checking the
instantiation of various types, and adds testing for C function pointers
and Obj-C blocks.

rdar://148124104
2025-04-29 23:17:14 -07:00
Slava Pestov
e1fc29193d AST: Add GenericTypeParamType::getWeight()
This is currently always 0, but can be set to 1.
2025-04-29 13:55:29 -04:00
Slava Pestov
cf1572c65b AST: Add ASTContext::TheSelfType for convenience 2025-04-28 11:49:50 -04:00
Doug Gregor
53ca902267 [Strict memory safety] Type alias types are only unsafe if their underlying type is 2025-04-19 10:38:07 -07:00
Doug Gregor
8ec52c825c [Strict memory safety] Nested types are safe/unsafe independent of their enclosing type
When determining whether a nested type is safe, don't consider whether
its enclosing type is safe. They're independent.
2025-04-19 09:49:22 -07:00
Allan Shortlidge
abac42b759 Serialization: Encode custom availability domains.
When serializing `@available` attributes, if the attribute applies to a custom
domain include enough information to deserialize the reference to that domain.

Resolves rdar://138441265.
2025-04-08 08:53:42 -07:00
Joe Groff
b4fb5296f9 Merge pull request #80519 from jckarter/canonicalize-integer-generic-parameters
Canonicalize different spellings of the same integer generic parameter.
2025-04-04 09:25:18 -07:00
Joe Groff
5a09c0b4e0 Canonicalize different spellings of the same integer generic parameter.
`Foo<256>`, `Foo<2_56>`, and `Foo<0x100>` are all canonically the same type.
Fixes rdar://144736386.
2025-04-03 18:56:00 -07:00
Slava Pestov
7399eeb602 AST: Remove type parameter from ProtocolConformanceRef::getWitnessByName() 2025-04-03 17:35:33 -04:00
Slava Pestov
00766f7deb AST: Remove type parameter from ProtocolConformanceRef::getTypeWitnessByName() 2025-04-03 17:35:32 -04:00
Artem Chikin
2e31e4692f Merge pull request #80414 from artemcm/RestorePriorCanImportBehaviour
[Explicit Module Builds] Switch versioned `canImport` to return `true` when encountering unversioned candidate
2025-04-02 09:02:56 -07:00
Artem Chikin
c9ba79c8da [Dependency Scanning] Always record best version of discovered 'canImport'-ed modules
Suppose module 'Foo' exists in the search paths and specifies user module version '1.0'.

If the first encountered 'canImport' query is unversioned:
...

Followed by a versioned one:
...

The success of the first check will record an unversioned successful canImport, which will cause the second check to evaluate to 'true', which is incorrect.

This change causes even unversioned 'canImport' checks to track and record the discovered user module version.
2025-04-01 14:55:37 -07:00
Artem Chikin
d2ea34c0bd [Explicit Module Builds] Switch versioned 'canImport' to return 'true' when encountering unversioned candidate
Specifically, when the scanner found a candidate which does not carry a user-specified version, it will pass '-module-can-import Foo' to compilation. During compilation, if the check is versioned but the candidate is unversioned, evaluate the check to 'true' to restore the behavior we had with implicitly-built modules.

Resolves rdar://148134993
2025-03-31 16:39:02 -07:00
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Karoy Lorentey
5583e6916c Merge pull request #73258 from lorentey/you-cannot-escape-optionals
[stdlib] Generalize some constructs for non-escapable types
2025-03-27 20:02:00 -07:00
Slava Pestov
d61c21ba2b Merge pull request #80304 from slavapestov/not-so-abstract-anymore
AST: Check subject type in ProtocolConformanceRef::forAbstract()
2025-03-27 08:21:16 -04:00
Slava Pestov
09ed91fab5 AST: Fix some comments 2025-03-26 17:45:38 -04:00
Slava Pestov
cc05e1e79a AST: Check subject type in ProtocolConformanceRef::forAbstract() 2025-03-26 12:29:35 -04:00
Karoy Lorentey
0cb4b1401e [AST] Generalize is_same_metatype builtin to take unconstrained metatypes
The builtin’s current is signature is:

```
(Any.Type, Any.Type) -> Bool
```

This needs to be changed to this:

```
(any (~Copyable & ~Escapable).Type, any (~Copyable & ~Escapable).Type) -> Bool
```

This requires a bit of support work in AST synthesis.

rdar://145707064

Co-authored-by: Alejandro Alonso <alejandro_alonso@apple.com>
2025-03-24 12:16:11 -07:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Doug Gregor
2a7de1b559 Store the conforming type within an abstract ProtocolConformanceRef
An "abstract" ProtocolConformanceRef is a conformance of a type
parameter or archetype to a given protocol. Previously, we would only
store the protocol requirement itself---but not track the actual
conforming type, requiring clients of ProtocolConformanceRef to keep
track of this information separately.

Record the conforming type as part of an abstract ProtocolConformanceRef,
so that clients will be able to recover it later. This is handled by a uniqued
AbstractConformance structure, so that ProtocolConformanceRef itself stays one
pointer.

There remain a small number of places where we create an abstract
ProtocolConformanceRef with a null type. We'll want to chip away at
those and establish some stronger invariants on the abstract conformance
in the future.
2025-03-23 20:53:48 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Allan Shortlidge
bff9169a7b Merge pull request #80176 from tshortli/remove-is-active-for-target-platform
AST: Fix `AvailabilityContext` platform range for certain targets
2025-03-21 05:07:53 -07:00
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Allan Shortlidge
592b70f00f AST: Fix AvailabilityContext platform range for certain targets.
https://github.com/swiftlang/swift/pull/79807 caused a regression in which
`AvailabilityContext` stopped tracking the available version range for the
active platform domain for certain platforms. Fix this by reverting to checking
`AvailabilityDomain::isActive()` to determine when a given platform
`AvailabilityDomain` represents the target platform. The compiler's existing
mapping from target triple to platform domain is incomplete and it's not clear
to me whether fixing that could cause other regressions.

Resolves rdar://147413616.
2025-03-20 16:26:54 -07:00
Doug Gregor
4cc6411d05 Merge pull request #79983 from DougGregor/isolated-conformances-alignment
Align isolated conformances with the current proposal
2025-03-13 22:40:36 -07:00