From 5ce3b0848d82dc6fa264b946dde6f0b53e8b02a7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Mar 2019 11:07:02 +0100 Subject: [PATCH] Fix #6055: Use correct condition for non-alias opaque types --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- tests/neg/i6055.scala | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i6055.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 807a532f02d2..787e2ff5c198 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -774,7 +774,7 @@ object desugar { * companion object, and the synthetic opaque type member will go into the self type. */ def opaqueAlias(tdef: TypeDef)(implicit ctx: Context): Tree = - if (tdef.rhs.isInstanceOf[TypeBoundsTree]) { + if (lacksDefinition(tdef)) { ctx.error(em"opaque type ${tdef.name} must be an alias type", tdef.sourcePos) tdef.withFlags(tdef.mods.flags &~ Opaque) } diff --git a/tests/neg/i6055.scala b/tests/neg/i6055.scala new file mode 100644 index 000000000000..4c7905e581f6 --- /dev/null +++ b/tests/neg/i6055.scala @@ -0,0 +1,5 @@ +opaque type i0 // error: opaque type must be an alias type +opaque type i2 <: Int // error: opaque type must be an alias type + +opaque type i1[_] // error: opaque type must be an alias type +opaque type x[_] <: Int // error: opaque type must be an alias type