Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ static Type checkContextualRequirements(Type type,
return type;
}

auto &ctx = dc->getASTContext();

SourceLoc noteLoc;
{
// We are interested in either a contextual where clause or
Expand All @@ -669,6 +671,13 @@ static Type checkContextualRequirements(Type type,

const auto subMap = parentTy->getContextSubstitutions(decl->getDeclContext());
const auto genericSig = decl->getGenericSignature();
if (!genericSig) {
ctx.Diags.diagnose(loc, diag::recursive_decl_reference,
decl->getDescriptiveKind(), decl->getName());
decl->diagnose(diag::kind_declared_here, DescriptiveDeclKind::Type);
return ErrorType::get(ctx);
}

const auto result =
TypeChecker::checkGenericArguments(
dc, loc, noteLoc, type,
Expand All @@ -681,7 +690,7 @@ static Type checkContextualRequirements(Type type,
switch (result) {
case RequirementCheckResult::Failure:
case RequirementCheckResult::SubstitutionFailure:
return ErrorType::get(dc->getASTContext());
return ErrorType::get(ctx);
case RequirementCheckResult::Success:
return type;
}
Expand Down
12 changes: 12 additions & 0 deletions validation-test/compiler_crashers_2_fixed/rdar64992293.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: not %target-swift-frontend -typecheck %s

public protocol SomeProtocol {}

public struct Impl<Param>: SomeProtocol where Param: SomeProtocol {}

public struct Wrapper<Content> where Content: SomeProtocol {}

public extension Wrapper where Content == Impl<WrapperParam> {
typealias WrapperParam = SomeProtocol
}