File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2107,6 +2107,14 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
21072107 }
21082108 }
21092109
2110+ // Reject "class" methods on actors.
2111+ if (SD->getStaticSpelling () == StaticSpellingKind::KeywordClass &&
2112+ SD->getDeclContext ()->getSelfClassDecl () &&
2113+ SD->getDeclContext ()->getSelfClassDecl ()->isActor ()) {
2114+ SD->diagnose (diag::class_subscript_not_in_class, false )
2115+ .fixItReplace (SD->getStaticLoc (), " static" );
2116+ }
2117+
21102118 // Now check all the accessors.
21112119 SD->visitEmittedAccessors ([&](AccessorDecl *accessor) {
21122120 visit (accessor);
Original file line number Diff line number Diff line change @@ -44,4 +44,7 @@ actor A2 {
4444extension A2 {
4545 class func h2( ) { } // expected-error{{class methods are only allowed within classes; use 'static' to declare a static method}}
4646 static func i2( ) { } // okay
47+
48+ class subscript( i: Int ) -> Int { i } // expected-error{{class subscripts are only allowed within classes; use 'static' to declare a static subscript}}
49+ static subscript( s: String ) -> String { s }
4750}
You can’t perform that action at this time.
0 commit comments