@@ -2718,6 +2718,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2718
2718
}
2719
2719
2720
2720
void visitSubscriptDecl (SubscriptDecl *SD) {
2721
+ auto *DC = SD->getDeclContext ();
2722
+
2721
2723
// Force requests that can emit diagnostics.
2722
2724
(void ) SD->getInterfaceType ();
2723
2725
(void ) SD->getGenericSignature ();
@@ -2768,7 +2770,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2768
2770
checkDefaultArguments (SD->getIndices ());
2769
2771
checkVariadicParameters (SD->getIndices (), SD);
2770
2772
2771
- if (SD-> getDeclContext () ->getSelfClassDecl ()) {
2773
+ if (DC ->getSelfClassDecl ()) {
2772
2774
checkDynamicSelfType (SD, SD->getValueInterfaceType ());
2773
2775
2774
2776
if (SD->getValueInterfaceType ()->hasDynamicSelfType () &&
@@ -2779,15 +2781,15 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2779
2781
2780
2782
// Reject "class" methods on actors.
2781
2783
if (SD->getStaticSpelling () == StaticSpellingKind::KeywordClass &&
2782
- SD-> getDeclContext () ->getSelfClassDecl () &&
2783
- SD-> getDeclContext () ->getSelfClassDecl ()->isActor ()) {
2784
+ DC ->getSelfClassDecl () &&
2785
+ DC ->getSelfClassDecl ()->isActor ()) {
2784
2786
SD->diagnose (diag::class_subscript_not_in_class, false )
2785
2787
.fixItReplace (SD->getStaticLoc (), " static" );
2786
2788
}
2787
2789
2788
2790
// Reject noncopyable typed subscripts with read/set accessors since we
2789
2791
// cannot define modify operations upon them without copying the read.
2790
- if (SD->getElementInterfaceType ()->isNoncopyable ()) {
2792
+ if (SD->getElementInterfaceType ()->isNoncopyable (DC )) {
2791
2793
if (auto *read = SD->getAccessor (AccessorKind::Read)) {
2792
2794
if (!read->isImplicit ()) {
2793
2795
if (auto *set = SD->getAccessor (AccessorKind::Set)) {
0 commit comments