Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Apr 30, 2025

Fixes #22734

@som-snytt som-snytt force-pushed the issue/22734-enum-missing-member branch from 6394792 to 9b3d4a1 Compare April 30, 2025 21:03
@som-snytt
Copy link
Contributor Author

Not a cycle but maybe opaque means abstract. Anyway it should only check abstract term.

The other caution is that it's easier to let refchecks do the work. What enum syntax is legal? Every tweak to the test is an indentation problem. So it's easier to have confidence in the refcheck in the first commit, because the def $new signals that the anon class must be concrete.

-- Error: tests/run/option-extract.scala:2:5 ---------------------------------------------------------------------------
 2 |enum Option[+A]:
   |^
   |enum class Option has an abstract member and an unparameterized case
 3 |  case Some(x: A)
 4 |  case None
 5 |  opaque type ExtractResult[B] = (=> B) => B
 6 |  def extract[B](f: A => B): ExtractResult[B] =
 7 |    def result(default: => B): B = (this: Option[A]) match
 8 |      case None => default
 9 |      case Some(elem) => f(elem)
10 |    result
11 |  extension [B](er: ExtractResult[B])
12 |    def orElse(default: => B): B = er(default)
13 |end Option

s"""|
|No errors expected/defined in $testSource -- use // error or // nopos-error"
|$showErrors
|""".stripMargin.trim.linesIterator.mkString("\n", "\n", "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most important part of this PR.

@som-snytt som-snytt marked this pull request as ready for review April 30, 2025 23:36
@Gedochao Gedochao requested a review from hamzaremmal May 5, 2025 06:11
@som-snytt som-snytt force-pushed the issue/22734-enum-missing-member branch from 9b3d4a1 to 3784d34 Compare November 25, 2025 16:48
@som-snytt
Copy link
Contributor Author

Rebased.

@som-snytt som-snytt force-pushed the issue/22734-enum-missing-member branch from 3784d34 to cf448f7 Compare November 25, 2025 19:23
@som-snytt
Copy link
Contributor Author

Passes locally.

Test 'tests/run/i23245a' failed with output:                                    

Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread "main"

@som-snytt som-snytt force-pushed the issue/22734-enum-missing-member branch from cf448f7 to da48b63 Compare December 12, 2025 13:03
@som-snytt som-snytt marked this pull request as draft December 12, 2025 13:11
@som-snytt
Copy link
Contributor Author

Dropped the check in Checking, where the idea was to error the enum if a case will error as abstract; the test was not correct and not worth the extra code. The message should be improved in refchecks instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect position on "object creation impossible" error in enums

2 participants