From 678e8e47b630786df7548c1be5bee744342f826c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 28 Jan 2017 17:11:56 +1100 Subject: Disallow polymorphic refinements in stuctural types. We can't handle them with the proposed scheme. I made a note in #1886. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala') diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index ec4c135f7..48636c27c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1039,7 +1039,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit for (refinement <- refinements1) { // TODO: get clarity whether we want to enforce these conditions typr.println(s"adding refinement $refinement") checkRefinementNonCyclic(refinement, refineCls, seen) - } + val rsym = refinement.symbol + if (rsym.info.isInstanceOf[PolyType] && rsym.allOverriddenSymbols.isEmpty) + ctx.error(i"polymorphic refinement $rsym without matching type in parent $tpt1 is no longer allowed", refinement.pos) } assignType(cpy.RefinedTypeTree(tree)(tpt1, refinements1), tpt1, refinements1, refineCls) } -- cgit v1.2.3