Skip to content

Commit ec05421

Browse files
committed
Don't try to look up designated types
It's not strictly necessary for source compatibility, since removing it just means that (in a not-officially-supported compiler mode) we will accept code we would previously have rejected.
1 parent 627ecbd commit ec05421

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,21 +1524,6 @@ TypeChecker::lookupPrecedenceGroup(DeclContext *dc, Identifier name,
15241524
return PrecedenceGroupLookupResult(dc, name, std::move(groups));
15251525
}
15261526

1527-
static bool canResolveSingleNominalTypeDecl(
1528-
DeclContext *DC, SourceLoc loc, Identifier ident, ASTContext &Ctx) {
1529-
auto *TyR = new (Ctx) SimpleIdentTypeRepr(DeclNameLoc(loc),
1530-
DeclNameRef(ident));
1531-
1532-
TypeResolutionOptions options{TypeResolverContext::TypeAliasDecl};
1533-
options |= TypeResolutionFlags::SilenceErrors;
1534-
const auto result =
1535-
TypeResolution::forInterface(DC, options, /*unboundTyOpener*/ nullptr,
1536-
/*placeholderHandler*/ nullptr)
1537-
.resolveType(TyR);
1538-
1539-
return !result->hasError();
1540-
}
1541-
15421527
/// Validate the given operator declaration.
15431528
///
15441529
/// This establishes key invariants, such as an InfixOperatorDecl's
@@ -1555,15 +1540,13 @@ OperatorPrecedenceGroupRequest::evaluate(Evaluator &evaluator,
15551540
auto loc = IOD->getPrecedenceGroupLoc();
15561541
auto groups = TypeChecker::lookupPrecedenceGroup(dc, name, loc);
15571542

1558-
bool wasActuallyADesignatedType = !groups.hasResults() &&
1559-
ctx.TypeCheckerOpts.EnableOperatorDesignatedTypes &&
1560-
canResolveSingleNominalTypeDecl(dc, loc, name, ctx);
1561-
1562-
if (!wasActuallyADesignatedType)
1543+
if (groups.hasResults() ||
1544+
!ctx.TypeCheckerOpts.EnableOperatorDesignatedTypes)
15631545
return groups.getSingleOrDiagnose(loc);
15641546

1565-
// Warn about the designated type, then fall through to look up
1566-
// DefaultPrecedence as though `PrecedenceGroupName` had never been set.
1547+
// We didn't find the named precedence group and designated types are
1548+
// enabled, so we will assume that it was actually a designated type. Warn
1549+
// and fall through as though `PrecedenceGroupName` had never been set.
15671550
ctx.Diags.diagnose(IOD->getColonLoc(),
15681551
diag::operator_decl_remove_designated_types)
15691552
.fixItRemove({IOD->getColonLoc(), loc});

test/Parse/operator_decl_designated_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ prefix operator *^^
3030
postfix operator ^^*
3131

3232
infix operator **>> : UndeclaredPrecedence
33-
// expected-error@-1 {{unknown precedence group 'UndeclaredPrecedence'}}
33+
// expected-warning@-1 {{designated types are no longer used by the compiler}} {{21-43=}}
3434

3535
infix operator **+> : MediumPrecedence, UndeclaredProtocol
3636
// expected-warning@-1 {{designated types are no longer used by the compiler}} {{39-59=}}

0 commit comments

Comments
 (0)