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 /src | |
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 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 99c1b6991e..6b11dec967 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -952,7 +952,8 @@ trait Namers extends MethodSynthesis { !tpe.typeSymbolDirect.isModuleClass // Infer Foo.type instead of "object Foo" && (tpe.widen <:< pt) // Don't widen our way out of conforming to pt && ( sym.isVariable - || sym.isMethod && !sym.hasAccessorFlag + || sym.hasFlag(ACCESSOR) && !sym.hasFlag(STABLE) + || sym.isMethod && !sym.hasFlag(ACCESSOR) || isHidden(tpe) ) ) |