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 @@ -2003,6 +2003,14 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2003
2003
}
2004
2004
}
2005
2005
2006
+ // Reject "class" methods on actors.
2007
+ if (SD->getStaticSpelling () == StaticSpellingKind::KeywordClass &&
2008
+ SD->getDeclContext ()->getSelfClassDecl () &&
2009
+ SD->getDeclContext ()->getSelfClassDecl ()->isActor ()) {
2010
+ SD->diagnose (diag::class_subscript_not_in_class, false )
2011
+ .fixItReplace (SD->getStaticLoc (), " static" );
2012
+ }
2013
+
2006
2014
// Now check all the accessors.
2007
2015
SD->visitEmittedAccessors ([&](AccessorDecl *accessor) {
2008
2016
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