Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Message "error: type _$1 is defined twice" when compiled the second time #5240
I have a project in java (JaCoP http://sourceforge.net/projects/jacop-solver/) that I add scala wrapper for creating DSL. The scala code contains a number of classes and a package object. Compilation of this scala code works correct the first time but the second time, when doing changes in the code, it reports the following two errors:
error: type _$1 is defined twice
It does not give any suggestion on possible error :( Cleaning the project and generating once more the code works correct again.
I can send the whole code on request but it is rather big. I send for you scala files that work with current version of JaCoP. Everything is on sourceforge.
Imported From: https://issues.scala-lang.org/browse/SI-5240?orig=1
I have find a way around the bug but it might also be useful for finding it.
The statement that causes the bug is as follows (it is present in package object).
var labels: Array[_ <: org.jacop.core.Var] = null
The error is also reported when I use a full version of the existential type (wildcard above).
Defining the type separately as written below does not give an error (this is my way around9.
type DFS = DepthFirstSearch[_ <: org.jacop.core.Var]
The bug happens only if the first statement is defined in package object and after the first compilation (when class files already exist). It is not reported for the first compilation when there is no class files yet.
Hope it can help.