Permalink
Browse files

[Sema] Remove restriction on conditional conformances.

  • Loading branch information...
Huon Wilson
Huon Wilson committed Sep 8, 2017
1 parent 7932a0f commit 041b14175c1f6a9ba5b0df10ef23013e30d299dd
@@ -1350,9 +1350,6 @@ ERROR(extension_stored_property,none,
"extensions must not contain stored properties", ())
ERROR(extension_nongeneric_trailing_where,none,
"trailing 'where' clause for extension of non-generic type %0", (Type))
ERROR(extension_constrained_inheritance,none,
"extension of type %0 with constraints cannot have an "
"inheritance clause", (Type))
ERROR(extension_protocol_inheritance,none,
"extension of protocol %0 cannot have an inheritance clause", (Type))
ERROR(objc_generic_extension_using_type_parameter,none,
@@ -367,17 +367,6 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
return;
}
}
// Constrained extensions cannot have inheritance clauses.
if (!inheritedClause.empty() &&
ext->getGenericParams() &&
ext->getGenericParams()->hasTrailingWhereClause()) {
diagnose(ext->getLoc(), diag::extension_constrained_inheritance,
ext->getExtendedType())
.highlight(SourceRange(inheritedClause.front().getSourceRange().Start,
inheritedClause.back().getSourceRange().End));
ext->setInherited({ });
}
}
// Retrieve the location of the start of the inheritance clause.
@@ -134,7 +134,7 @@ func genericClassNotEquatable<T>(_ gc: GenericClass<T>, x: T, y: T) {
extension Array where Element == String { }
extension GenericClass : P3 where T : P3 { } // expected-error{{extension of type 'GenericClass' with constraints cannot have an inheritance clause}}
extension GenericClass : P3 where T : P3 { }
extension GenericClass where Self : P3 { }
// expected-error@-1{{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'GenericClass'?}} {{30-34=GenericClass}}
@@ -1132,9 +1132,10 @@ extension rdar17391625derived {
}
// <rdar://problem/27671033> Crash when defining property inside an invalid extension
// (This extension is no longer invalid.)
public protocol rdar27671033P {}
struct rdar27671033S<Key, Value> {}
extension rdar27671033S : rdar27671033P where Key == String { // expected-error {{extension of type 'rdar27671033S' with constraints cannot have an inheritance clause}}
extension rdar27671033S : rdar27671033P where Key == String {
let d = rdar27671033S<Int, Int>() // expected-error {{extensions must not contain stored properties}}
}

0 comments on commit 041b141

Please sign in to comment.