diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-12 11:28:35 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:09:43 +0100 |
commit | 61cb51acaedbe603add8c4af9e390a27f8b33f09 (patch) | |
tree | 2e6f7d2410b96b208b3f6be5c5465a320751d7f0 /src | |
parent | 3f5d15defa7481da1b9d1f20e91569a340c71e8e (diff) | |
download | dotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.tar.gz dotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.tar.bz2 dotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.zip |
Disallow refinements of types or methods that do not appear in parent.
We planned this for a long time but never implemented it. Instead, we sometimes
issued an erro in Splitter, namely if reflection would have been needed to access the
member. It turns out that some tests (e.g. neg/t625) fail -Ycheck (we knew that before
and disabled) but also fail Pickling because they generate orhpan PolyParams. So rather
than patching this up it seems now is a good time to enforce the restriction for real.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 5dc0452d1..331657e12 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -801,6 +801,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit typr.println(s"adding refinement $refinement") checkRefinementNonCyclic(refinement, refineCls, seen) val rsym = refinement.symbol + if ((rsym.is(Method) || rsym.isType) && rsym.allOverriddenSymbols.isEmpty) { + println(refineCls.baseClasses) + ctx.error(i"refinement $rsym without matching type in parent $parent", refinement.pos) + } val rinfo = if (rsym is Accessor) rsym.info.resultType else rsym.info RefinedType(parent, rsym.name, rt => rinfo.substThis(refineCls, SkolemType(rt))) // todo later: check that refinement is within bounds |