Skip to content

Commit f94deac

Browse files
authored
Merge pull request #6106 from dotty-staging/fix-#6055
Fix #6055: Use correct condition for non-alias opaque types
2 parents 036128c + 5ce3b08 commit f94deac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ object desugar {
774774
* companion object, and the synthetic opaque type member will go into the self type.
775775
*/
776776
def opaqueAlias(tdef: TypeDef)(implicit ctx: Context): Tree =
777-
if (tdef.rhs.isInstanceOf[TypeBoundsTree]) {
777+
if (lacksDefinition(tdef)) {
778778
ctx.error(em"opaque type ${tdef.name} must be an alias type", tdef.sourcePos)
779779
tdef.withFlags(tdef.mods.flags &~ Opaque)
780780
}

tests/neg/i6055.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
opaque type i0 // error: opaque type must be an alias type
2+
opaque type i2 <: Int // error: opaque type must be an alias type
3+
4+
opaque type i1[_] // error: opaque type must be an alias type
5+
opaque type x[_] <: Int // error: opaque type must be an alias type

0 commit comments

Comments
 (0)