Skip to content

Synth method generation failed on invalid value class #1670

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

Closed
dos65 opened this issue Nov 6, 2016 · 3 comments
Closed

Synth method generation failed on invalid value class #1670

dos65 opened this issue Nov 6, 2016 · 3 comments

Comments

@dos65
Copy link
Contributor

dos65 commented Nov 6, 2016

Compiler crashes on synthetic methods generation on value class with more that one parameter

class A(a:Int, b:Int) extends AnyVal 
error while transforming (a: Int, b: Int) extends AnyVal() { 
  private[this] val a: Int
  private[this] val b: Int
}
error while transforming @scala.annotation.internal.SourceFile("/home/dos65/projects/tmp/dotty_samples/3.scala") final class A(a: Int, b: Int)
   extends
 AnyVal() { 
  private[this] val a: Int
  private[this] val b: Int
}
error while transforming package <empty> {
  @scala.annotation.internal.SourceFile("/home/dos65/projects/tmp/dotty_samples/3.scala") final class A(a: Int, b: Int)
     extends
   AnyVal() { 
    private[this] val a: Int
    private[this] val b: Int
  }
  final lazy module val A: A$ = new A$()
  final module class A$() extends Object() { this: A.type =>}
}

exception occurred while compiling /home/dos65/projects/tmp/dotty_samples/3.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:151)
	at dotty.tools.dotc.transform.SyntheticMethods.dotty$tools$dotc$transform$SyntheticMethods$$valueHashCodeBody$1(SyntheticMethods.scala:141)
	at dotty.tools.dotc.transform.SyntheticMethods$$anonfun$syntheticRHS$1$1.apply(SyntheticMethods.scala:87)
	at dotty.tools.dotc.transform.SyntheticMethods$$anonfun$syntheticRHS$1$1.apply(SyntheticMethods.scala:87)
	at dotty.tools.dotc.ast.tpd$.polyDefDef(tpd.scala:200)
	at dotty.tools.dotc.ast.tpd$.DefDef(tpd.scala:170)
	at dotty.tools.dotc.transform.SyntheticMethods.syntheticDef$1(SyntheticMethods.scala:96)
	at dotty.tools.dotc.transform.SyntheticMethods.dotty$tools$dotc$transform$SyntheticMethods$$syntheticDefIfMissing$1(SyntheticMethods.scala:70)
	at dotty.tools.dotc.transform.SyntheticMethods$$anonfun$syntheticMethods$1.apply(SyntheticMethods.scala:190)
	at dotty.tools.dotc.transform.SyntheticMethods$$anonfun$syntheticMethods$1.apply(SyntheticMethods.scala:190)
	at scala.collection.immutable.List.flatMap(List.scala:327)
	at dotty.tools.dotc.transform.SyntheticMethods.syntheticMethods(SyntheticMethods.scala:190)
	at dotty.tools.dotc.transform.SyntheticMethods.addSyntheticMethods(SyntheticMethods.scala:195)
	at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:215)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1149)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
	at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:242)

Currently value class checking is in RefChecks, should it be moved on Typer?
@smarter

@felixmulder
Copy link
Contributor

ping: @DarkDimius, @odersky

@odersky
Copy link
Contributor

odersky commented Nov 6, 2016

I think it makes sense to do this in typer.

@DarkDimius
Copy link
Contributor

Instead of putting more stuff into typer, I'd propose to move such checks into InfoTransformer of RefChecks.

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

5 participants