aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
-rw-r--r--tests/pos/typers.scala33
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