@@ -97,10 +97,12 @@ abstract class Symbols: SymbolTable {
97
97
def isClass = false ; // to be overridden
98
98
99
99
final def isValue = isTerm && ! (isModule && hasFlag(PACKAGE | JAVA ));
100
- final def isVariable = isTerm && hasFlag(MUTABLE );
100
+ final def isVariable = isTerm && hasFlag(MUTABLE ) && ! isMethod;
101
+ final def isSetter = isTerm && hasFlag(ACCESSOR ) && nme.isSetterName(name);
102
+ // todo: make independent of name, as this can be forged.
101
103
final def hasGetter = isTerm && nme.isLocalName(name);
102
104
final def isValueParameter = isTerm && hasFlag(PARAM );
103
- final def isLocalDummy = isTerm && (name startsWith nme.LOCAL_PREFIX );
105
+ final def isLocalDummy = isTerm && nme.isLocalDummyName(name );
104
106
final def isMethod = isTerm && hasFlag(METHOD );
105
107
final def isSourceMethod = isTerm && (flags & (METHOD | STABLE )) == METHOD ;
106
108
final def isLabel = isTerm && hasFlag(LABEL );
@@ -115,7 +117,8 @@ abstract class Symbols: SymbolTable {
115
117
final def isAliasType = isType && ! isClass && ! hasFlag(DEFERRED );
116
118
final def isAbstractType = isType && ! isClass && hasFlag(DEFERRED );
117
119
final def isTypeParameter = isType && hasFlag(PARAM );
118
- final def isAnonymousClass = isClass && (name startsWith nme.ANON_CLASS_NAME ); // startsWith necessary because name may grow when lifted and also because of anonymous function classes
120
+ final def isAnonymousClass = isClass && (originalName startsWith nme.ANON_CLASS_NAME );
121
+ // startsWith necessary because name may grow when lifted and also because of anonymous function classes
119
122
final def isRefinementClass = isClass && name == nme.REFINE_CLASS_NAME .toTypeName; // no lifting for refinement classes
120
123
final def isModuleClass = isClass && hasFlag(MODULE );
121
124
final def isPackageClass = isClass && hasFlag(PACKAGE );
@@ -133,8 +136,13 @@ abstract class Symbols: SymbolTable {
133
136
isConstructor && owner.primaryConstructor == this ;
134
137
135
138
/** Is this symbol an implementation class for a trait ? */
136
- final def isImplClass : boolean =
137
- name.endsWith(nme.IMPL_CLASS_SUFFIX );
139
+ final def isImplClass : boolean = isClass && nme.isImplClassName(name);
140
+
141
+ final def needsImplClass : boolean =
142
+ isTrait && (! hasFlag(INTERFACE ) || hasFlag(lateINTERFACE)) && ! isImplClass;
143
+
144
+ /** Is this symbol a module variable ? */
145
+ final def isModuleVar : boolean = isVariable && nme.isModuleVarName(name);
138
146
139
147
/** Is this symbol static (i.e. with no outer instance)? */
140
148
final def isStatic : boolean = hasFlag(STATIC ) || isRoot || owner.isStaticOwner;
@@ -203,6 +211,8 @@ abstract class Symbols: SymbolTable {
203
211
def name : Name = rawname;
204
212
final def name_= (name : Name ): unit = { rawname = name }
205
213
214
+ def originalName = nme.originalName(name);
215
+
206
216
final def flags = {
207
217
val fs = rawflags & phase.flagMask;
208
218
(fs | ((fs & LateFlags ) >>> LateShift )) & ~ (fs >>> AntiShift )
@@ -296,7 +306,7 @@ abstract class Symbols: SymbolTable {
296
306
phase = current;
297
307
limit = current;
298
308
}
299
- assert(infos != null /* , name.toString() + " " + limit + " " + phase */ );
309
+ assert(infos != null , name);
300
310
infos.info
301
311
} else {
302
312
var infos = this .infos;
@@ -454,11 +464,11 @@ abstract class Symbols: SymbolTable {
454
464
*/
455
465
final def accessed : Symbol = {
456
466
assert(hasFlag(ACCESSOR ));
457
- // todo: make independent of name, as this can be forged.
458
- owner.info.decl(
459
- nme.getterToLocal(if (nme.isSetterName(name)) nme.setterToGetter(name) else name))
467
+ owner.info.decl(nme.getterToLocal(if (isSetter) nme.setterToGetter(name) else name))
460
468
}
461
469
470
+ final def implClass : Symbol = owner.info.decl(nme.implClassName(name));
471
+
462
472
/** For a paramaccessor: a superclass paramaccessor for which this symbol is
463
473
* an alias, NoSymbol for all others */
464
474
def alias : Symbol = NoSymbol ;
@@ -492,6 +502,13 @@ abstract class Symbols: SymbolTable {
492
502
owner.info.decl(name.toTermName).suchThat(sym => sym.rawInfo != NoType )
493
503
else NoSymbol ;
494
504
505
+ final def toInterface : Symbol =
506
+ if (isImplClass) {
507
+ val iface = tpe.parents.last.symbol;
508
+ assert(nme.implClassName(iface.name) == name, this );
509
+ iface
510
+ } else this ;
511
+
495
512
/** The module corresponding to this module class (note that this
496
513
* is not updated when a module is cloned).
497
514
*/
@@ -525,17 +542,13 @@ abstract class Symbols: SymbolTable {
525
542
sym
526
543
}
527
544
528
- /** The superaccessor for this symbol in the definition of `base'. */
529
- final def superAccessor (base : Symbol ): Symbol =
530
- base.info.decl(nme.superName(name)) suchThat (.alias.== (this ));
531
-
532
545
/** The getter of this value definition in class `base', or NoSymbol if none exists */
533
546
final def getter (base : Symbol ): Symbol =
534
- base.info.decl(nme.localToGetter (name)) filter (.hasFlag(ACCESSOR ));
547
+ base.info.decl(nme.getterName (name)) filter (.hasFlag(ACCESSOR ));
535
548
536
549
/** The setter of this value definition, or NoSymbol if none exists */
537
550
final def setter (base : Symbol ): Symbol =
538
- base.info.decl(nme.getterToSetter(nme.localToGetter (name))) filter (.hasFlag(ACCESSOR ));
551
+ base.info.decl(nme.getterToSetter(nme.getterName (name))) filter (.hasFlag(ACCESSOR ));
539
552
540
553
/** Remove private modifier from symbol `sym's definition. If `sym' is a
541
554
* term symbol rename it by expanding its name to avoid name clashes
@@ -559,9 +572,12 @@ abstract class Symbols: SymbolTable {
559
572
getter(owner).expandName(base);
560
573
setter(owner).expandName(base);
561
574
}
562
- name = newTermName(name.toString() + " $$ " + base.fullNameString( '$' ) )
575
+ name = base.expandedName(name )
563
576
}
564
577
578
+ def expandedName (name : Name ): Name =
579
+ newTermName(fullNameString('$' ) + nme.EXPAND_SEPARATOR_STRING + name);
580
+
565
581
/*
566
582
def referenced: Symbol =
567
583
throw new Error("referenced inapplicable for " + this);
@@ -709,9 +725,10 @@ abstract class Symbols: SymbolTable {
709
725
}
710
726
711
727
override def alias : Symbol =
712
- if (hasFlag(SUPERACCESSOR | PARAMACCESSOR )) referenced else NoSymbol ;
728
+ if (hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN )) initialize. referenced else NoSymbol ;
713
729
714
730
def setAlias (alias : Symbol ): TermSymbol = {
731
+ assert(alias != NoSymbol );
715
732
assert(hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN ));
716
733
referenced = alias;
717
734
this
@@ -738,12 +755,14 @@ abstract class Symbols: SymbolTable {
738
755
override def tpe : Type = {
739
756
assert(tpeCache != NoType , this );
740
757
if (tpePhase != phase) {
741
- if (isValid(tpePhase)) tpePhase = phase
742
- else {
758
+ if (isValid(tpePhase)) {
759
+ tpePhase = phase
760
+ } else {
743
761
if (hasFlag(INITIALIZED )) tpePhase = phase;
744
762
tpeCache = NoType ;
745
- tpeCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType,
746
- this , unsafeTypeParams map (.tpe))
763
+ val targs = if (phase.erasedTypes && this != ArrayClass ) List ()
764
+ else unsafeTypeParams map (.tpe);
765
+ tpeCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this , targs)
747
766
}
748
767
}
749
768
assert(tpeCache != null /* , "" + this + " " + phase*/ );// debug
@@ -803,12 +822,11 @@ abstract class Symbols: SymbolTable {
803
822
val p = thisTypePhase;
804
823
if (p != phase) {
805
824
thisTypePhase = phase;
806
- if (! isValid(p)) {
825
+ if (! (isValid(p) /* ||
826
+ thisTypePhase != null && thisTypePhase.erasedTypes && phase.erasedTypes*/ )) {
807
827
thisTypeCache =
808
- if (isModuleClass && ! isRoot && ! phase.erasedTypes) {
809
- assert(sourceModule != NoSymbol , this );
810
- singleType(owner.thisType, sourceModule);
811
- }
828
+ if (isModuleClass && ! isRoot && ! phase.erasedTypes)
829
+ singleType(owner.thisType, sourceModule);
812
830
else ThisType (this );
813
831
}
814
832
}
0 commit comments