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

wrong number of arguments at getClass for (): PackratParsers #8847

Closed
chungonn opened this issue May 1, 2020 · 2 comments · Fixed by #10064
Closed

wrong number of arguments at getClass for (): PackratParsers #8847

chungonn opened this issue May 1, 2020 · 2 comments · Fixed by #10064

Comments

@chungonn
Copy link

chungonn commented May 1, 2020

The code fragment compiles on scala 2.13.1 but not on dotty 0.24.0-RC1,

Minimized code

package test

import scala.util.parsing.combinator.{ImplicitConversions, PackratParsers, RegexParsers}

class TestParser  extends RegexParsers with ImplicitConversions with PackratParsers {

}

Output

[info] Compiling 2 Scala sources to /home/chungonn/development/scala3/bugs/packratparsers/target/scala-0.24/classes ...
[error] -- Error: /home/chungonn/development/scala3/bugs/packratparsers/src/main/scala/test/TestParser.scala:5:83 
[error] 5 |class TestParser  extends RegexParsers with ImplicitConversions with PackratParsers {
[error]   |                                                                                   ^
[error]   |wrong number of arguments at getClass for (): PackratParsers.this.MemoEntry$: (PackratParsers.this.MemoEntry$#<init> : (): PackratParsers.this.MemoEntry$), expected: 0, found: 1
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed 1 May, 2020 9:37:08 AM

Expectation

@griggt
Copy link
Contributor

griggt commented Oct 21, 2020

Standalone reproducer below.

Note that this is a Scala 2 interop issue, and only occurs when the trait is compiled by Scala 2 and extended in a file compiled by Scala 3.

lib/lib.scala

package i8847

trait P {
  // The `private` modifier is needed, and `X` must be a case class or case object
  private case class X(x: Int)
  // private case object X
}

main/test.scala

import i8847.P

class T extends P

build.sbt

lazy val lib = (project in file ("lib"))
  .settings(scalaVersion := "2.13.3")

lazy val main = (project in file ("main"))
  .dependsOn(lib)
  .settings(
    scalaVersion := "0.24.0-RC1",
    projectDependencies := {
      projectDependencies.value.map(_.withDottyCompat(scalaVersion.value))
    }
  )

Output from Dotty 0.24.0-RC1

[info] Compiling 1 Scala source to /src/dotty-issues/i8847/lib/target/scala-2.13/classes ...
[info] Done compiling.
[info] Compiling 1 Scala source to /src/dotty-issues/i8847/main/target/scala-0.24/classes ...
[error] -- Error: /src/dotty-issues/i8847/main/test.scala:3:17 -----------------------------------
[error] 3 |class T extends P
[error]   |                 ^
[error]   |wrong number of arguments at getClass for (): P.this.X$: (P.this.X$#<init> : (): P.this.X$), expected: 0, found: 1
[error] one error found
[error] (main / Compile / compileIncremental) Compilation failed

This is fixed by #8652.

@griggt
Copy link
Contributor

griggt commented Oct 21, 2020

While creating a standalone reproducer from the original and bisecting this issue, I ran into another:

lib.scala

package i8847

trait Foo {
  def foo(): Unit = ???
}

trait Bar extends Foo {
  override def foo(): Unit = super.foo()
}

trait Baz extends Foo {
  override def foo(): Unit = super.foo()
}

test.scala

import i8847.{ Bar, Baz }

class C extends Bar with Baz
$ scalac -version
Scala compiler version 2.13.3 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.

$ scalac lib.scala

$ dotc -version
Dotty compiler version 0.26.0-bin-SNAPSHOT-git-d7bea54 -- Copyright 2002-2020, LAMP/EPFL

$ dotc test.scala
-- [E120] Naming Error: test.scala:3:6 -----------------------------------------
3 |class C extends Bar with Baz
  |      ^
  |      Double definition:
  |      private def super$foo(): Unit in class C and
  |      private def super$foo(): Unit in class C
  |      have the same type after erasure.
1 error found

This issue appears to have been both introduced and corrected during the commit sequence of #8652.

griggt added a commit to griggt/dotty that referenced this issue Oct 21, 2020
bishabosha added a commit that referenced this issue Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants