Skip to content

Commit

Permalink
Typer: allow to assign to vals inside trait setters.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkDimius committed Sep 14, 2015
1 parent 406ec56 commit 91f992c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def lhs1 = typed(untpd.TypedSplice(lhsCore))
def canAssign(sym: Symbol) = // allow assignments from the primary constructor to class fields
sym.is(Mutable, butNot = Accessor) ||
ctx.owner.isPrimaryConstructor && !sym.is(Method) && sym.owner == ctx.owner.owner
ctx.owner.isPrimaryConstructor && !sym.is(Method) && sym.owner == ctx.owner.owner ||
ctx.owner.name.isTraitSetterName
lhsCore.tpe match {
case ref: TermRef if canAssign(ref.symbol) =>
assignType(cpy.Assign(tree)(lhs1, typed(tree.rhs, ref.info)))
Expand Down

0 comments on commit 91f992c

Please sign in to comment.