Aladdin - Scala Bugtracking
[#562] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin won't fix 2006-03-31 14:50:00.0
subject mixin override val crash
code
package test;

abstract class XXX;

trait YYY extends XXX {
  val y = 10;
}

class Foo extends XXX with YYY {
  override val y = super.y;
}
what happened
scala.tools.nsc.symtab.Types$TypeError: wrong number of arguments for value y: ()scala.Int
	at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:178)
	at scala.tools.nsc.typechecker.Typers$Typer.reportTypeError(Typers.scala:139)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1595)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1613)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.staticCall$0(Mixin.scala:348)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.scala$tools$nsc$transform$Mixin$MixinTransformer$$postTrans\
form(Mixin.scala:369)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$31.apply(Mixin.scala:407)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$31.apply(Mixin.scala:407)
	at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:38)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:407)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:980)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1036)
	at scala.List$.loop$0(List.scala:232)
	at scala.List$.mapConserve(List.scala:249)
	at scala.List$.loop$0(List.scala:236)
	at scala.List$.mapConserve(List.scala:249)
	at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1036)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:964)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:943)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:942)
	at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1044)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:941)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1036)
	at scala.List$.loop$0(List.scala:232)
	at scala.List$.mapConserve(List.scala:249)
	at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1036)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:962)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer.transformTemplate(Trees.scala:1024)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:930)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:930)
	at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1044)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:929)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1036)
	at scala.List$.loop$0(List.scala:232)
	at scala.List$.mapConserve(List.scala:249)
	at scala.List$.loop$0(List.scala:236)
	at scala.List$.mapConserve(List.scala:249)
	at scala.List$.loop$0(List.scala:236)
	at scala.List$.mapConserve(List.scala:249)
	at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1036)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:926)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:926)
	at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1044)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:925)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1039)
	at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:22)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:213)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
	at scala.Iterator$class.foreach(Iterator.scala:285)
	at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:202)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:432)
	at scala.tools.nsc.Global$Run.compile(Global.scala:490)
	at ch.epfl.lamp.sdt.build.ScalaCompilerManager$ScalaCompiler.compile(ScalaCompilerManager.java:186)
	at ch.epfl.lamp.sdt.build.ScalaProjectBuilder.build(ScalaProjectBuilder.java:76)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:593)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:168)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:202)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:231)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:234)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:253)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:282)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:204)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
what expected
[back to overview]
Changes of this bug report
Martin  edited on  2006-04-05 15:51:11.0
This is a nasty one. Our modular scheme for mixin composition does not allow to override a value definition in a mixin by another one in the inheriting class (you would get a name clash). The only thing I could do is to outlaw this case. Now you get this behavior: bug562.scala:10 error: error overriding value y in trait YYY of type => scala.Int; value y cannot override a value or variable definition in a trait (this is an implementation restriction) override val y = super.y; ^ one error found