File tree 6 files changed +25
-2
lines changed 6 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -601,7 +601,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context
601
601
isPrivate // || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass)
602
602
603
603
def isFinal : Boolean = sym is Flags .Final
604
- def isStaticMember : Boolean = (sym ne NoSymbol ) && ((sym is Flags .JavaStatic ) || (owner is Flags .ImplClass ))
604
+ def isStaticMember : Boolean = (sym ne NoSymbol ) &&
605
+ ((sym is Flags .JavaStatic ) || (owner is Flags .ImplClass ) || toDenot(sym).hasAnnotation(ctx.definitions.ScalaStaticAnnot ))
605
606
// guard against no sumbol cause this code is executed to select which call type(static\dynamic) to use to call array.clone
606
607
607
608
def isBottomClass : Boolean = (sym ne defn.NullClass ) && (sym ne defn.NothingClass )
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class Compiler {
44
44
List (new FirstTransform ,
45
45
new CheckReentrant ),
46
46
List (new RefChecks ,
47
+ new CheckStatic ,
47
48
new ElimRepeated ,
48
49
new NormalizeFlags ,
49
50
new ExtensionMethods ,
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
320
320
case _ =>
321
321
false
322
322
}
323
- try test || tp.symbol.is(JavaStatic )
323
+ try test || tp.symbol.is(JavaStatic ) || tp.symbol.hasAnnotation(defn. ScalaStaticAnnot )
324
324
catch { // See remark in SymDenotations#accessWithin
325
325
case ex : NotDefinedHere => test(ctx.addMode(Mode .FutureDefsOK ))
326
326
}
@@ -337,6 +337,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
337
337
else if (prefixIsElidable(tp)) Ident (tp)
338
338
else if (tp.symbol.is(Module ) && ctx.owner.isContainedIn(tp.symbol.moduleClass))
339
339
followOuterLinks(This (tp.symbol.moduleClass.asClass))
340
+ else if (tp.symbol hasAnnotation defn.ScalaStaticAnnot )
341
+ Ident (tp)
340
342
else tp.prefix match {
341
343
case pre : SingletonType => followOuterLinks(singleton(pre)).select(tp)
342
344
case pre => SelectFromTypeTree (TypeTree (pre), tp)
Original file line number Diff line number Diff line change @@ -462,6 +462,8 @@ class Definitions {
462
462
def ScalaLongSignatureAnnot (implicit ctx : Context ) = ScalaLongSignatureAnnotType .symbol.asClass
463
463
lazy val ScalaStrictFPAnnotType = ctx.requiredClassRef(" scala.annotation.strictfp" )
464
464
def ScalaStrictFPAnnot (implicit ctx : Context ) = ScalaStrictFPAnnotType .symbol.asClass
465
+ lazy val ScalaStaticAnnotType = ctx.requiredClassRef(" scala.annotation.static" )
466
+ def ScalaStaticAnnot (implicit ctx : Context ) = ScalaStaticAnnotType .symbol.asClass
465
467
lazy val SerialVersionUIDAnnotType = ctx.requiredClassRef(" scala.SerialVersionUID" )
466
468
def SerialVersionUIDAnnot (implicit ctx : Context ) = SerialVersionUIDAnnotType .symbol.asClass
467
469
lazy val TASTYSignatureAnnotType = ctx.requiredClassRef(" scala.annotation.internal.TASTYSignature" )
Original file line number Diff line number Diff line change @@ -285,6 +285,10 @@ object SymDenotations {
285
285
final def addAnnotation (annot : Annotation ): Unit =
286
286
annotations = annot :: myAnnotations
287
287
288
+ /** Add given annotation to the annotations of this denotation */
289
+ final def addAnnotation (annot : ClassSymbol )(implicit ctx : Context ): Unit =
290
+ addAnnotation(ConcreteAnnotation (tpd.ref(annot)))
291
+
288
292
/** Remove annotation with given class from this denotation */
289
293
final def removeAnnotation (cls : Symbol )(implicit ctx : Context ): Unit =
290
294
annotations = myAnnotations.filterNot(_ matches cls)
Original file line number Diff line number Diff line change
1
+ package scala .annotation
2
+
3
+ import scala .annotation .meta ._
4
+
5
+ /** https://github.com/scala/scala.github.com/pull/491 */
6
+
7
+ @ field
8
+ @ getter
9
+ @ beanGetter
10
+ @ beanGetter
11
+ @ param
12
+ @ setter
13
+ final class static extends StaticAnnotation
You can’t perform that action at this time.
0 commit comments