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

Assertion failed "class defined twice" with testCompilation #20296

Open
aherlihy opened this issue Apr 30, 2024 · 3 comments
Open

Assertion failed "class defined twice" with testCompilation #20296

aherlihy opened this issue Apr 30, 2024 · 3 comments

Comments

@aherlihy
Copy link
Contributor

aherlihy commented Apr 30, 2024

Compiler version

3.4.2-RC1

Minimized code

$sbt testCompilation tests/pos/shared-classname.scala. Does not fail with scalac tests/pos/shared-classname.scala.

(shortened version of not-looping-implicit.scala with the anonymous classes given the same name).

import scala.deriving.Mirror
import scala.compiletime._
trait Schema[T]
object Schema {
  inline given derived[A]: Schema[A] =
    inline summonInline[Mirror.Of[A]] match {
      case m: Mirror.SumOf[A] =>
        summonInline[Schema[m.MirroredElemTypes]]
        class InlinedSchema extends Schema[A] {}
        new InlinedSchema
      case m: Mirror.ProductOf[A] =>
        class InlinedSchema extends Schema[A] {}
        new InlinedSchema
    }
}
sealed trait InputValue
object InputValue {
  case class T() extends InputValue
}
@main def Test:Schema[InputValue] =
  Schema.derived

Output (click arrow to expand)

completed (0/1, 0 failed, 0s)java.lang.AssertionError: assertion failed: class defined twice class Schema$_$InlinedSchema 7130 6099
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.transform.TreeChecker.testDuplicate(TreeChecker.scala:55)
        ...
@aherlihy aherlihy added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 30, 2024
@nicolasstucki
Copy link
Contributor

Fails Ycheck after genSJSIR

checking t/Test.scala after phase MegaPhase{dropOuterAccessors, checkNoSuperThis, flatten, transformWildcards, moveStatic, expandPrivate, restoreScopes, selectStatic, Collect entry points, collectSuperCalls, repeatableAnnotations}
checking t/Test.scala after phase genSJSIR
java.lang.AssertionError: assertion failed: class defined twice class Schema$_$InlinedSchema 6090 7121
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.transform.TreeChecker.testDuplicate(TreeChecker.scala:55)
        at dotty.tools.dotc.transform.TreeChecker.transformSym(TreeChecker.scala:78)
        at dotty.tools.dotc.core.DenotTransformers$SymTransformer.transform(DenotTransformers.scala:72)

@nicolasstucki
Copy link
Contributor

Minimization

trait Foo

object Foo {
  inline def bar(): Foo =
    class InlinedFoo extends Foo {}
    new InlinedFoo

  inline def foo(): Foo =
    bar()
    class InlinedFoo extends Foo {}
    new InlinedFoo

  def Test: Foo = Foo.foo()
}

@nicolasstucki
Copy link
Contributor

@sjrd could you check if this is an issue with genSJSIR or before that pahse?

@Gedochao Gedochao added area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants