aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-26 11:46:46 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-26 11:46:52 +0100
commitfc319b002ff4bc82061250352f1568c612c70d72 (patch)
treef2f8a76eb5e8dd8926a35271118cf0e3b91182f5 /src/dotty/tools/dotc/typer/Typer.scala
parent5733684a4ec6857ece1048d56654dcd749163510 (diff)
downloaddotty-fc319b002ff4bc82061250352f1568c612c70d72.tar.gz
dotty-fc319b002ff4bc82061250352f1568c612c70d72.tar.bz2
dotty-fc319b002ff4bc82061250352f1568c612c70d72.zip
Allow refinements that refine already refined types.
Previously, a double definition errorfor `T` was produced in a case like this: type T1 = C { T <: A } type T2 = T1 { T <: B } This was caused by the way T1 was treated in the refinement class that is used to typecheck the type. Desugaring of T2 with `refinedTypeToClass` would give trait <refinement> extends T1 { type T <: B } and `normalizeToClassRefs` would transform this to: trait <refinement> extends C { type T <: A; type T <: B } Hence the double definition. The new scheme desugars the rhs of `T2` to: trait <refinement> extends C { this: T1 => type T <: B } which avoids the problem. Also, added tests that #232 (fix/boundsPropagation) indeed considers all refinements together when comparing refined types.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 9ef73f0b6..7d4e8d132 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -756,7 +756,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedRefinedTypeTree(tree: untpd.RefinedTypeTree)(implicit ctx: Context): RefinedTypeTree = track("typedRefinedTypeTree") {
val tpt1 = if (tree.tpt.isEmpty) TypeTree(defn.ObjectType) else typedAheadType(tree.tpt)
- val refineClsDef = desugar.refinedTypeToClass(tree)
+ val refineClsDef = desugar.refinedTypeToClass(tpt1, tree.refinements)
val refineCls = createSymbol(refineClsDef).asClass
val TypeDef(_, Template(_, _, _, refinements1)) = typed(refineClsDef)
assert(tree.refinements.length == refinements1.length, s"${tree.refinements} != $refinements1")