`Import from illegal package` error

721 views Asked by At

Anyone knows why I get the error Table.scala:8:0: Import from illegal package from the following code?

Line 8 is referring to import scala.collection.JavaConversions._

import org.allenai.common.Logging
import scala.collection.parallel.mutable

import java.io.FileReader
import au.com.bytecode.opencsv.CSVReader
import scala.collection.JavaConversions._

/** Created by i-danielk on 6/11/15.
  */
class Table(fileName: String) extends Logging {
  val (titleRow, contentMatrix) = readCSV(fileName)

  // reading from csv: for future
  def readCSV(file: String): (Array[String], Array[Array[String]]) = {
    val reader = new CSVReader(new FileReader(file))

    val fullContents = for {
      row <- reader.readAll
    } yield {
      row
    }
    (fullContents.head, fullContents.tail.toArray)
  }
}
1

There are 1 answers

1
Travis Brown On BEST ANSWER

For the sake of completeness: the Scala compiler will never (as far as I know) complain about an import from "an illegal package", so this must be a rule that someone has configured in a linter that the project is using (most likely Scalastyle).

Many people prefer the more explicit JavaConverters (with its asScala and asJava enrichment methods) to the magical implicit conversions of JavaConversions, so the solution is probably just to switch to that package.