Skip to content

Commit

Permalink
Merge pull request #12633 from DougGregor/sr-6100
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-ci committed Oct 26, 2017
2 parents 5c5c9ac + e1e0dec commit ffd3423
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Sema/TypeCheckPattern.cpp
Expand Up @@ -1321,8 +1321,9 @@ bool TypeChecker::coercePatternToType(Pattern *&P, DeclContext *dc, Type type,
}
// Otherwise, if the type is an unbound generic of the context type, use
// the context type to resolve the parameters.
else if (parentTy->is<UnboundGenericType>()) {
if (parentTy->getAnyNominal() == type->getAnyNominal()) {
else if (parentTy->hasUnboundGenericType()) {
if (parentTy->is<UnboundGenericType>() &&
parentTy->getAnyNominal() == type->getAnyNominal()) {
enumTy = type;
} else {
diagnose(EEP->getLoc(), diag::ambiguous_enum_pattern_type,
Expand Down
16 changes: 16 additions & 0 deletions test/Constraints/patterns.swift
Expand Up @@ -336,3 +336,19 @@ func rdar32241441() {
break;
}
}


// SR-6100
struct One<Two> {
public enum E: Error {
// if you remove associated value, everything works
case SomeError(String)
}
}

func testOne() {
do {
} catch let error { // expected-warning{{'catch' block is unreachable because no errors are thrown in 'do' block}}
if case One.E.SomeError = error {} // expected-error{{generic enum type 'One.E' is ambiguous without explicit generic parameters when matching value of type 'Error'}}
}
}

0 comments on commit ffd3423

Please sign in to comment.