Skip to content

Fix #2375: Memoize should not generate static fields. #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/transform/Memoize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down