Skip to content

Commit 5ff0f41

Browse files
authored
Merge pull request #66894 from angela-laar/exclude-generic-param-constraints-5.9
[5.9] Exclude GenericParam Constraints
2 parents 1fbbc70 + 1361655 commit 5ff0f41

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ Type GenericSignatureImpl::getUpperBound(Type type,
697697
abort();
698698
}
699699

700-
if (!hasInnerGenericParam)
700+
if (!hasInnerGenericParam && (wantDependentBound || !hasOuterGenericParam))
701701
argTypes.push_back(reducedType);
702702
}
703703

test/Constraints/opened_existentials.swift

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
22

33
protocol Q { }
44

@@ -369,3 +369,52 @@ func testPrimaryAssocReturn(p: any P4<Int>) {
369369
func testPrimaryAssocCollection(p: any P4<Float>) {
370370
let _: any Collection<Float> = p.returnAssocTypeCollection()
371371
}
372+
373+
protocol P5<X> {
374+
associatedtype X = Void
375+
}
376+
377+
struct K<T>: P5 {
378+
typealias X = T
379+
}
380+
381+
extension P5 {
382+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
383+
func foo() -> some P5<X>{
384+
K<X>()
385+
}
386+
func bar(_ handler: @escaping (X) -> Void) -> some P5<X> {
387+
K<X>()
388+
}
389+
}
390+
391+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
392+
func testFoo(_ p: any P5<String>) -> any P5 {
393+
p.foo()
394+
}
395+
396+
func testFooGeneric<U>(_ p: any P5<Result<U, Error>>) -> any P5 {
397+
p.foo()
398+
}
399+
400+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
401+
func testBar<U>(_ p: any P5<Result<U, Error>>) -> any P5 {
402+
p.bar { _ in }
403+
}
404+
405+
enum Node<T> {
406+
case e(any P5)
407+
case f(any P5<Result<T, Error>>)
408+
}
409+
410+
struct S<T, U> {
411+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
412+
func foo(_ elt: Node<U>) -> Node<T>? {
413+
switch elt {
414+
case let .e(p):
415+
return .e(p)
416+
case let .f(p):
417+
return .e(p.bar { _ in })
418+
}
419+
}
420+
}

0 commit comments

Comments
 (0)