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> {
2107
2107
}
2108
2108
}
2109
2109
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
+
2110
2118
// Now check all the accessors.
2111
2119
SD->visitEmittedAccessors ([&](AccessorDecl *accessor) {
2112
2120
visit (accessor);
Original file line number Diff line number Diff line change @@ -44,4 +44,7 @@ actor A2 {
44
44
extension A2 {
45
45
class func h2( ) { } // expected-error{{class methods are only allowed within classes; use 'static' to declare a static method}}
46
46
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 }
47
50
}
You can’t perform that action at this time.
0 commit comments