Commit Graph

757 Commits

Author SHA1 Message Date
Meghana Gupta
827caa9fce XFAIL typechecker test which leads to a cycle in the requirement machine
This PR introduces a `mapTypeIntoContext` in `InterfaceTypeRequest::evaluate` which introduces a cycle in this test.
2024-11-12 12:05:23 -08:00
Kavon Farvardin
53fb8c3570 XFAIL test for minor issue
This test is failing to verify the generic signature for this bogus
 program, because the generic signature isn't minimal. We should
 gracefully handle this situation and still have a minimal signature,
 despite rejecting this program.
2024-03-14 23:10:44 -07:00
Slava Pestov
af8c8f1671 Sema: Remove non-experimental associated type inference 2024-03-07 17:30:17 -05:00
Slava Pestov
3662bb2a28 Remove REQUIRES: asserts from fixed crashers 2024-03-06 21:38:28 -05:00
Slava Pestov
d3aa3a8db9 Adjust XFAILs 2024-02-29 13:55:48 -05:00
Doug Gregor
c142205a50 Resolve an old compiler crasher via the new diagnostic formatter
The old diagnostic formatter would crash on some Fix-Its involving
Unicode characters. The new one does not.
2024-02-19 02:48:37 -10:00
Slava Pestov
c5c6e00d0e Pass -disable-experimental-associated-type-inference in a compiler_crasher pending further investigation 2024-01-25 22:01:44 -05:00
Holly Borla
0708e0efd4 Revert "Tests: Disable failing SwiftUI validation tests" 2022-11-15 09:10:23 -08:00
Allan Shortlidge
b2421aa463 Tests: Disable failing SwiftUI validation tests until rdar://102298208 is fixed. 2022-11-13 16:56:20 -08:00
Anthony Latsis
25e42ca56c Gardening: Migrate test suite to GH issues: validation-test/compiler_crashers_fixed 2022-09-19 22:34:06 +03:00
Nate Chandler
f454717c6e [IRGen] Look through opaque types for protocol witness table lazy access function.
When determining the linkage of protocol witness table lazy access
functions and their cache variables, look through opaque types to find
the underlying decls.

rdar://96194366
2022-07-11 15:21:38 -07:00
Anthony Latsis
7158760dbb Add fixed crasher to close #43187 2022-06-24 05:03:28 +03:00
Slava Pestov
dac8d666ee Stop passing -requirement-machine-{abstract,inferred,protocol}-signatures flags in tests
These flags are now no-ops.
2022-05-10 12:56:17 -04:00
Slava Pestov
226d2c89a0 RequirementMachine: Disable verification in a few highly-invalid compiler_crashers where it's not useful 2022-03-14 12:33:18 -04:00
Slava Pestov
a61f67a0e8 RequirementMachine: Hack to allow protocol typealiases to appear in associated type inheritance clauses
If you have something like

    protocol P {
      typealias A = C

      associatedtype T : A
    }

    class C {}

Then ::Structural resolution of 'A' in the inheritance clause will
produce a DependentMemberType 'Self.A'. Check for this case and
attempt ::Interface resolution to get the correct underlying type.

Fixes rdar://problem/90219229.
2022-03-14 12:33:18 -04:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
Erik Eckstein
dccaa8f01f diagnose duplicated @_cdecl and @_silgen_name function names
Prints a regular error instead of crashing.
The check is done in SILGen, because it's simple. We could also do it earlier, but I don't see a strong reason for this.

rdar://75950093
2021-03-31 13:30:22 +02:00
Michael Gottesman
1de2d3f7c0 [ast] Enable the ASTVerifier behind the enable-ast-verifier flag in no-asserts builds.
This follows the design of how we handled this with
sil-verify-all. Specifically, the default behavior is to run only in asserts
builds, but one can use the two flags: enable-ast-verifier and
disable-ast-verifier to override the default behavior.

The reason why this is interesting is that this means that when compiling
normally, we will not run the verifier, so we won't have a perf hit. But we can
now ask the user to run with this flag (or in a future maybe a re-run in the
driver would do this for them), saving us time when screening bugs by avoiding
the need to build an asserts compiler to triage if the ASTVerifier would catch
the bug.
2021-01-25 11:55:47 -08:00
Robert Widmann
363b66a7ad Fully Qualify the Parent Type When Diagnosing Missing Member Types
Use the FullyQualified<Type> abstraction from the prior commit plus DescriptiveDeclKind to give a bit more information when issuing a missing member type diagnostic during type resolution.
2020-11-09 17:10:18 -08:00
Pavel Yaskevich
f24e5dbd26 [Diangostics] NFC: Adjust test-cases to expect that "type cannot conform" diagnostic has a note 2020-10-27 14:54:07 -07:00
Anthony Latsis
2133fe27df Sema: Have TypeResolution accept an unbound generic type opener function 2020-07-08 13:39:34 +03:00
Holly Borla
b871528179 Merge pull request #32524 from OnyekachiSamuel/fix-confusing-protocol-diagnostic
[Diagnostics] Fix Confusing Protocol Diagnostic
2020-07-02 13:01:19 -07:00
Onyekachi Ezeoke
ff26a06257 fix broken test 2020-07-02 03:13:10 +01:00
Slava Pestov
31a78590a8 ASTMangler: Fix assertion when mangling invalid identifiers
We sometimes need to mangle invalid identifiers, for example when sorting
declarations in EmittedMembersRequest. Make sure this doesn't assert.
2020-06-29 22:17:56 -04:00
Doug Gregor
2f97d24969 Note a fixed compiler crasher 2020-06-04 23:19:47 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Slava Pestov
c543838854 Sema: Rewrite partial applications into closures
When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
2020-03-18 09:29:22 -04:00
Hamish Knight
c667d2b361 Use DefaultArgumentExpr for caller-side defaults
This commit changes how we represent caller-side
default arguments within the AST. Instead of
directly inserting them into the call-site, use
a DefaultArgumentExpr to refer to them indirectly.

The main goal of this change is to make it such
that the expression type-checker no longer cares
about the difference between caller-side and
callee-side default arguments. In particular, it
no longer cares about whether a caller-side
default argument is well-formed when type-checking
an apply. This is important because any
conversions introduced by the default argument
shouldn't affect the score of the resulting
solution.

Instead, caller-side defaults are now lazily
type-checked when we want to emit them in SILGen.
This is done through introducing a request, and
adjusting the logic in SILGen to be more lenient
with ErrorExprs. Caller-side defaults in primary
files are still also currently checked as a part
of the declaration by `checkDefaultArguments`.

Resolves SR-11085.
Resolves rdar://problem/56144412.
2019-11-20 15:07:32 -08:00
Robert Widmann
dd1b15775d Partially Revert #27862
When SE-110 was being implemented, we accidentally began to accept
closure parameter declarations that had no associated parameter names,
e.g.

foo { ([Int]) in /**/ }

This syntax has never been sanctioned by any version of Swift and should
be banned.  However, the change was made long enough ago and there are
enough clients relying on this, that we cannot accept the source break
at the moment.  For now, add a bit to ParamDecl that marks a parameter
as destructured, and back out setting the invalid bit on the type repr
for these kinds of declarations.

To prevent further spread of this syntax, stub in a warning that offers
to insert an anonymous parameter.

Resolves part of rdar://56673657 and improves QoI for errors like
rdar://56911630
2019-11-10 22:10:53 -08:00
Robert Widmann
a1e956d3e7 Resolve a compiler crasher 2019-10-24 16:03:41 -07:00
Slava Pestov
eef8c11dd9 This test case only fails with asserts on
Fixes <rdar://problem/56196703>.
2019-10-11 18:44:10 -04:00
Slava Pestov
de8745b733 Sema: Simplify error handling in typeCheckParameterList() 2019-10-10 13:08:08 -04:00
Holly Borla
7687293b7b [Diagnostics] Adjust the description of existential types for the
type_cannot_conform diagnostic message.
2019-09-17 11:52:43 -07:00
Holly Borla
2a7e0099d2 [Diagnostics] Add notes for the type_cannot_conform error that point
to the declaration that requires protocol conformance.
2019-09-17 09:22:07 -07:00
Holly Borla
40985b6eb7 [Diagnostics] Generalize the "protocol type cannot conform" error to
work for all types that cannot conform to protocols.
2019-09-13 14:51:17 -07:00
Luciano Almeida
7557f29a27 Reverting file location 2019-06-26 17:49:47 -03:00
Luciano Almeida
6331e9a1cd Reverting file location 2019-06-26 17:49:23 -03:00
Luciano Almeida
cfbcaa2cb9 Removing REQUIRES: Assert 2019-06-26 17:46:49 -03:00
Luciano Almeida
bbf38c5541 Merge branch 'master' of https://github.com/apple/swift into attemp-fix-compiler-crash-28818 2019-06-10 00:14:56 -03:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Luciano Almeida
2ef18488d6 Walking through the expr to set the types and type variables in the constraint system before add convertion constraint 2019-05-27 22:57:56 -03:00
Alexis Laferrière
bddb40dacf GSB: ignore generic types in expandConformanceRequirement
Fixes crashes in 28437-swift-typechecker-validatedecl.swift (from previous commit)
and the compiler crasher 28861-gpdecl-getdepth-generictypeparamdecl-
invaliddepth-parameter-hasnt-been-validated.swift.
2019-04-30 10:43:23 -07:00
Stephen Canon
28962b5754 Move most of the simd operators into an optional module (#20914)
* Move most of the simd operators into an optional module

Adding simd to the stdlib caused some typechecker regressions. We can resolve them in the near-term by making the types universally available, but moving the arithmetic operators into a separate module that must be explicitly imported.

* Move two fuzzing tests back to fixed.

* Add SIMDOperators as a dependency for MediaPlayer.

* Move the .-prefixed operator declarations back into the stdlib.
2018-11-30 16:30:15 -05:00
Stephen Canon
fb8b9e143d SIMD into stdlib
Implements SE-0229.

Also updates simd module types in the Apple SDKs to use the new types, and updates a couple tests to work with the new types and protocols.
2018-11-29 17:09:01 -05:00
Doug Gregor
de18384d89 [AST] Don’t deserialize members of @objc protocol looking for associated types
Thanks to @slavapestov for pointing this out! The optimization to avoid
looking through the members of a protocol that can’t possibly have any
associated types was for both deserialized protocols and imported
protocols, but I only supported the former in my previous change. Check
both cases and make the reasons much more obvious.

Also, that change resolved an existing compiler crasher as well.
2018-10-06 22:08:45 -07:00
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Pavel Yaskevich
f15e17a629 [Sema] NFC: reword "only concrete types can conform to protocols" diagnostic 2018-08-03 14:27:00 -07:00
Pavel Yaskevich
c2bf3d5ba9 [TypeChecker] NFC: Fix all of the diagnostics improved by conformance tracking 2018-08-02 21:55:16 -07:00
Huon Wilson
ea1560f43b [AST] Member lookup in the GSB needs to understand equivalence classes with concrete types.
A constraint like `Parameter == SomethingConcrete` means references to
`Parameter` in that context behave like `SomethingConcrete`, including for name
resolution. Handling the parameter as just a parameter type means that it won't
find any non-protocol nested types (i.e. things other than associated types and
protocol typealiases are invisible).

Fixes rdar://problem/42136457 and SR-8240.
2018-07-17 22:54:22 +10:00
Slava Pestov
d4782b0fab Sema: Another validateDeclForNameLookup() state transition bug 2018-07-10 17:01:12 -07:00