File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -2963,6 +2963,17 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2963
2963
if (enumDecl->hasRawType ())
2964
2964
checkEnumRawValues (TC, enumDecl);
2965
2965
}
2966
+
2967
+ // Only generic and protocol types are permitted to have
2968
+ // trailing where clauses.
2969
+ if (auto trailingWhereClause = ED->getTrailingWhereClause ()) {
2970
+ if (!ED->getGenericParams () &&
2971
+ !ED->isInvalid ()) {
2972
+ ED->diagnose (diag::extension_nongeneric_trailing_where,
2973
+ nominal->getFullName ())
2974
+ .highlight (trailingWhereClause->getSourceRange ());
2975
+ }
2976
+ }
2966
2977
}
2967
2978
2968
2979
if (auto genericParams = ED->getGenericParams ())
Original file line number Diff line number Diff line change @@ -348,14 +348,7 @@ static void bindExtensionToNominal(ExtensionDecl *ext,
348
348
// If we have a trailing where clause, deal with it now.
349
349
// For now, trailing where clauses are only permitted on protocol extensions.
350
350
if (auto trailingWhereClause = ext->getTrailingWhereClause ()) {
351
- if (!genericParams) {
352
- // Only generic and protocol types are permitted to have
353
- // trailing where clauses.
354
- ext->diagnose (diag::extension_nongeneric_trailing_where,
355
- nominal->getFullName ())
356
- .highlight (trailingWhereClause->getSourceRange ());
357
- ext->setTrailingWhereClause (nullptr );
358
- } else {
351
+ if (genericParams) {
359
352
// Merge the trailing where clause into the generic parameter list.
360
353
// FIXME: Long-term, we'd like clients to deal with the trailing where
361
354
// clause explicitly, but for now it's far more direct to represent
@@ -365,6 +358,9 @@ static void bindExtensionToNominal(ExtensionDecl *ext,
365
358
trailingWhereClause->getWhereLoc (),
366
359
trailingWhereClause->getRequirements ());
367
360
}
361
+
362
+ // If there's no generic parameter list, the where clause is diagnosed
363
+ // in typeCheckDecl().
368
364
}
369
365
370
366
nominal->addExtension (ext);
You can’t perform that action at this time.
0 commit comments