File tree Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ object NameOps {
63
63
(if (name.isTermName) n.toTermName else n.toTypeName).asInstanceOf [N ]
64
64
65
65
def isConstructorName = name == CONSTRUCTOR || name == TRAIT_CONSTRUCTOR
66
+ def isStaticConstructorName = name == STATIC_CONSTRUCTOR
66
67
def isExceptionResultName = name startsWith EXCEPTION_RESULT_PREFIX
67
68
def isImplClassName = name endsWith IMPL_CLASS_SUFFIX
68
69
def isLocalDummyName = name startsWith LOCALDUMMY_PREFIX
Original file line number Diff line number Diff line change @@ -594,6 +594,10 @@ object SymDenotations {
594
594
final def isPrimaryConstructor (implicit ctx : Context ) =
595
595
isConstructor && owner.primaryConstructor == symbol
596
596
597
+ /** Does this symbol denote the primary constructor of its enclosing class? */
598
+ final def isStaticConstructor (implicit ctx : Context ) =
599
+ name.isStaticConstructorName
600
+
597
601
/** Is this a subclass of the given class `base`? */
598
602
def isSubClass (base : Symbol )(implicit ctx : Context ) = false
599
603
Original file line number Diff line number Diff line change @@ -476,7 +476,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
476
476
def canAssign (sym : Symbol ) = // allow assignments from the primary constructor to class fields
477
477
sym.is(Mutable , butNot = Accessor ) ||
478
478
ctx.owner.isPrimaryConstructor && ! sym.is(Method ) && sym.owner == ctx.owner.owner ||
479
- ctx.owner.name.isTraitSetterName
479
+ ctx.owner.name.isTraitSetterName || ctx.owner.isStaticConstructor
480
480
lhsCore.tpe match {
481
481
case ref : TermRef if canAssign(ref.symbol) =>
482
482
assignType(cpy.Assign (tree)(lhs1, typed(tree.rhs, ref.info)))
You can’t perform that action at this time.
0 commit comments