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

retypechecking during specialization breaks with a local case object #8122

Open
scabug opened this issue Jan 7, 2014 · 5 comments
Open

retypechecking during specialization breaks with a local case object #8122

scabug opened this issue Jan 7, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Jan 7, 2014

object test {
  class R[@specialized(Double) C]

  def g[@specialized(Double) C](x: R[C]): Unit = {
    case object S
  }
}
sandbox/test.scala:5: error: S is already defined as (compiler-generated) case class companion object S
    case object S
                ^

Here's what gets into retyped

<specialized> def g$mDc$sp(x: test.R[Double]): Unit = {
  case object S extends Object with Product with Serializable {
    def <init>(): S.type = {
      S.super.<init>();
      ()
    };
    override <synthetic> def productPrefix(): String = "S";
    <synthetic> def productArity(): Int = 0;
    <synthetic> def productElement(x$1: Int): Any = {
      case <synthetic> val x1: Int = x$1;
      case4(){
        matchEnd3(throw new IndexOutOfBoundsException(x$1.toString()))
      };
      matchEnd3(x: Any){
        x
      }
    };
    override <synthetic> def productIterator(): Iterator[Any] = runtime.this.ScalaRunTime.typedProductIterator[Any](S.this);
    <synthetic> def canEqual(x$1: Any): Boolean = x$1.$isInstanceOf[S.type]();
    override <synthetic> def hashCode(): Int = 83;
    override <synthetic> def toString(): String = "S";
    <synthetic> private def readResolve(): Object = S()
  };
  var S$module: S.type = _;
  case <stable> def S(): S.type = {
    S$module = new S.type();
    S$module
  };
  ()
}
@scabug
Copy link
Author

scabug commented Jan 7, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8122?orig=1
Reporter: @retronym
Affected Versions: 2.10.3
Blocks #5464

@scabug
Copy link
Author

scabug commented Jan 7, 2014

@xeno-by said:
Looks related to #5467

@scabug
Copy link
Author

scabug commented Jan 7, 2014

@retronym said:
This case seems harder, as the retypechecking happens after expansion of modules to an accessor method and a module.

See also: #7928 / scala/scala@8076738

@scabug
Copy link
Author

scabug commented Mar 2, 2015

@VladUreche said:
Reduced more:

$ cat spec.scala 
class C[@specialized T] {
  def get(t: T): T = {
    case object Hi
    t
  }
}

$ scalac spec.scala
spec.scala:3: error: Hi is already defined as (compiler-generated) case class companion object Hi
    case object Hi
                ^
one error found

And it affects miniboxing as well: miniboxing/miniboxing-plugin#184

@scabug
Copy link
Author

scabug commented Mar 2, 2015

@VladUreche said:
Fixed in miniboxing, but I'm sure the fix in the compiler can be significantly cleaner, since you have full control over the namer:
miniboxing/miniboxing-plugin@5aaa707

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

3 participants