@@ -724,12 +724,6 @@ class ApplyClassifier {
724724 DeclContext *RethrowsDC = nullptr ;
725725 DeclContext *ReasyncDC = nullptr ;
726726
727- // Indicates if `classifyApply` will attempt to classify SelfApplyExpr
728- // because that should be done only in certain contexts like when infering
729- // if "async let" implicit auto closure wrapping initialize expression can
730- // throw.
731- bool ClassifySelfApplyExpr = false ;
732-
733727 DeclContext *getPolymorphicEffectDeclContext (EffectKind kind) const {
734728 switch (kind) {
735729 case EffectKind::Throws: return RethrowsDC;
@@ -758,38 +752,29 @@ class ApplyClassifier {
758752
759753 if (auto *SAE = dyn_cast<SelfApplyExpr>(E)) {
760754 assert (!E->isImplicitlyAsync ());
761-
762- if (ClassifySelfApplyExpr) {
763- // Do not consider throw properties in SelfAssignExpr with an implicit
764- // conversion base.
765- if (isa<ImplicitConversionExpr>(SAE->getBase ()))
766- return Classification ();
767-
768- auto fnType = E->getType ()->getAs <AnyFunctionType>();
769- if (fnType && fnType->isThrowing ()) {
770- return Classification::forUnconditional (
771- EffectKind::Throws, PotentialEffectReason::forApply ());
772- }
773- }
774- return Classification ();
775755 }
776756
777757 auto type = E->getFn ()->getType ();
778758 if (!type) return Classification::forInvalidCode ();
779759 auto fnType = type->getAs <AnyFunctionType>();
780760 if (!fnType) return Classification::forInvalidCode ();
781761
782- // If the function doesn't have any effects, we're done here.
762+ auto fnRef = AbstractFunction::getAppliedFn (E);
763+ auto conformances = fnRef.getSubstitutions ().getConformances ();
764+ const auto hasAnyConformances = !conformances.empty ();
765+
766+ // If the function doesn't have any effects or conformances, we're done
767+ // here.
783768 if (!fnType->isThrowing () &&
784769 !E->implicitlyThrows () &&
785770 !fnType->isAsync () &&
786- !E->isImplicitlyAsync ()) {
771+ !E->isImplicitlyAsync () &&
772+ !hasAnyConformances) {
787773 return Classification ();
788774 }
789775
790776 // Decompose the application.
791777 auto *args = E->getArgs ();
792- auto fnRef = AbstractFunction::getAppliedFn (E);
793778
794779 // If any of the arguments didn't type check, fail.
795780 for (auto arg : *args) {
@@ -2983,7 +2968,6 @@ void TypeChecker::checkPropertyWrapperEffects(
29832968
29842969bool TypeChecker::canThrow (Expr *expr) {
29852970 ApplyClassifier classifier;
2986- classifier.ClassifySelfApplyExpr = true ;
2987- return (classifier.classifyExpr (expr, EffectKind::Throws) ==
2988- ConditionalEffectKind::Always);
2971+ auto effect = classifier.classifyExpr (expr, EffectKind::Throws);
2972+ return (effect != ConditionalEffectKind::None);
29892973}
0 commit comments