Skip to content

Fix #6055: Use correct condition for non-alias opaque types #6106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions tests/neg/i6055.scala
Original file line number Diff line number Diff line change
@@ -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