Skip to content

Conversation

@slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jan 9, 2019

rdar://problem/20530021, rdar://problem/21161476, https://bugs.swift.org/browse/SR-1181, rdar://problem/46853611

It looks like Type::subst() was subsequently fixed for GenericFunctionTypes
in 06d1679 so we can remove this hack.
…eclared type

In a protocol, the overload signature type of a property is (Self) -> (),
not (Proto) -> ().
…ocols and superclass constraints on an archetype

Semantically, these are not superclass/refined-protocol members.
If I have a generic parameter <T : P & Q>, then when looking at
a value of type T, members of P and Q are at the same "level" as
if I had a value of type (P & Q).
…tential type

It's better to use the 'Self' archetype here.
…n existential type

It's better to use the 'Self' archetype here.
It's no longer needed after the previous set of changes, and removing it
fixes a crash.

Fixes <rdar://problem/46853611>.
… is used with protocol conformance

Consider this setup:

protocol Proto {
  func foo() {}
}

class Base : Proto {
  func foo() {}
}

class Derived : Base {
  ...
}

When completing members of a Derived instance, we find both the protocol's
foo() and the base class's foo(). These have the following types:

- Proto.foo: <Self : Proto> (Self) -> () -> ()
- Base.foo: (Base) -> () -> ()

If we simply substitute the base type (Derived) into the type of the protocol
member, we get (Derived) -> () -> (), which is different than the type of
Base.foo, so we get both declarations in the completion list.

Instead, use the 'Self' type for the specific class of the conformance,
which in this case is 'Base' even if we're looking at members of 'Derived'.

Fixes <rdar://problem/21161476>, <https://bugs.swift.org/browse/SR-1181>.
The logic here had diverged from UnqualifiedLookup. One day we'll merge
the two, for now clean it up a bit to match.

Note that all generic parameters now have 'Reason' reported as 'Local'.
I don't believe this really matters.

Fixes <rdar://problem/20530021>.
@slavapestov slavapestov requested a review from a team as a code owner January 9, 2019 21:33
@slavapestov slavapestov changed the base branch from swift-5.0-branch to swift-5.0-branch-01-07-2019 January 9, 2019 21:34
@AnnaZaks AnnaZaks merged commit 13a96ca into swiftlang:swift-5.0-branch-01-07-2019 Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants