From 850dc6f2fb3b6228f2586ce0790621e80f664afe Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 29 Jun 2016 19:04:03 +0200 Subject: Introduce recursive types Map self-references in refinements to recursive types. This commit does this for refinement types appearing in source. We still have to do it for unpickled refinements. Test apply-equiv got moved to pending because it simulates the old higher-kinded type encoding in source, which relies on the old representation in terms of self-referential refinement types. The plan is not to adapt this encoding to the new representation, but to replace it with a different encoding that makes critical use of the added power of recursive types. Use recursive types also when unpickling from Scala 2.x. Add mapInfo method to Denotations. --- src/dotty/tools/dotc/typer/Typer.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index d5a32dbc0..fb3418563 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -917,11 +917,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit if ((rsym.is(Method) || rsym.isType) && rsym.allOverriddenSymbols.isEmpty) 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, RefinedThis(rt))) + RefinedType(parent, rsym.name, rinfo) // todo later: check that refinement is within bounds } - val res = cpy.RefinedTypeTree(tree)(tpt1, refinements1) withType - (tpt1.tpe /: refinements1)(addRefinement) + val refined = (tpt1.tpe /: refinements1)(addRefinement) + val res = cpy.RefinedTypeTree(tree)(tpt1, refinements1).withType( + RecType.closeOver(rt => refined.substThis(refineCls, RecThis(rt)))) typr.println(i"typed refinement: ${res.tpe}") res } -- cgit v1.2.3