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

Compiler exception on new anonymous class creation (with apply call) #5696

Closed
scabug opened this Issue Apr 23, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Apr 23, 2012

class TestApply {
  class G(y: Int) {
    def apply(x: Int) = 1
  }

  new G(1)(2) {}
}

java.lang.AssertionError: assertion failed: type can't convert from UNIT to REF(class TestApply$G) in unit Main.scala at source-C:\Users\Alexander.Podkhalyuz\IdeaProjects\LiftMavenTest\src\scalatest\Main.scala,line-8,offset=109
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.adapt(GenICode.scala:1149)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1131)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1175)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:921)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:174)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:143)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
at scala.collection.immutable.List.foldLeft(List.scala:45)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genStat(GenICode.scala:143)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1052)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:114)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:136)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:88)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:79)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:65)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:61)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
at scala.collection.Iterator$class.foreach(Iterator.scala:660)
at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:316)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:54)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
at scala.tools.nsc.Global$Run.compile(Global.scala:1038)
at scala.tools.nsc.Main$.process(Main.scala:106)
at scala.tools.nsc.Main$.main(Main.scala:123)
at scala.tools.nsc.Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jetbrains.plugins.scala.compiler.rt.ClassRunner.main(ClassRunner.java:46)
Exception in thread "main" java.lang.reflect.InvocationTargetException

@scabug

This comment has been minimized.

Copy link

scabug commented Apr 23, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5696?orig=1
Reporter: @Alefas
Affected Versions: 2.9.1
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link

scabug commented May 3, 2012

@hubertp said:
Still fails in trunk.

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 10, 2012

@scabug scabug closed this Jun 11, 2012

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 11, 2012

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 11, 2012

@dcsobral said:
Is new G(1)(2) still legal? I'm pretty sure I have code like that.

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 11, 2012

@retronym said:
Yep.

scala> class G(y: Int) {
     |     def apply(x: Int) = 1
     |   }
defined class G

scala> new G(0)(0)
res0: Int = 1

scala> new G(0)(0) {}
<console>:9: error: too many argument lists for constructor invocation
              new G(0)(0) {}
                  ^

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

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