Skip to content

Commit

Permalink
Merge pull request scala#1428 from dotty-staging/fix-#1285
Browse files Browse the repository at this point in the history
Fix scala#1285: Mutable vars are not to be considered constant
  • Loading branch information
odersky authored Jul 31, 2016
2 parents 54895cd + 2eb0fed commit ed05cba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ object Flags {
/** Flags guaranteed to be set upon symbol creation */
final val FromStartFlags =
AccessFlags | Module | Package | Deferred | Final | MethodOrHKCommon | Param | ParamAccessor | Scala2ExistentialCommon |
InSuperCall | Touched | JavaStatic | CovariantOrOuter | ContravariantOrLabel | ExpandedName | AccessorOrSealed |
Mutable.toCommonFlags | InSuperCall | Touched | JavaStatic | CovariantOrOuter | ContravariantOrLabel | ExpandedName | AccessorOrSealed |
CaseAccessorOrBaseTypeArg | Fresh | Frozen | Erroneous | ImplicitCommon | Permanent | Synthetic |
LazyOrTrait | SuperAccessorOrScala2x | SelfNameOrImplClass

Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ class Namer { typer: Typer =>

// println(s"final inherited for $sym: ${inherited.toString}") !!!
// println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}")
def isInline = sym.is(Final, butNot = Method)

def isInline = sym.is(Final, butNot = Method | Mutable)
// Widen rhs type and approximate `|' but keep ConstantTypes if
// definition is inline (i.e. final in Scala2).
def widenRhs(tp: Type): Type = tp.widenTermRefExpr match {
Expand Down
4 changes: 4 additions & 0 deletions tests/pos/i1285.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Test {
final var x = false
x = true
}

0 comments on commit ed05cba

Please sign in to comment.