Skip to content

Commit a314f8c

Browse files
committed
Addressing Jordan's code review feedbacks. NFC
1 parent 8323152 commit a314f8c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,17 +2410,18 @@ findCorrectEnumCaseName(MetatypeType *MetaTy, LookupResult &Result,
24102410
DeclName memberName) {
24112411
if (!memberName.isSimpleName())
24122412
return DeclName();
2413-
if (!MetaTy->getInstanceType()->is<EnumType>())
2413+
if (!MetaTy->getInstanceType()->is<EnumType>() &&
2414+
!MetaTy->getInstanceType()->is<BoundGenericEnumType>())
24142415
return DeclName();
2415-
std::vector<DeclName> candidates;
2416+
llvm::SmallVector<DeclName, 4> candidates;
24162417
for (auto &correction : Result) {
24172418
DeclName correctName = correction.Decl->getFullName();
24182419
if (!correctName.isSimpleName())
24192420
continue;
24202421
if (!isa<EnumElementDecl>(correction.Decl))
24212422
continue;
24222423
if (correctName.getBaseName().str().
2423-
compare_lower(memberName.getBaseName().str()) == 0)
2424+
equals_lower(memberName.getBaseName().str()))
24242425
candidates.push_back(correctName);
24252426
}
24262427
if (candidates.size() == 1)

test/NameBinding/name_lookup.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,13 @@ func foo() {
541541
_ = MyEnum.Two // expected-error {{enum type 'MyEnum' has no case 'Two'; did you mean 'two'}}{{14-17=two}}
542542
_ = MyEnum.OneTwoThree // expected-error {{enum type 'MyEnum' has no case 'OneTwoThree'; did you mean 'oneTwoThree'}}{{14-25=oneTwoThree}}
543543
}
544+
545+
enum MyGenericEnum<T> {
546+
case one(T)
547+
case oneTwo(T)
548+
}
549+
550+
func foo1() {
551+
_ = MyGenericEnum<Int>.One // expected-error {{enum type 'MyGenericEnum<Int>' has no case 'One'; did you mean 'one'}}{{26-29=one}}
552+
_ = MyGenericEnum<Int>.OneTwo // expected-error {{enum type 'MyGenericEnum<Int>' has no case 'OneTwo'; did you mean 'oneTwo'}}{{26-32=oneTwo}}
553+
}

0 commit comments

Comments
 (0)