Skip to content

Commit d954b84

Browse files
[tests] Adjusting SR-11535 test case on the suit
1 parent 1c9ba53 commit d954b84

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7183,9 +7183,9 @@ static bool attemptUnresolvedMemberFix(ConstraintSystem &cs,
71837183
return false;
71847184

71857185
// Right now, name lookup only unwraps a single layer of optionality, which
7186-
// for cases where base type is a multi-optional type e.g. Foo?? so, it only
7187-
// finds optional base candidates. To produce the correct warning perform an
7188-
// extra lookup on unwrapped type is required.
7186+
// for cases where base type is a multi-optional type e.g. Foo?? it only
7187+
// finds optional base candidates. To produce the correct warning we perform
7188+
// an extra lookup on unwrapped type.
71897189
if (!allOptionalBaseCandidates)
71907190
return true;
71917191

test/decl/enum/enumtest.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,23 @@ let _: GenericEnumWithStaticNone<Int>? = .none // expected-warning {{assuming yo
511511
// expected-note@-2 {{use 'GenericEnumWithStaticNone<Int>.none' instead}}{{42-42=GenericEnumWithStaticNone<Int>}}
512512
let _: GenericEnumWithStaticNone<String>? = .none // Okay
513513

514-
let _: GenericEnumWithStaticNone? = .none // Okay
515-
// Base can only be inferred as static member `none` since `Optional.none` overload does not
516-
// provide a valid solution because the struct's generic argument `T` cannot be infered in this context.
514+
let _: GenericEnumWithStaticNone? = .none // expected-warning {{assuming you mean 'GenericEnumWithStaticNone<Int>.none'; did you mean 'Optional<GenericEnumWithStaticNone<Int>>.none' instead?}}
515+
// expected-note@-1 {{use 'Optional<GenericEnumWithStaticNone<Int>>.none' instead}} {{37-37=Optional<GenericEnumWithStaticNone<Int>>}}
516+
// expected-note@-2 {{use 'GenericEnumWithStaticNone<Int>.none' instead}} {{37-37=GenericEnumWithStaticNone<Int>}}
517+
518+
enum GenericStructWithStaticNone<T> {
519+
init() {}
520+
static var none: GenericStructWithStaticNone<Int> { GenericStructWithStaticNone<Int>() }
521+
}
522+
523+
let _: GenericStructWithStaticNone<Int>? = .none // expected-warning {{assuming you mean 'Optional<GenericStructWithStaticNone<Int>>.none'; did you mean 'GenericStructWithStaticNone<Int>.none' instead?}}
524+
// expected-note@-1 {{explicitly specify 'Optional' to silence this warning}}{{44-44=Optional}}
525+
// expected-note@-2 {{use 'GenericStructWithStaticNone<Int>.none' instead}}{{44-44=GenericStructWithStaticNone<Int>}}
526+
let _: GenericStructWithStaticNone<String>? = .none // Okay
527+
528+
let _: GenericStructWithStaticNone? = .none // expected-warning {{assuming you mean 'GenericStructWithStaticNone<Int>.none'; did you mean 'Optional<GenericStructWithStaticNone<Int>>.none' instead?}}
529+
// expected-note@-1 {{use 'Optional<GenericStructWithStaticNone<Int>>.none' instead}} {{39-39=Optional<GenericStructWithStaticNone<Int>>}}
530+
// expected-note@-2 {{use 'GenericStructWithStaticNone<Int>.none' instead}} {{39-39=GenericStructWithStaticNone<Int>}}
517531

518532
enum GenericEnumWithoutNone<T> {
519533
case a

0 commit comments

Comments
 (0)