Scala Programming Language
  1. Scala Programming Language
  2. SI-5240

Message "error: type _$1 is defined twice" when compiled the second time

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: Scala 2.9.0, Scala 2.9.1
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Environment:

      I use Mac OS X and sbt with java 6 and scala 2.9.0-final. I have a project that use both java and scala.

      Description

      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
      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.

      /Kris

        Activity

        Hide
        Paul Phillips added a comment -

        We don't have the resources to do this much of the work. Please reopen if you obtain a small self-contained reproduction.

        Show
        Paul Phillips added a comment - We don't have the resources to do this much of the work. Please reopen if you obtain a small self-contained reproduction.
        Hide
        krzku added a comment -

        Hi!

        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]
        var labels: Array[DFS] = null

        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.

        /Kris

        Show
        krzku added a comment - Hi! 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] var labels: Array [DFS] = null 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. /Kris
        Hide
        Aleksandar Prokopec added a comment -

        Added pending test in pending/pos.

        Show
        Aleksandar Prokopec added a comment - Added pending test in pending/pos.
        Hide
        Daniel Sobral added a comment -

        This compiles for me, with Scala compiler version 2.10.0-20120430-094203-cfd037271e – Copyright 2002-2011, LAMP/EPFL.

        Show
        Daniel Sobral added a comment - This compiles for me, with Scala compiler version 2.10.0-20120430-094203-cfd037271e – Copyright 2002-2011, LAMP/EPFL.
        Hide
        Paul Phillips added a comment -

        The bug is still there, I reproduced it yesterday.

        Show
        Paul Phillips added a comment - The bug is still there, I reproduced it yesterday.
        Hide
        Paul Phillips added a comment -

        Duplicate of SI-5504.

        Show
        Paul Phillips added a comment - Duplicate of SI-5504 .

          People

          • Assignee:
            Paul Phillips
            Reporter:
            krzku
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development