Skip to content

Commit 33a6cce

Browse files
committed
Dependencies: references in generic signatures create public dependencies.
Noticed by inspection (!). This logic could use some before/after fuzzing.
1 parent de76781 commit 33a6cce

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ resolveTopLevelIdentTypeComponent(TypeChecker &TC, DeclContext *DC,
746746
}
747747
}
748748

749-
if (!DC->isCascadingContextForLookup(/*excludeFunctions*/true))
749+
if (!DC->isCascadingContextForLookup(/*excludeFunctions*/false))
750750
options |= TR_KnownNonCascadingDependency;
751751

752752
// The remaining lookups will be in the parent context.

test/NameBinding/Inputs/reference-dependencies-helper.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,6 @@ struct OtherFileTypeToBeExtended {}
133133

134134
struct TypeReferencedOnlyBySubscript {}
135135
struct TypeReferencedOnlyByPrivateSubscript {}
136+
137+
protocol ProtoReferencedOnlyInGeneric {}
138+
protocol ProtoReferencedOnlyInPrivateGeneric {}

test/NameBinding/reference-dependencies.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ private struct PrivateTy6 {}
326326
// CHECK-DAG: !private "PrivateProto3"
327327
extension PrivateTy6 : PrivateProto3 {}
328328

329+
// CHECK-DAG: - "ProtoReferencedOnlyInGeneric"
330+
func genericTest<T: ProtoReferencedOnlyInGeneric>(_: T) {}
331+
// CHECK-DAG: !private "ProtoReferencedOnlyInPrivateGeneric"
332+
// FIXME: Should be
333+
private func privateGenericTest<T: ProtoReferencedOnlyInPrivateGeneric>(_: T) {}
334+
329335
struct Sentinel1 {}
330336

331337
private protocol ExtensionProto {}

0 commit comments

Comments
 (0)