Commit Graph

28 Commits

Author SHA1 Message Date
Anthony Latsis
58fa8bf762 RequirementMachine: Diagnose unsupported value generic parameter definitions properly
The flow was such that we recorded subtype constraints regardless of the
subject type's nature. Extract value generics handling out of the
devious `else if` chain, and never record any subtype constraints if the
subject type is a non-type parameter.

While we're here, generalize the diagnostic message for user-written
subtype constraints on value generic parameters and emit it
consistently, not just if the right-hand side contains a protocol type.
2025-10-08 02:13:03 +01:00
Hamish Knight
3daae5955e [AST] Use ErrorType for invalid value generic parameter
If we fail to resolve the value type for a value generic parameter,
previously we would have returned a null Type, causing crashes
downstream. Instead, return an ErrorType, leaving a null Type for
cases where the generic parameter isn't a value generic at all.

rdar://154856417
2025-07-02 14:46:55 +01:00
Rintaro Ishizaki
a82f14bab0 Merge pull request #81265 from rintaro/parse-rdar149556573
[Parse] Parse operator function with value generics
2025-05-03 20:26:22 -07:00
Rintaro Ishizaki
682d2634ba [Parse] Parse operator function with value generics
Operator function parsing has a heuristics to determine if `<` a part of
the operator name or the generic parameter clause. Handle `let` there
because value generics uses it.

rdar://149556573
2025-05-02 17:09:13 -07:00
Alejandro Alonso
0d5b53d235 Update value_generics.swift 2025-04-25 09:27:33 -07:00
Alejandro Alonso
ae355007fc Store TypeRepr in TypeValueExpr 2025-04-14 15:33:08 -07:00
Alejandro Alonso
42b416171a Add feature for value generic namelookup 2025-04-14 15:33:05 -07:00
Alejandro Alonso
b3f3dd79cf Handle dynamically accessing the static member from type(of:) 2025-04-14 15:32:46 -07:00
Alejandro Alonso
b34b6e58e0 Make it an error to redeclare properties with the same name as a value generic
Update value_generics.swift
2025-04-14 15:32:45 -07:00
Alejandro Alonso
1aaf2c9d29 Allow value generics to show up as static members 2025-04-14 15:32:43 -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
Alejandro Alonso
c1bb143648 Make ValueGenerics feature always available 2025-02-27 10:03:37 -08:00
Alejandro Alonso
15c32e117b Directly store GTPD in TypeValueExpr 2025-02-25 14:11:55 -08:00
Meghana Gupta
e8abd59da5 Update tests 2024-11-18 18:09:19 -08:00
Alejandro Alonso
400bfb227c Remove disable parser round trip on some tests 2024-11-06 13:56:06 -08:00
Alejandro Alonso
90ce2cd361 Restrict parsing integer types in certain contexts 2024-11-06 13:55:01 -08:00
Alex Hoppen
9bbdeaa8c0 Enable experimental parser round-trip in test cases that no longer need it
Also, track all remaining uses of `-disable-experimental-parser-round-trip` by issues.
2024-11-04 15:49:47 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Alejandro Alonso
6f83e3c28f Fix type parsing when preceeded by '-' 2024-09-11 10:28:44 -07:00
Alex Hoppen
50a892425d [test] Add -disable-experimental-parser-round-trip to value generic tests
Parsing of integer literals as generic arguments isn’t implemented in SwiftParser yet, blocking swift-syntax PR testing.
2024-09-06 08:16:23 -07:00
Alejandro Alonso
9faf615c88 Add runtime availability checking for value generics 2024-09-04 15:13:51 -07:00
Alejandro Alonso
451e7259a1 Add ValueGenerics experimental feature 2024-09-04 15:13:49 -07:00
Alejandro Alonso
19fc174f30 Don't create fake GTPDs for SIL generic signatures 2024-09-04 15:13:47 -07:00
Alejandro Alonso
e0f2b812e8 Add serialization and parser tests for SIL 2024-09-04 15:13:47 -07:00
Alejandro Alonso
a434126554 Disallow referencing a value generic outside of certain contexts 2024-09-04 15:13:45 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
0df42e9841 Lower UDRE to TypeValue if it references a value generic 2024-09-04 15:13:29 -07:00
Alejandro Alonso
3e9c4633ca Add some new diagnostics and tests 2024-09-04 15:13:27 -07:00