Skip to content

Commit 578f137

Browse files
committed
[CodeCompletion] For types with type parameters, their constraint extensions are considered unusable. rdar://23173692
1 parent a296ed4 commit 578f137

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,11 @@ bool TypeChecker::isProtocolExtensionUsable(DeclContext *dc, Type type,
41984198
if (!protocolExtension->isConstrainedExtension())
41994199
return true;
42004200

4201+
// If the type still has parameters, the constrained extension is considered
4202+
// unusable.
4203+
if (type->hasTypeParameter())
4204+
return false;
4205+
42014206
// Set up a constraint system where we open the generic parameters of the
42024207
// protocol extension.
42034208
ConstraintSystem cs(*this, dc, None);

test/IDE/complete_crashes.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct CustomGenericCollection<Key> : DictionaryLiteralConvertible {
6363
// GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[TypeAlias]/CurrNominal: Key[#Key#]; name=Key
6464
// GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[TypeAlias]/CurrNominal: Value[#Value#]; name=Value
6565
// GENERIC_PARAM_AND_ASSOC_TYPE: End completions
66-
66+
6767
var count: Int { #^GENERIC_PARAM_AND_ASSOC_TYPE^# }
6868
}
6969

@@ -159,3 +159,9 @@ func rdar22834017() {
159159
}
160160
// FIXME: We could provide a useful completion here. rdar://problem/22846558
161161
// INVALID_TYPE_INIT-NOT: Begin completions
162+
163+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RDAR_23173692 | FileCheck %s -check-prefix=RDAR_23173692
164+
func rdar23173692() {
165+
return IndexingGenerator(#^RDAR_23173692^#)
166+
}
167+
// RDAR_23173692: Begin completions

0 commit comments

Comments
 (0)