Commit Graph

15 Commits

Author SHA1 Message Date
Anthony Latsis
ae35f150cd Gardening: Migrate test suite to GH issues (file names): Generics 2022-09-18 18:00:52 +03:00
Slava Pestov
5fa5ff7ce1 RequirementMachine: Update tests for protocol typealiases 2022-02-13 09:50:16 -05:00
Slava Pestov
91b81cbdc8 RequirementMachine: Add a test that used to fail with the GSB
I have a lot more known-failing GSB test cases, but the limiting factor
now is the GSB's minimization algorithm, which runs first before the
requirement machine gets to see anything. Replacing that with a new
algorithm based on the rewrite system is the next step here.
2021-07-17 14:27:51 -04:00
Slava Pestov
653fa07260 GSB: Fix maybeResolveEquivalenceClass() with member type of superclass-constrained type
Name lookup might find an associated type whose protocol is not in our
conforms-to list, if we have a superclass constraint and the superclass
conforms to the associated type's protocol.

We used to return an unresolved type in this case, which would result in
the constraint getting delayed forever and dropped.

While playing wack-a-mole with regressing crashers, I had to do some
refactoring to get all the tests to pass. Unfortuanately these refactorings
don't lend themselves well to being peeled off into their own commits:

- maybeAddSameTypeRequirementForNestedType() was almost identical to
  concretizeNestedTypeFromConcreteParent(), except for superclasses
  instead of concrete same-type constraints. I merged them together.

- We used to drop same-type constraints where the subject type was an
  ErrorType, because maybeResolveEquivalenceClass() would return an
  unresolved type in this case.

  This violated some invariants around nested types of ArchetypeTypes,
  because now it was possible for a nested type of a concrete type to
  be non-concrete, if the type witness in the conformance was missing
  due to an error.

  Fix this by removing the ErrorType hack, and adjusting a couple of
  other places to handle ErrorTypes in order to avoid regressing with
  invalid code.

Fixes <rdar://problem/45216921>, <https://bugs.swift.org/browse/SR-8945>,
<https://bugs.swift.org/browse/SR-12744>.
2020-05-19 20:28:51 -04:00
Mike Ash
5decec24e7 [Runtime] Fix gatherWrittenGenericArgs crashing when description is NULL.
rdar://problem/54775582
SR-11374
2019-09-09 10:58:22 -04:00
Harlan Haskins
5a3761df1b [Sema] Stop filtering nested protocol types from lookup
This check wasn't ever correct, because the fact that the the protocol comes
from another module doesn't change the fact that the type is valid for lookup
within this module. It incorrectly rejects the following, valid code:

```swift
// In A.swift
public protocol A {}
```

```
// In B.swift
import A

extension A {
  typealias B = Int
  func b(_ b: Self.B) {}
}
```
2019-06-13 17:54:35 -07:00
Doug Gregor
af335c6bb9 [GSB] Consistently use nested type name match constraints.
We generated a mix of "inferred" and "nested type name match"
constraints for the case where we had two nested types with the same
name and inferred that they are equal. Make them consistent by always
using nested type name match constraints. This fixes a bug where we
would get different canonical generic signatures in different source
files because we inferred the same-type constraint with different
requirement sources.

Fixes rdar://problem/48049725.
2019-02-14 14:28:43 -08:00
Huon Wilson
9a7be78421 [Sema] Give an explicit error for conditional conformances to @objc protocols.
Fixes https://bugs.swift.org/browse/SR-7372.
2018-04-09 09:20:39 +10:00
Huon Wilson
dd845c40d2 [Sema] Disallow conditional conformances on objective-c generics.
There's no way to look up information about objective-c generic
parameters, meaning the runtime cannot check same-type constraints or
conformance requirements, so dynamic casts cannot work. We want to keep
the static and dynamic systems the same, so we have to disable this
functionality from the start (i.e. no conditional conformances on
objective-c types :( ).

Fixes rdar://problem/37524969.
2018-02-15 16:59:03 +11:00
Slava Pestov
d5c2f44c4e Sema: Clean up name lookup and fix a couple of bugs
Previously, qualified lookup would use a metatype to signal
to the LookupResultBuilder that conformance checks should not
be used to resolve protocol members found with a concrete
type base. This is too subtle for my taste. Add an explicit
flag and clean up some usages, fixing <rdar://problem/16123805>.

Also, clean up the 'CheckProtocolMembers' flag. We now set
when the base type is an archetype, and correctly handle
the concept of an abstract conformance. This finally
fixes <rdar://problem/22776964>.
2016-08-09 00:53:30 -07:00
John McCall
6593c5319d Add typo correction to qualified lookup. 2016-07-01 19:04:57 -07:00
Doug Gregor
38c1de69e4 Reinstate "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
2016-01-14 00:21:48 -08:00
Erik Eckstein
ce7b2bcf09 Revert "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit 2b2e9dc80e.

It broke some compiler crasher tests
2016-01-13 20:42:58 -08:00
gregomni
2b2e9dc80e [SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either
typealias or associatedtype to create an AssociatedTypeDecl, warning
that the former is deprecated. The ASTPrinter now emits associatedtype
for AssociatedTypeDecls.

Separated AssociatedType from TypeAlias as two different kinds of
CodeCompletionDeclKinds. This part probably doesn’t turn out to be
absolutely necessary currently, but it is nice cleanup from formerly
specifically glomming the two together.

And then many, many changes to tests. The actual new tests for the fixits
is at the end of Generics/associated_types.swift.
2016-01-13 17:54:31 -08:00
Jordan Rose
d3a41b6a78 Add some more tests for inferred associated types.
Filed <rdar://problem/16123805> for the cases that don't work.

Swift SVN r14163
2014-02-20 19:47:44 +00:00