@@ -724,12 +724,6 @@ class ApplyClassifier {
724
724
DeclContext *RethrowsDC = nullptr ;
725
725
DeclContext *ReasyncDC = nullptr ;
726
726
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
-
733
727
DeclContext *getPolymorphicEffectDeclContext (EffectKind kind) const {
734
728
switch (kind) {
735
729
case EffectKind::Throws: return RethrowsDC;
@@ -758,38 +752,29 @@ class ApplyClassifier {
758
752
759
753
if (auto *SAE = dyn_cast<SelfApplyExpr>(E)) {
760
754
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 ();
775
755
}
776
756
777
757
auto type = E->getFn ()->getType ();
778
758
if (!type) return Classification::forInvalidCode ();
779
759
auto fnType = type->getAs <AnyFunctionType>();
780
760
if (!fnType) return Classification::forInvalidCode ();
781
761
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.
783
768
if (!fnType->isThrowing () &&
784
769
!E->implicitlyThrows () &&
785
770
!fnType->isAsync () &&
786
- !E->isImplicitlyAsync ()) {
771
+ !E->isImplicitlyAsync () &&
772
+ !hasAnyConformances) {
787
773
return Classification ();
788
774
}
789
775
790
776
// Decompose the application.
791
777
auto *args = E->getArgs ();
792
- auto fnRef = AbstractFunction::getAppliedFn (E);
793
778
794
779
// If any of the arguments didn't type check, fail.
795
780
for (auto arg : *args) {
@@ -2983,7 +2968,6 @@ void TypeChecker::checkPropertyWrapperEffects(
2983
2968
2984
2969
bool TypeChecker::canThrow (Expr *expr) {
2985
2970
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);
2989
2973
}
0 commit comments