diff --git a/compiler/src/dotty/tools/dotc/transform/Memoize.scala b/compiler/src/dotty/tools/dotc/transform/Memoize.scala index 8b5ceb0aadbb..605f784b602f 100644 --- a/compiler/src/dotty/tools/dotc/transform/Memoize.scala +++ b/compiler/src/dotty/tools/dotc/transform/Memoize.scala @@ -69,6 +69,7 @@ import Decorators._ val sym = tree.symbol def newField = { + assert(!sym.hasAnnotation(defn.ScalaStaticAnnot)) val fieldType = if (sym.isGetter) sym.info.resultType else /*sym.isSetter*/ sym.info.firstParamTypes.head diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index 4c07ca4c8c7b..b6ae97450aae 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -97,8 +97,13 @@ class SymUtils(val self: Symbol) extends AnyVal { if (self.isSetter) self else accessorNamed(self.asTerm.name.setterName) - def field(implicit ctx: Context): Symbol = - self.owner.info.decl(self.asTerm.name.fieldName).suchThat(!_.is(Method)).symbol + def field(implicit ctx: Context): Symbol = { + val thisName = self.name.asTermName + val fieldName = + if (self.hasAnnotation(defn.ScalaStaticAnnot)) thisName.getterName + else thisName.fieldName + self.owner.info.decl(fieldName).suchThat(!_.is(Method)).symbol + } def isField(implicit ctx: Context): Boolean = self.isTerm && !self.is(Method)