Commit Graph

7889 Commits

Author SHA1 Message Date
eeckstein
50b5ecf042 Merge pull request #84013 from eeckstein/canonical-substitution-maps
SIL: only use canonical substitution maps in SIL
2025-08-30 20:30:07 +02:00
Hamish Knight
9b3d2a00c0 Merge pull request #84005 from hamishknight/duet 2025-08-30 17:41:53 +01:00
Hamish Knight
d7fea157a1 [IDE] Remove fallback type-checking logic
This should no longer be necessary, rip it out.
2025-08-30 14:08:42 +01:00
Erik Eckstein
6df033b298 SIL: only use canonical substitution maps in SIL
* When constructing instructions which have substitution maps: initialize those with the canonical SubstitutionMap
* Also initialize SILFunction::ForwardingSubMap with the canonical one

Non-canonical substitution maps may prevent generic specializations.
This fixes a problem in Embedded Swift where an error is given because a function cannot be specialized, although it should.

https://github.com/swiftlang/swift/issues/83895
rdar://159065157
2025-08-29 22:31:04 +02:00
Hamish Knight
a9e339b973 [CS] Strengthen check for completion in CSApply
Turns out we don't always set a completion callback for some unqualified
completion positions. Upgrade the check for a completion callback to
a check for a completion buffer to account for this. This avoids
unnecessary type-checker work as well as fixing a couple of
double-type-checking crashers.
2025-08-29 16:20:06 +01:00
Hamish Knight
28772234bc [CS] Allow contextual types with errors
Previously we would skip type-checking the result expression of a
`return` or the initialization expression of a binding if the contextual
type had an error, but that misses out on useful diagnostics and
prevents code completion and cursor info from working. Change the logic
such that we open ErrorTypes as holes and continue to type-check.
2025-08-29 15:04:20 +01:00
Hamish Knight
1b0eed22be [CS] Better propagate holes from contextual types
Eagerly bind invalid type references to holes and propagate contextual
type holes in `repairFailures`. This avoids some unnecessary diagnostics
in cases where we have an invalid contextual type.
2025-08-29 15:04:20 +01:00
Hamish Knight
23ee6fb853 Merge pull request #83982 from hamishknight/unattached-fix
[Completion] Avoid type-checking parent closure for unattached node
2025-08-29 10:23:40 +01:00
Hamish Knight
a309fc0ac9 Merge pull request #83992 from hamishknight/tweak-assert 2025-08-29 06:08:57 +01:00
Slava Pestov
4f6d7f40ec Merge pull request #83986 from slavapestov/fix-rdar158774099
AST: Remove old hack that appears to be obsolete and revert a revert of another fix
2025-08-28 23:59:46 -04:00
Hamish Knight
b90494b9ec Merge pull request #83985 from hamishknight/null-ext
[ASTDumper] Check null for `getExtendedTypeRepr`
2025-08-29 02:34:18 +01:00
Hamish Knight
2f5cfad7bc Merge pull request #83974 from hamishknight/reprap
[Sema] Avoid marking TypeRepr invalid with `SilenceErrors`
2025-08-29 01:09:55 +01:00
Hamish Knight
627f41ccbc [CS] Fix an overly strict assert
`matchExistentialTypes` can handle existential metatypes, fix the
assert to handle that.
2025-08-29 00:17:14 +01:00
Slava Pestov
672135b053 AST: Remove old hack that appears to be obsolete
The FIXME was originally introduced in 2017 by commit c0805a2bc8.

Good riddance!
2025-08-28 16:51:49 -04:00
Hamish Knight
dfc940f82d [ASTDumper] Check null for getExtendedTypeRepr
This can be null for `extension {}`.
2025-08-28 20:46:16 +01:00
Hamish Knight
3d9b7f3ac2 [Completion] Avoid type-checking parent closure for unattached node
We should have already type-checked a parent closure, and we wouldn't
be able to correctly locate the node anyway since it's not actually
part of the AST. While here, also walk up to the parent-most closure
instead of recursing to avoid unnecessary stack frames for nested
closures.
2025-08-28 19:30:54 +01:00
Hamish Knight
79e8a6cb3c [Sema] Avoid marking TypeRepr invalid with SilenceErrors
Pattern resolution currently invokes type resolution with this flag
since it's trying to see if it can treat a given expression as a
TypeRepr for e.g an enum pattern. Make sure we don't `setInvalid` on
such TypeRepr nodes since that will avoid diagnosing in cases where
the node also then gets treated as a TypeRepr for an ExprPattern,
where we actually want the diagnostic emitted.
2025-08-28 15:31:48 +01:00
Hamish Knight
0eae70cd84 Merge pull request #83961 from hamishknight/null-and-void
[IDE] Use `nullableTypesEqual` in `AfterPoundExprCompletion::sawSolutionImpl`
2025-08-28 13:06:53 +01:00
Hamish Knight
7296c82625 Merge pull request #83944 from hamishknight/walkerr
[AST] Walk ErrorExpr's original expr in ASTWalker
2025-08-28 11:48:41 +01:00
Hamish Knight
4aeb7e1b52 [IDE] Use nullableTypesEqual in AfterPoundExprCompletion::sawSolutionImpl
Avoid crashing if we can't compute the expected type.
2025-08-28 00:33:54 +01:00
Evan Wilde
5eb727b668 Merge pull request #83908 from etcwilde/ewilde/freebsd-disable-known-failures
FreeBSD: Disable known/in-progress test failures
2025-08-27 10:30:53 -07:00
Hamish Knight
7e22297b71 [AST] Walk ErrorExpr's original expr in ASTWalker
We set an original expression on ErrorExpr for cases where we have
something semantically invalid that doesn't fit into the AST, but is
still something that the user has explicitly written. For example
this is how we represent unresolved dots without member names (`x.`).
We still want to type-check the underlying expression though since
it can provide useful diagnostics and allows semantic functionality
such as completion and cursor info to work correctly.

rdar://130771574
2025-08-27 15:27:06 +01:00
Evan Wilde
cc4f323b71 FreeBSD: TSan: main thread finished with ignores enabled
Disabling several TSan tests that are failing due to a bug in the thread
sanitizer. TSan appears to be setting the thread to ignored in the
`thr_exit` interceptor, and then immediately checking that the thread
isn't being ignored, and dying.

```
ThreadSanitizer: main thread finished with ignores enabled
  One of the following ignores was not ended (in order of probability)
```

rdar://158450231
2025-08-25 15:18:20 -07:00
Eric Miotto
aa927b44b1 Merge pull request #83840 from edymtt/edymtt/disable-some-tests-on-backdeploy-configurations
Restrict a few tests to run against the just built runtime
2025-08-25 11:59:16 -07:00
Hamish Knight
0c16c00bb4 [Sema] Resolve interface type in ExtendedTypeRequest
Resolving only a structural type meant we weren't checking generic
constraints, allowing invalid extensions to get past the type-checker.
Change to resolve an interface type.
2025-08-24 11:49:14 +01:00
Hamish Knight
0c29284098 [test] Add some more known crashers 2025-08-22 00:54:18 +01:00
Hamish Knight
8c6a1f8878 [test] Update a couple of crasher signatures 2025-08-21 09:46:53 +01:00
Eric Miotto
d6df83d8fa Restrict a few tests to run against the just built runtime
Addresses rdar://158442561
2025-08-20 14:50:47 -07:00
nate-chandler
d1637af144 Merge pull request #83789 from nate-chandler/nfc/20250818/1
[NFC] Renamed three SIL utilities.
2025-08-20 13:25:04 -07:00
Nate Chandler
aa85694237 [NFC] OSSACompleteLifetime: Renamed. 2025-08-18 09:45:19 -07:00
Nate Chandler
d8710fc83d [OSSACompleteLifetime] Fix error message. 2025-08-18 08:44:10 -07:00
Pavel Yaskevich
a5649a12e5 Merge pull request #83735 from xedin/rdar-158159462
[CSOptimizer] Add support for opened existential arguments
2025-08-18 00:16:24 -07:00
Hamish Knight
45065f3069 [Diags] Allow multiple in-flight diagnostics
Lift the limitation of a single active diagnostic, which was a pretty
easy-to-hit footgun. We now maintain an array of active in-flight
diagnostics, which gets flushed once all them have ended.
2025-08-17 11:48:21 +01:00
Hamish Knight
89787e24b6 Merge pull request #83766 from hamishknight/fifty-thousand-ants
[CS] Use apply component locator for `verifyThatArgumentIsHashable`
2025-08-16 05:20:51 +01:00
nate-chandler
4becc5dd15 Merge pull request #83756 from nate-chandler/assert/20250815/1
[OSSACompleteLifetime] Promote assertion.
2025-08-15 19:34:46 -07:00
Hamish Knight
4423399fce [CS] Use apply component locator for verifyThatArgumentIsHashable
For a method key path use the locator for the apply itself rather
than the member, ensuring we handle invalid cases where the apply is
the first component, and providing more accurate location info.
2025-08-15 21:30:22 +01:00
Nate Chandler
0a6c712195 [OSSACompleteLifetime] Flag disables leak checking
The utility effectively determines whether a value leaks as part of its
work, a subset of the checking done by the ownership verifier.  Disable
that checking when the flag that disables the ownership verifier is
passed.
2025-08-15 11:06:18 -07:00
Hamish Knight
8d80454591 [test] Record whether a crasher is a stack overflow 2025-08-15 17:09:58 +01:00
Nate Chandler
c197ca107e [OSSACompleteLifetime] Promote assertion.
Use llvm::report_fatal_error instead.  Also, add logging to clarify that
reaching this point is a bug in the incoming SIL.
2025-08-15 09:09:04 -07:00
Pavel Yaskevich
0d33af78ca [CSOptimizer] Add support for opened existential arguments
Check whether it would be possible to match a parameter type
by opening an existential type of the candidate argument.

Resolves: rdar://158159462
2025-08-15 00:14:51 -07:00
Hamish Knight
5e27e83456 Merge pull request #83613 from hamishknight/next-step
[IDE] Perform extension binding after AST mutation
2025-08-13 22:37:56 +01:00
Pavel Yaskevich
1060643278 Merge pull request #83687 from xedin/rdar-156955193
[TypeCheckEffects] AbstractFunction: Parameter types should be mapped…
2025-08-13 13:40:09 -07:00
nate-chandler
a868d92ad0 Merge pull request #83683 from nate-chandler/rdar158083136
[InlineArray] Fix outlining metadata collection.
2025-08-13 03:26:32 -07:00
Pavel Yaskevich
32b97d0e2a [TypeCheckEffects] AbstractFunction: Parameter types should be mapped into context
Parameter type could be represented by an associated type which is
bound to a concrete type by an extension, `AbstractFunction::getType()`
should map it into context before returning because the construct is
that it always produces a function type.

Resolves: rdar://156955193
2025-08-12 17:29:07 -07:00
Nate Chandler
3078e95074 [InlineArray] Fix outlining metadata collection.
The metadata of the element type is required for outlining.

rdar://158083136
2025-08-12 14:22:50 -07:00
Hamish Knight
ead2c0c43a Merge pull request #83634 from hamishknight/invalid-check 2025-08-12 09:36:22 +01:00
Karoy Lorentey
14b9b80746 Merge pull request #83314 from lorentey/pushing-word-boundaries
[stdlib] Fix implementation of Unicode text segmentation for word boundaries
2025-08-11 11:28:39 -07:00
Hamish Knight
e7098a34b2 [Sema] Remove isInvalid checks from checkAndContextualizePatternBindingInit
The invalid bit on PatternBindingDecl is very coarse grained, it
means any of the possible binding entries could be invalid.
Contextualization can handle invalid code anyway (e.g this is what we
do for `typeCheckBody`), so let's just avoid checking.
2025-08-11 12:55:36 +01:00
finagolfin
e251aea113 [build] Change Foundation macro checks because of #83422 (#83629)
I missed that `build-script` passes back `false` instead, so use the
`true_false` function for broader checking.
2025-08-10 18:29:24 -07:00
Hamish Knight
acf6375d46 Introduce BindExtensionsForIDEInspectionRequest
This allows us to lazily bind extensions after mutating the AST,
ensuring we don't prematurely kick the building of lookup tables.
2025-08-10 23:49:03 +01:00