diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-08-29 18:16:22 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-29 18:33:59 +0200 |
commit | 0fbb427a2d0c20dd20d046249f37164b46eb602d (patch) | |
tree | 34be632505dcd188096cf1a92b31124b2dfa8b34 /test/files | |
parent | 3304bc33987f5821912bb0c7371b5e9a115c893d (diff) | |
download | scala-0fbb427a2d0c20dd20d046249f37164b46eb602d.tar.gz scala-0fbb427a2d0c20dd20d046249f37164b46eb602d.tar.bz2 scala-0fbb427a2d0c20dd20d046249f37164b46eb602d.zip |
Ensure trait var accessor type is widened
If we don't widen, we'll fail to find the setter when
typing `x = 42`, because `x` is constant-folded to `0`,
as its type is `=> Int(0)`. After widening, `x` is
type checked to `x` and its symbol is the getter in the
trait, which can then be rewritten to the setter.
Regression spotted and test case by szeiger.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/pos/fields_widen_trait_var.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/files/pos/fields_widen_trait_var.scala b/test/files/pos/fields_widen_trait_var.scala new file mode 100644 index 0000000000..0ea9d9629a --- /dev/null +++ b/test/files/pos/fields_widen_trait_var.scala @@ -0,0 +1,4 @@ +// check that the `var x` below is assigned the type `Int`, and not `Constant(0)`, +// and that we can assign to it (if it gets a constant type, the `x` in `x = 42` +// is constant-folded to `0` and we can't find a setter.. +trait C { protected final var x = 0; x = 42 } |