aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
-rw-r--r--test/dotc/tests.scala1
3 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 473800cde..027c3238d 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -715,10 +715,12 @@ object desugar {
* ==>
* trait <refinement> extends parent { refinements }
*
+ * If the parent is missing, Object is assumed.
* 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 = if (tree.tpt.isEmpty) TypeTree(defn.ObjectType) else tree.tpt
+ val impl = Template(emptyConstructor, parent :: Nil, EmptyValDef, tree.refinements)
TypeDef(Modifiers(Trait), tpnme.REFINE_CLASS, impl)
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index ebb648ea5..400a1407a 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -798,7 +798,7 @@ class Typer extends Namer with Applications with Implicits {
}
def typedRefinedTypeTree(tree: untpd.RefinedTypeTree)(implicit ctx: Context): RefinedTypeTree = track("typedRefinedTypeTree") {
- val tpt1 = typedAheadType(tree.tpt)
+ val tpt1 = if (tree.tpt.isEmpty) TypeTree(defn.ObjectType) else typedAheadType(tree.tpt)
val refineClsDef = desugar.refinedTypeToClass(tree)
val refineCls = createSymbol(refineClsDef).asClass
val TypeDef(_, _, Template(_, _, _, refinements1)) = typed(refineClsDef)
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 03bc89ea9..9132ce9c4 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -39,6 +39,7 @@ class tests extends CompilerTest {
@Test def pos_packageobject() = compileFile(posDir, "packageobject")
@Test def pos_overloaded() = compileFile(posDir, "overloaded")
@Test def pos_templateParents() = compileFile(posDir, "templateParents")
+ @Test def pos_structural() = compileFile(posDir, "structural")
@Test def neg_blockescapes() = compileFile(negDir, "blockescapesNeg", xerrors = 1)
@Test def neg_typedapply() = compileFile(negDir, "typedapply", xerrors = 4)