Skip to content

NCGenerics: remove the reverse-condfail workaround #75183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
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
2 changes: 1 addition & 1 deletion docs/Generics/chapters/class-inheritance.tex
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
\item The witness must be in a protocol extension. If the witness is a method on the class, there is no way to observe the concrete substitution for the protocol \texttt{Self} type, because it is not a generic parameter of the class method.
\item (The hack) The interface type of the protocol requirement must not mention any associated types.
\end{enumerate}
The determination of whether to use a static or covariant \texttt{Self} type for a class conformance is implemented by the type cheker function \texttt{matchWitness()}.
The determination of whether to use a static or covariant \texttt{Self} type for a class conformance is implemented by the type checker function \texttt{matchWitness()}.

Indeed, Condition~3 is a hack; it opens up an exception where the soundness hole we worked so hard to close is once again allowed. In an ideal world, Conditions 1~and~2 would be sufficient, but by the time the soundness hole was discovered and closed, existing code had already been written taking advantage of it. The scenario necessitating Condition~3 is when the default implementation appears in a \emph{constrained} protocol extension:
\begin{Verbatim}
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ EXPERIMENTAL_FEATURE(DebugDescriptionMacro, true)

EXPERIMENTAL_FEATURE(ReinitializeConsumeInMultiBlockDefer, false)

EXPERIMENTAL_FEATURE(SE427NoInferenceOnExtension, false)

#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
#undef EXPERIMENTAL_FEATURE
#undef UPCOMING_FEATURE
Expand Down
1 change: 0 additions & 1 deletion lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ static bool usesFeatureSensitive(Decl *decl) {

UNINTERESTING_FEATURE(DebugDescriptionMacro)
UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
UNINTERESTING_FEATURE(SE427NoInferenceOnExtension)

// ----------------------------------------------------------------------------
// MARK: - FeatureSet
Expand Down
9 changes: 0 additions & 9 deletions lib/Sema/TypeCheckGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,6 @@ GenericSignatureRequest::evaluate(Evaluator &evaluator,
// to invertible protocols. This forces people to write out the conditions.
inferInvertibleReqs = !ext->isAddingConformanceToInvertible();

// FIXME: to workaround a reverse condfail, always infer the requirements if
// the extension is in a swiftinterface file. This is temporary and should
// be removed soon. (rdar://130424971)
if (auto *sf = ext->getOutermostParentSourceFile()) {
if (sf->Kind == SourceFileKind::Interface
&& !ctx.LangOpts.hasFeature(Feature::SE427NoInferenceOnExtension))
inferInvertibleReqs = true;
}

collectAdditionalExtensionRequirements(ext->getExtendedType(), extraReqs);

auto *extendedNominal = ext->getExtendedNominal();
Expand Down
8 changes: 0 additions & 8 deletions test/ModuleInterface/noncopyable_generics.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
// RUN: %empty-directory(%t)

// Due to SE427NoInferenceOnExtension not being in production
// REQUIRES: asserts

// RUN: %target-swift-frontend -swift-version 5 -enable-library-evolution -emit-module \
// RUN: -enable-experimental-feature SuppressedAssociatedTypes \
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -enable-experimental-feature SE427NoInferenceOnExtension \
// RUN: -o %t/NoncopyableGenerics_Misc.swiftmodule \
// RUN: -emit-module-interface-path %t/NoncopyableGenerics_Misc.swiftinterface \
// RUN: %S/Inputs/NoncopyableGenerics_Misc.swift

// RUN: %target-swift-frontend -swift-version 5 -enable-library-evolution -emit-module \
// RUN: -enable-experimental-feature SuppressedAssociatedTypes \
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -enable-experimental-feature SE427NoInferenceOnExtension \
// RUN: -o %t/Swiftskell.swiftmodule \
// RUN: -emit-module-interface-path %t/Swiftskell.swiftinterface \
// RUN: %S/../Inputs/Swiftskell.swift
Expand All @@ -29,19 +24,16 @@
// RUN: %target-swift-frontend -compile-module-from-interface \
// RUN: -enable-experimental-feature SuppressedAssociatedTypes \
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -enable-experimental-feature SE427NoInferenceOnExtension \
// RUN: %t/NoncopyableGenerics_Misc.swiftinterface -o %t/NoncopyableGenerics_Misc.swiftmodule

// RUN: %target-swift-frontend -compile-module-from-interface \
// RUN: -enable-experimental-feature SuppressedAssociatedTypes \
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -enable-experimental-feature SE427NoInferenceOnExtension \
// RUN: %t/Swiftskell.swiftinterface -o %t/Swiftskell.swiftmodule

// RUN: %target-swift-frontend -emit-silgen -I %t %s \
// RUN: -enable-experimental-feature SuppressedAssociatedTypes \
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -enable-experimental-feature SE427NoInferenceOnExtension \
// RUN: -o %t/final.silgen

// RUN: %FileCheck %s --check-prefix=CHECK-SILGEN < %t/final.silgen
Expand Down

This file was deleted.