Skip to content

[Sema] Extend fix for reference storage types in protocol witnesses to include generics. #12446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3990,10 +3990,10 @@ static Type getWitnessTypeForMatching(TypeChecker &tc,
// Retrieve the set of substitutions to be applied to the witness.
Type model = conformance->getType();
TypeSubstitutionMap substitutions = model->getMemberSubstitutions(witness);
Type type = witness->getInterfaceType()->getReferenceStorageReferent();

if (substitutions.empty())
return witness->getInterfaceType()->getReferenceStorageReferent();

Type type = witness->getInterfaceType();
return type;

// Strip off the requirements of a generic function type.
// FIXME: This doesn't actually break recursion when substitution
Expand Down
4 changes: 4 additions & 0 deletions test/Generics/associated_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,8 @@ class C3 : sr6097_b {
weak var aProperty: C1? // and same here, despite 'weak'
init() { fatalError() }
}
class G<T> : sr6097_b where T : AnyObject {
weak var aProperty: T?
}