Skip to content
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

Add compilation unit info to ClassSymbol #19010

Merged
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,9 @@ object Parsers {
}

private def checkAccessOnly(mods: Modifiers, where: String): Modifiers =
val mods1 = mods & (AccessFlags | Enum)
// We allow `infix to mark the `enum`s type as infix.
// Syntax rules disallow the soft infix modifier on `case`s.
val mods1 = mods & (AccessFlags | Enum | Infix)
if mods1 ne mods then
syntaxError(em"Only access modifiers are allowed on enum $where")
mods1
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i18933.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Error: tests/neg/i18933.scala:3:8 -----------------------------------------------------------------------------------
3 | infix case B(b: B) // error // error
| ^^^^
| end of statement expected but 'case' found
-- [E006] Not Found Error: tests/neg/i18933.scala:3:2 ------------------------------------------------------------------
3 | infix case B(b: B) // error // error
| ^^^^^
| Not found: infix
|
| longer explanation available when compiling with `-explain`
3 changes: 3 additions & 0 deletions tests/neg/i18933.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum Extends[A, B]:
case A(a: A)
infix case B(b: B) // error // error
4 changes: 4 additions & 0 deletions tests/pos/i18933.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//> using options -Werror

infix enum Extends[A, B]:
bishabosha marked this conversation as resolved.
Show resolved Hide resolved
case Ev[B, A <: B]() extends (A Extends B)