diff options
author | liu fengyun <liufengyunchina@gmail.com> | 2016-11-07 23:10:01 +0100 |
---|---|---|
committer | liu fengyun <liu@fengy.me> | 2016-11-24 13:36:04 +0100 |
commit | 8592af1c815c34078d89c08536addbe757550179 (patch) | |
tree | babe705efa6062e35e64d78302735fd9511df9b2 /compiler/src/dotty/tools/dotc/typer | |
parent | 3599c243c86ae0a926ef45a435d38b7878dc322f (diff) | |
download | dotty-8592af1c815c34078d89c08536addbe757550179.tar.gz dotty-8592af1c815c34078d89c08536addbe757550179.tar.bz2 dotty-8592af1c815c34078d89c08536addbe757550179.zip |
fix #1670: move the check of value class to typer
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/RefChecks.scala | 3 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Typer.scala | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 46bdbf3b3..feeb80547 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -689,7 +689,7 @@ object RefChecks { } /** Verify classes extending AnyVal meet the requirements */ - private def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context) = { + def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context) = { def checkValueClassMember(stat: Tree) = stat match { case _: ValDef if !stat.symbol.is(ParamAccessor) => ctx.error(s"value class may not define non-parameter field", stat.pos) @@ -836,7 +836,6 @@ class RefChecks extends MiniPhase { thisTransformer => checkParents(cls) checkCompanionNameClashes(cls) checkAllOverrides(cls) - checkDerivedValueClass(cls, tree.body) tree } catch { case ex: MergeError => diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 9f5a942d6..34300a5e3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1269,6 +1269,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit ctx.featureWarning(nme.dynamics.toString, "extension of type scala.Dynamic", isScala2Feature = true, cls, isRequired, cdef.pos) } + + + // check value class constraints + RefChecks.checkDerivedValueClass(cls, body1) + cdef1 // todo later: check that |