Slava Pestov
69e3aaf6fe
AST: Add workaround for incorrect mangling of conditional conformances with pack requirements
...
I added commit 7eecf97132 a while ago
to fix a newly-added assertion failure that came up, however this
had the inadvertent side effect of changing symbol mangling and
ASTPrinter behavior.
The problem in both instances was that we would incorrectly return
certain requirements as unsatisfied when really they are satisfied.
There is nothing to fix in the ASTPrinter, because printing redundant
requirements does not change the generic signature of the extension;
they are simply dropped. I added a test to exercise the new behavior
showing that the requirements are dropped.
As for the mangler, the fix introduced an ABI break, because the
symbol name of a conformance descriptor includes its conditional
requirements, so we must preserve the redundant requirements forever.
The IRGen test has some examples of manglings that are incorrect but
must be preserved.
I'm plumbing down a flag to isRequirementSatified() to preserve
compatibility with the old behavior where we would mangle these
redundant requirements. No other callers should pass this flag,
except for the mangler.
Fixes rdar://139089004.
2024-11-07 16:28:26 -05:00
Slava Pestov
08bb0017f5
AST: Add GenericSignatureImpl::getReducedTypeParameter()
...
This avoids a bit of indirection when the input is already known to be
a type parameter, and not just a type that contains type parameters.
2024-09-13 15:19:48 -04:00
Slava Pestov
be9d999e64
AST: Simplify GenericSignature::getLocalRequirements()
2024-09-13 15:19:48 -04:00
Slava Pestov
1901862afc
AST: Remove LookUpConformanceInSignature
2024-07-06 12:05:46 -04:00
Slava Pestov
cb66dabc8c
AST: Add getNextDepth() and getMaxDepth() methods to GenericSignature
2024-05-01 12:08:40 -04:00
Kavon Farvardin
a754f4ba6c
NFC: clarify comment
2024-03-02 09:57:04 -08:00
Slava Pestov
0e31d41072
AST: Move GenericSignature::typeErased() to SIL
...
This is used by the specializer and belongs at the SIL level.
2024-02-24 07:25:59 -05:00
Slava Pestov
af50d7e6b8
AST: Add allowInverses flag to AbstractGenericSignatureRequest
2024-02-05 18:43:06 -05:00
Slava Pestov
8092f18772
AST: Generalize GenericSignatureImpl::getUpperBound()
...
Handle inverses, and add a couple of flags (yuck!) to allow its
usage in diagnostics and code completion.
2024-02-01 23:35:33 -05:00
Slava Pestov
6ed553da59
AST: Introduce GenericSignature::getRequirementsWithInverses()
2024-01-31 18:40:35 -05:00
Slava Pestov
f5e250551d
AST: Merge GenericSignature::get{Non,}DependentUpperBounds()
2023-11-27 14:05:36 -05:00
Slava Pestov
8afff61699
AST: Replace TypeArrayView<GenericTypeParamType> with ArrayRef<GenericTypeParamType *>
...
This basically undoes 3da6fe9c0d , which in hindsight was wrong.
There were no other usages of TypeArrayView anywhere else except for
GenericSignature::getGenericParams(), and it was almost never what
you want, so callers had to convert back and forth to an ArrayRef.
Remove it.
2023-06-29 19:23:44 -04:00
Angela Laar
a9f1096839
[Generic Signature] Unify generic upper bound functions
...
Opened existentials should be erased to the dependent upper bound
if the dependent member can be reduced to a concrete type. This
allows the generic signature to support parameterized protocol types
and bound generic class types by producing a more specific constraint
instead of just a plain protocol or class.
2023-05-17 15:33:50 -07:00
Slava Pestov
8af5bbedc3
AST: Factor out GenericSignatureImpl::getShapeClasses()
2023-03-03 14:16:54 -05:00
Slava Pestov
7ffbf58c55
AST: Add GenericSignatureImpl::getDependentUpperBounds()
2022-11-07 18:38:00 -05:00
Holly Borla
cf38d55e3a
[AST] Plumb reduced shape types through local requirements into pack archetypes.
2022-10-23 11:42:46 -07:00
Holly Borla
be619c62c9
[RequirementMachine] Add a generic signature query that determines whether
...
two type parameter packs have the same shape.
2022-10-07 10:35:49 -07:00
Holly Borla
fab5b7d364
[RequirementMachine] Add a generic signature query that returns the
...
reduced shape of a given type parameter pack.
2022-10-06 20:38:31 -07:00
Dario Rexin
210c68d8aa
[SILOptimizer] Add prespecialization for arbitray reference types ( #58846 )
...
* [SILOptimizer] Add prespecialization for arbitray reference types
* Fix benchmark Package.swift
* Move SimpleArray to utils
* Fix multiple indirect result case
* Remove leftover code from previous attempt
* Fix test after rebase
* Move code to compute type replacements to SpecializedFunction
* Fix ownership when OSSA is enabled
* Fixes after rebase
* Changes after rebasing
* Add feature flag for layout pre-specialization
* Fix pre_specialize-macos.swift
* Add compiler flag to benchmark build
* Fix benchmark SwiftPM flags
2022-09-22 16:29:01 -07:00
Slava Pestov
4a041c57d0
AST: Rename ConformanceAccessPath to ConformancePath
2022-08-09 13:34:27 -04:00
Slava Pestov
9d96ed940f
AST: Rename 'canonical wrt. generic signature' to 'reduced'
...
We had two notions of canonical types, one is the structural property
where it doesn't contain sugared types, the other one where it does
not contain reducible type parameters with respect to a generic
signature.
Rename the second one to a 'reduced type'.
2022-08-09 12:46:31 -04:00
Josh Soref
81d3ad76ac
Spelling ast ( #42463 )
...
* spelling: accessor
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accommodates
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: argument
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: associated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: available
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: belongs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: bookkeeping
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: building
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clonable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: closure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: concatenated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conformance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: context
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: correspondence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declared
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: defining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: delayed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deployed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: descendants
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnostic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equitable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: evaluation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: exclusivity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existential
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: explicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: expressed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: for
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: foreign
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: function
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: implicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: information
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interchangeable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interface
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introduced
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: invalid
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: kind-in
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: least
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: library
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: location
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: not
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: number
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: obtains
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: occurs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: opaque
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: precede
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: preceding
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: property
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: protocol
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: qualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recursively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: references
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: relaxing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: represented
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: request
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirements
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: returned
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: siblings
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: source
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specializations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specially
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: statement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: stripped
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: structure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transform
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transformed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transparent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: typecheck
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unlabeled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unqualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whether
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: with
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-21 12:57:16 -07:00
Slava Pestov
4d097da73c
RequirementMachine: Re-use requirement machines constructed by minimization for queries
...
Fixes rdar://problem/88135641.
2022-03-26 00:56:41 -04:00
Pavel Yaskevich
2b6379de24
[AST] GenericSignature: Add a way to drop marker protocol requirements
2022-03-17 15:02:14 -07:00
Slava Pestov
f5b3d19703
RequirementMachine: Replace hadError() with getErrors() returning an OptionSet
...
This gives us more fine-grained information which will be plumbed
through the various requests.
2022-03-14 12:33:18 -04:00
Anthony Latsis
b3ee4b0718
AST, Sema: Use the opened archetype's generic signature to determine existential member availability
2022-02-02 02:09:59 +03:00
Slava Pestov
0ffd11c558
RequirementMachine: New GenericSignature::isValidTypeInContext() query
2022-01-14 21:25:32 -08:00
Slava Pestov
3a92d2fc53
AST: Remove legacy GSB-based GenericSignature query implementation
2022-01-12 12:33:34 -05:00
Slava Pestov
589fc40d5a
AST: Use RequirementMachine to verify protocol requirement signatures
2021-12-08 23:07:48 -05:00
Slava Pestov
0eb66222e2
AST: Move expensive generic signature checks to GenericSignature.cpp
...
This removes the final dependency on GenericSignatureBuilder.h.
2021-10-30 00:35:59 -04:00
Slava Pestov
f38f25a3de
AST: Factor out AbstractGenericSignatureRequest into a new buildGenericSignature() function
...
This is slightly cleaner.
2021-10-30 00:35:59 -04:00
Slava Pestov
47ab4a9f28
AST: GenericSignatures point directly to their RequirementMachine
...
This avoids a hashtable lookup when performing queries.
2021-09-27 21:36:45 -04:00
Robert Widmann
e545d7f760
Lift getCanonicalTypeInContext up to GenericSignature
2021-09-20 15:43:07 -07:00
Robert Widmann
980fde2ede
Lift requirementsNotSatisfiedBy Into GenericSignature
2021-09-20 15:29:51 -07:00
Slava Pestov
26fa4b354b
GSB: Use RequirementMachine (when enabled) to verify newly-built generic signatures
2021-09-07 13:31:17 -04:00
Slava Pestov
8f8b02c114
AST: Move compareDependentTypes() to GenericSignature.cpp
2021-08-11 12:01:07 -04:00
Slava Pestov
b3deddb68d
AST: Factor out duplicated definition of compareAssociatedTypes()
2021-08-11 12:01:07 -04:00
Slava Pestov
6dc9ef88d7
AST: GenericSignatures don't contain type variables
2021-08-05 14:39:07 -04:00
Doug Gregor
f9c34756ef
Parameterize conformance lookup on whether "missing" conformances are allowed.
...
Many clients of the conformance lookup operations would prefer to get
an invalid conformance (== there is no conformance) rather than a
missing conformance. Parameterize the conformance lookup operations so
that most callers won't see missing conformances, by filtering them
out at the end. Opt-in those callers that do want to see missing
conformances so they can be diagnosed.
2021-08-03 00:10:45 -07:00
Slava Pestov
212099be82
RequirementMachine: Move RequirementMachine class to swift::rewriting namespace
2021-07-23 17:21:58 -04:00
Robert Widmann
1329f3cfbd
[NFC] Lift getGenericEnvironment() into GenericSignature
2021-07-22 23:33:02 -07:00
Robert Widmann
109da00f50
Hide GenericSignatureImpl::getCanonicalSignature
2021-07-22 23:27:06 -07:00
Robert Widmann
74b653518d
Lift GenericSignature::hasTypeVariable
2021-07-22 23:27:06 -07:00
Robert Widmann
d86551de67
Lift Requirement and Parameter Accessors up to GenericSignature
...
Start treating the null {Can}GenericSignature as a regular signature
with no requirements and no parameters. This not only makes for a much
safer abstraction, but allows us to simplify a lot of the clients of
GenericSignature that would previously have to check for null before
using the abstraction.
2021-07-22 23:27:05 -07:00
Slava Pestov
08edd56686
RequirementMachine: Drop protocols that the superclass conforms to when building an archetype
2021-07-17 00:05:05 -04:00
Slava Pestov
c2a275ef0f
AST: Factor out GenericSignature::getLocalRequirements() method
...
This encapsulates GenericEnvironment's usage of the GSB.
2021-07-17 00:05:05 -04:00
Slava Pestov
499bff25bc
RequirementMachine: Implement GenericSignature::getConformanceAccessPath() query
...
This is just a straight port of the existing code in the GSB, with minimal changes.
It could be made more efficient in the future by trafficking in Terms rather than
Types, avoiding some intermediate conversion and canonicalization steps.
2021-07-14 00:16:02 -04:00
Slava Pestov
c5b299ceea
AST: Factor out GenericSignature::lookupNestedType()
2021-07-14 00:06:17 -04:00
Slava Pestov
6fa7a3fedb
AST: Introduce GenericSignatureImpl::getRequirementMachine()
2021-06-30 01:34:20 -04:00
Slava Pestov
e6ff771d59
GSB: Rewrite getConformanceAccessPath(), again
...
The new approach is to not look at RequirementSources at all. Instead,
we exhaustively enumerate all conformance access paths, beginning
from the root conformance requirements in the signature, then doing
all conformance requirements from those protocols' requirement
signatures, and so on.
We enumerate conformance access paths in breadth first order by
length until we find the one we want. The results are memoized.
This fixes a regression with another change I'm working on. The
test case does not fail with this PR alone, but I'm adding it now
anyway.
2021-05-06 17:55:43 -04:00