@@ -691,8 +691,7 @@ static void checkRedeclaration(PrecedenceGroupDecl *group) {
691
691
692
692
// / Check whether \c current is a redeclaration.
693
693
evaluator::SideEffect
694
- CheckRedeclarationRequest::evaluate (Evaluator &eval, ValueDecl *current,
695
- NominalTypeDecl *SelfNominalType) const {
694
+ CheckRedeclarationRequest::evaluate (Evaluator &eval, ValueDecl *current) const {
696
695
// Ignore invalid and anonymous declarations.
697
696
if (current->isInvalid () || !current->hasName ())
698
697
return std::make_tuple<>();
@@ -1135,6 +1134,26 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current,
1135
1134
break ;
1136
1135
}
1137
1136
}
1137
+
1138
+ // Look to see if this type has a value generic with the same name and that
1139
+ // the current value is a property.
1140
+ if (currentDC->isTypeContext () && currentDC->isGenericContext () &&
1141
+ isa<VarDecl>(current)) {
1142
+ auto gpList = currentDC->getAsDecl ()->getAsGenericContext ()->getGenericParams ();
1143
+
1144
+ if (gpList && !current->getBaseName ().isSpecial ()) {
1145
+ auto gp = gpList->lookUpGenericParam (current->getBaseIdentifier ());
1146
+
1147
+ if (gp && gp->isValue ()) {
1148
+ ctx.Diags .diagnoseWithNotes (
1149
+ current->diagnose (diag::invalid_redecl, current), [&]() {
1150
+ gp->diagnose (diag::invalid_redecl_prev, gp);
1151
+ });
1152
+ current->setInvalid ();
1153
+ }
1154
+ }
1155
+ }
1156
+
1138
1157
return std::make_tuple<>();
1139
1158
}
1140
1159
@@ -2348,11 +2367,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2348
2367
// Force some requests, which can produce diagnostics.
2349
2368
2350
2369
// Check redeclaration.
2351
- (void )evaluateOrDefault (
2352
- Ctx.evaluator ,
2353
- CheckRedeclarationRequest{
2354
- VD, VD->getDeclContext ()->getSelfNominalTypeDecl ()},
2355
- {});
2370
+ (void )evaluateOrDefault (Ctx.evaluator , CheckRedeclarationRequest{VD}, {});
2356
2371
2357
2372
// Compute access level.
2358
2373
(void ) VD->getFormalAccess ();
0 commit comments