@@ -96,8 +96,11 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
96
96
def isByNameParam : Boolean = this .isValueParameter && (this hasFlag BYNAMEPARAM )
97
97
def isImplementationArtifact : Boolean = (this hasFlag BRIDGE ) || (this hasFlag VBRIDGE ) || (this hasFlag ARTIFACT )
98
98
def isJava : Boolean = isJavaDefined
99
- def isVal : Boolean = isTerm && ! isModule && ! isMethod && ! isMutable
100
- def isVar : Boolean = isTerm && ! isModule && ! isMethod && ! isLazy && isMutable
99
+
100
+ def isField : Boolean = isTerm && ! isModule && (! isMethod || owner.isTrait && isAccessor)
101
+ def isVal : Boolean = isField && ! isMutable
102
+ def isVar : Boolean = isField && ! isLazy && isMutable
103
+
101
104
def isAbstract : Boolean = isAbstractClass || isDeferred || isAbstractType
102
105
def isPrivateThis = (this hasFlag PRIVATE ) && (this hasFlag LOCAL )
103
106
def isProtectedThis = (this hasFlag PROTECTED ) && (this hasFlag LOCAL )
@@ -2057,7 +2060,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
2057
2060
assert(hasAccessorFlag, this )
2058
2061
val localField = owner.info decl localName
2059
2062
2060
- if (localField == NoSymbol && this .hasFlag(MIXEDIN )) {
2063
+ if (localField == NoSymbol && this .hasFlag(MIXEDIN )) { // TODO: fields phase does not (yet?) add MIXEDIN in setMixedinAccessorFlags
2061
2064
// SI-8087: private[this] fields don't have a `localName`. When searching the accessed field
2062
2065
// for a mixin accessor of such a field, we need to look for `name` instead.
2063
2066
// The phase travel ensures that the field is found (`owner` is the trait class symbol, the
@@ -2103,8 +2106,15 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
2103
2106
/** If this is a lazy value, the lazy accessor; otherwise this symbol. */
2104
2107
def lazyAccessorOrSelf : Symbol = if (isLazy) lazyAccessor else this
2105
2108
2106
- /** If this is an accessor, the accessed symbol. Otherwise, this symbol. */
2107
- def accessedOrSelf : Symbol = if (hasAccessorFlag) accessed else this
2109
+ /** `accessed`, if this is an accessor that should have an underlying field. Otherwise, `this`.
2110
+ * Note that a "regular" accessor in a trait does not have a field, as an interface cannot define a field.
2111
+ * "non-regular" vals are: early initialized or lazy vals.
2112
+ * Eventually, we should delay introducing symbols for all val/vars until the fields (or lazyvals) phase,
2113
+ * as they are an implementation detail that's irrelevant to type checking.
2114
+ */
2115
+ def accessedOrSelf : Symbol =
2116
+ if (hasAccessorFlag && (! owner.isTrait || hasFlag(PRESUPER | LAZY ))) accessed
2117
+ else this
2108
2118
2109
2119
/** For an outer accessor: The class from which the outer originates.
2110
2120
* For all other symbols: NoSymbol
0 commit comments