diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-16 11:32:03 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-16 11:32:03 +0100 |
commit | f3d428e6957501578c9516de2d179adf713ca95f (patch) | |
tree | 2807ac65c3ecf3c22e39df810e12f7ce0d691465 | |
parent | 4079d6d5048dbebf5aaac06be42e9b9484b3934f (diff) | |
download | dotty-f3d428e6957501578c9516de2d179adf713ca95f.tar.gz dotty-f3d428e6957501578c9516de2d179adf713ca95f.tar.bz2 dotty-f3d428e6957501578c9516de2d179adf713ca95f.zip |
Fix to desugaring refinement types.
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 | ||||
-rw-r--r-- | tests/pos/typers.scala | 33 |
3 files changed, 35 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 7692d5a95..267e1a607 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -696,7 +696,8 @@ object desugar { * The result is used for validity checking, is thrown away afterwards. */ def refinedTypeToClass(tree: RefinedTypeTree)(implicit ctx: Context): TypeDef = { - val impl = Template(emptyConstructor, tree.tpt :: Nil, EmptyValDef, tree.refinements) + val parent = Select(New(tree.tpt), nme.CONSTRUCTOR) + val impl = Template(emptyConstructor, parent :: Nil, EmptyValDef, tree.refinements) TypeDef(Modifiers(), tpnme.REFINE_CLASS, impl) } diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 2645cf450..4e9d5953a 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -708,7 +708,7 @@ class Typer extends Namer with Applications with Implicits { } val res = cpy.RefinedTypeTree(tree, tpt1, refinements1) withType (tpt1.tpe /: refinements1)(addRefinement) - println(s"typed refinement: ${res.tpe}") + // println(s"typed refinement: ${res.tpe.show}") res } diff --git a/tests/pos/typers.scala b/tests/pos/typers.scala index 3fcd1ff29..51692e026 100644 --- a/tests/pos/typers.scala +++ b/tests/pos/typers.scala @@ -1,5 +1,5 @@ object typers { - + class List[+T] { def :: (x: T) = new :: (x, this) @@ -17,5 +17,36 @@ object typers { case x :: xs1 => 1 + len(xs1) case Nil => 0 } + + object returns { + + def foo(x: Int): Int = { + return 3 + } + } + + object tries { + + val x = try { + "abc" + } catch { + case ex: java.io.IOException => + 123 + } finally { + println("done") + } + + val y = try 2 catch Predef.identity + + val z = try 3 finally "abc" + + } + + class C { + + } + class Refinements { + val y: C { type T; val key: T; def process(x: T): Int } + } }
\ No newline at end of file |