Commit Graph

21693 Commits

Author SHA1 Message Date
Hamish Knight
3367d8b3d1 [Sema] Remove workaround from TypeExpr::createForSpecializedDecl
This no longer seems to be necessary now that we
eagerly open UnboundGenericTypes in
`resolveTypeReferenceInExpression`.
2024-09-13 11:30:06 +01:00
Kavon Farvardin
793b46f917 ASTMangler: sink fix to be more safe
My previous fix in `6f6a46f` was the correct fix in theory, but in
practice it could accidentally change the mangling of something I
haven't considered, which would break ABI with Swift 6.0

I've narrowed that fix here to only affect dependent conformances
specifically for Copyable/Escapable. The existing code in
`appendDependentProtocolConformance` would always reach a trap because
we're mangling a conformance path that ends with Copyable/Escapable.

We can assume no such symbol has been successfully been mangled before,
thanks to the pre-existing skip in `conformanceRequirementIndex`, so
there's no risk of ABI change.

rdar://135310019
2024-09-12 10:21:11 -07:00
Alejandro Alonso
718bba486a Merge pull request #76404 from Azoy/integer-type-parsing-fixes
[Parse] Fix type parsing when preceded by '-'
2024-09-12 09:26:57 -07:00
Slava Pestov
2c1297e5a2 AST: Simplify GenericSignatureImpl::isRequirementSatisfied() 2024-09-12 11:49:01 -04:00
Alexis Laferrière
ad94d55b62 Merge pull request #76410 from xymus/public-module-name-fix-loaded
Sema: Fix `getPublicModuleName` to look only at loaded modules
2024-09-12 08:27:12 -07:00
Alexis Laferrière
f9a8a674c6 Sema: fix getPublicModuleName to look only at loaded modules
When onlyIfImported is true, we should return the public module name
only when the public facing module is already imported. Replace the
call to getModuleByIdentifier with getLoadedModule to prevent trigering
loading that module.

Also fix the test where the CHECK lined ended up matching itself from
the diagnostics output.
2024-09-11 13:12:58 -07:00
Doug Gregor
b272a05ea9 Merge pull request #76363 from DmT021/wp/print-diagnostic-groups
[Diagnostics] Add -print-diagnostic-groups flag
2024-09-11 13:04:07 -07:00
Alejandro Alonso
6f83e3c28f Fix type parsing when preceeded by '-' 2024-09-11 10:28:44 -07:00
Dmitrii Galimzianov
a8b71ea97f Add -print-diagnostic-groups flag
This change adds the `-print-diagnostic-groups` flag as described by SE-0443.
2024-09-11 13:34:42 +02:00
Meghana Gupta
0dde044e89 Merge pull request #76256 from meg-gupta/lifetimeattrsyntax
Introduce @lifetime attribute to specify lifetime dependence on function declarations
2024-09-10 19:49:32 -07:00
Alexis Laferrière
2aabffa8a0 Merge pull request #76358 from xymus/authoritative-import
Sema: Pick the most relevant import for diagnostics about the source of a decl
2024-09-10 16:25:06 -07:00
Allan Shortlidge
3d47e1cdd8 Merge pull request #76336 from tshortli/member-import-visibility-ranking
ConstraintSystem: Use scoring to implement MemberImportVisibility
2024-09-10 13:28:30 -07:00
Gábor Horváth
863d2e4656 Merge pull request #75477 from swiftlang/gaborh/nested-structs
[cxx-interop] Support nested structs
2024-09-10 18:18:30 +01:00
Allan Shortlidge
c868378d96 ConstraintSystem: Use scoring to implement MemberImportVisibility.
Previously, the constraint solver would first attempt member lookup that
excluded members from transitively imported modules. If there were no viable
candidates, it would perform a second lookup that included the previously
excluded members, treating any candidates as unviable. This meant that if the
member reference did resolve to one of the unviable candidates the resulting
AST would be broken, which could cause unwanted knock-on diagnostics.

Now, members from transitively imported modules are always returned in the set
of viable candidates. However, scoring will always prioritize candidates from
directly imported modules over members from transitive imports. This solves the
ambiguities that `MemberImportVisibility` is designed to prevent. If the only
viable candidates are from transitively imported modules, though, then the
reference will be resolved successfully and diagnosed later in
`MiscDiagnostics.cpp`. The resulting AST will not contain any errors, which
ensures that necessary access levels can be computed correctly for the imports
suggested by `MemberImportVisibility` fix-its.

Resolves rdar://126637855.
2024-09-10 09:47:42 -07:00
Gabor Horvath
94b466656e [cxx-interop] Support nested structs
It is really involved to change how methods and classes are emitted into
the header so this patch introduces the impression of nested structs
through using statements and still emits the structs themselves as top
level structs. It emits them in their own namespace to avoid name
collisions. This patch also had to change some names to be fully
qualified to avoid some name lookup errors in case of nested structs.
Moreover, nesting level of 3 and above requires C++17 because it relies
on nested namespaces. Only nested structs are supported, not nested
classes.

Since this patch is already started to grow quite big, I decided to put
it out for reviews and plan to address some of the shortcomings in a
follow-up PR.

rdar://118793469
2024-09-10 13:22:17 +01:00
Meghana Gupta
7af6c11e7e Store parsed @lifetime attribute on the function type 2024-09-09 22:02:44 -07:00
Meghana Gupta
b610036e6a [NFC] Refactor out common utilities to be used by lifetime attribute 2024-09-09 22:02:44 -07:00
Meghana Gupta
2b011b0a3a [NFC] Rename/reorg LifetimeDependence utils 2024-09-09 22:02:44 -07:00
Meghana Gupta
e61d87c01c Add support for parsing @lifetime attribute to specify lifetime dependencies on declarations 2024-09-09 22:02:42 -07:00
Meghana Gupta
a7518ac3d9 Merge pull request #76255 from meg-gupta/disablemangling
Delete lifetime dependence mangling
2024-09-09 19:59:16 -07:00
Doug Gregor
50f81234f1 Merge pull request #76350 from DougGregor/archetype-properties-consolidation
Consolidate get(Opaque|Opened)TypeArchetypeProperties into archetypeProperties()
2024-09-09 18:31:25 -07:00
Kavon Farvardin
034dab8af2 Merge pull request #76293 from kavon/ncgenerics-opaque-dependent-conformance-mangling
ASTMangler: skip mangling Copyable dependents
2024-09-09 18:20:32 -07:00
Allan Shortlidge
60f049d9ac Merge pull request #76349 from tshortli/resolve-warnings
Resolve recently introduced warnings
2024-09-09 18:17:09 -07:00
Alexis Laferrière
9eaa0e5df8 Sema: getImportAccessLevel returns an authoritative import
Change how we pick the one import to point to in diagnostics about a
referenced decl. This mostly affects the warning about superfluously
public imports. This warning encourages the developer to delete imports,
let's make sure we push them towards deleting the right ones.

The order was previously not well defined, except that we always picked
one of the most public imports.

We now prioritize imports in this order:
1. The most public import. (Preserving the current behavior in
   type-checking of access-level on imports)
2. The import of the public version of the module defining the decl,
   determined via export_as or -public-module-name.
3. The import of the module defining the decl.
4. The first import in the sources bringing the decl via reexports.
5. Any other import, usually via an @_exported import in a different file.

rdar://135357155
2024-09-09 16:57:46 -07:00
Alexis Laferrière
8d28ed4fa9 Merge pull request #76269 from xymus/public-module-name
Diagnostics: Intro the public module name concept to hide support modules from clients
2024-09-09 16:57:12 -07:00
Kavon Farvardin
6f6a46f225 ASTMangler: skip mangling Copyable dependents
Typically, a conformance that is dependent on a conformance to a marker
protocol never reaches this point in the compiler, where we're mangling
the metadata for an opaque return type.

But with the invertible protocols like Copyable, we do permit them, so
we should avoid mangling Copyable as that's generally ABI incompatible
with existing code.

resolves rdar://135310019
2024-09-09 14:36:54 -07:00
Doug Gregor
b597f6bed4 Consolidate get(Opaque|Opened)TypeArchetypeProperties into archetypeProperties() 2024-09-09 13:02:49 -07:00
Allan Shortlidge
896ed660e1 AST: Suppress unused function and -Wreturn-type-c-linkage warnings. 2024-09-09 12:48:28 -07:00
Doug Gregor
08e339b7b4 Merge pull request #74466 from DmT021/wp/no-warning-as-error
[Diagnostics] Add -no-warning-as-error to except a specific warning from being treated as an error
2024-09-09 09:35:05 -07:00
swift-ci
290cda09b1 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-09 09:15:25 -07:00
Doug Gregor
c0fea1f224 Disable printing of #ifs from the AST
The option to print #ifs defaulted to "on", but was disabled in most of
the actual compiler inputs that mattered, and the results weren't ever
actually used. Remove the option so we never print #ifs.
2024-09-08 09:52:37 -07:00
swift-ci
b04e01e9ad Merge remote-tracking branch 'origin/main' into rebranch 2024-09-07 22:14:25 -07:00
Ellie Shin
5f41d084c7 Merge pull request #76315 from swiftlang/elsh/check-interface-srckind
[PackageInterface] Fix isInterfacePackageEffectivelyPublic.
2024-09-07 22:06:37 -07:00
Tony Allevato
aebe2ab309 Fix missing operators in synthesized == impls printed by -print-ast.
`visitBinaryExpr` wasn't handling `UnresolvedDeclRefExpr` nodes, which the
synthesized `==` implementation uses to compare fields/payloads. Also fixed
the test that wasn't catching it since it also left out the operators.
2024-09-07 20:13:13 -04:00
elsh
bd9272c695 [PackageInterface] Fix isInterfacePackageEffectivelyPublic.
ValueDecl::isInterfacePackageEffectivelyPublic is used to check if a package decl in
interface file can be skipped for typecheck; if the decl is inlinable and in public or
private interface, it should be allowed to skip. This PR adds a missing check which
looks up the Interface source kind.

Resolves rdar://135388095
2024-09-07 08:49:23 -07:00
Dmitrii Galimzianov
28883b6654 [Diagnostics] Add -[no-]warning-as-error flags for precise control over warning behavior
This commit adds new compiler options -no-warning-as-error/-warning-as-error which allows users to specify behavior for exact warnings and warning groups.
2024-09-07 01:14:43 +02:00
swift-ci
2e640fa861 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-06 14:34:39 -07:00
Augusto Noronha
5f851b664d Merge pull request #76065 from augusto2112/clash-abi-name-demangler
Account for multiple modules when looking up the DeclContext of a type
2024-09-06 14:22:24 -07:00
swift-ci
c89dbc5087 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-06 13:54:37 -07:00
Hamish Knight
1caaeeb83e Merge pull request #76295 from hamishknight/capturent
Remove `shouldWalkCaptureInitializerExpressions`
2024-09-06 21:39:51 +01:00
swift-ci
99519cb291 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 22:53:33 -07:00
Meghana Gupta
10057523ec Delete lifetime dependence mangling
Mangling this information for future directions like component lifetimes
becomes complex and the current mangling scheme isn't scalable anyway.

Deleting this support for now.
2024-09-05 22:03:58 -07:00
Alexis Laferrière
c70162c703 Merge branch 'main' into public-module-name 2024-09-05 20:02:07 -07:00
Allan Shortlidge
a770371a80 ModuleInterface: Print patterns with opaque result types using some keyword.
Previously, the opaque types in patterns were printed using their full stable
reference which cannot be resolved when parsing a swiftinterface.

Resolves rdar://127771885.
2024-09-05 16:08:42 -07:00
Allan Shortlidge
2788c1dac1 AST: Introduce PrintWithOpaqueResultTypeKeywordRAII utility. 2024-09-05 16:08:42 -07:00
swift-ci
da55e84c74 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 15:35:33 -07:00
Alejandro Alonso
45d7ea39a5 Merge pull request #75518 from Azoy/integer-generics
Implement Value generics
2024-09-05 15:33:46 -07:00
swift-ci
a5967570e0 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 15:15:02 -07:00
Doug Gregor
9d3c265572 Merge pull request #76287 from DougGregor/local-let-of-tuple-type
Expand the tuple "hack" for initializable values to local tuples
2024-09-05 15:07:04 -07:00
Hamish Knight
f5557c4c10 Remove shouldWalkCaptureInitializerExpressions
There doesn't seem to be any reason we can't
walk the PatternBindingDecls directly here.
2024-09-05 22:27:15 +01:00