0

I have the following:

case class Location(name: String, level: Location.Level)

object Location {
  trait Level
  case object City extends Level
  case object State extends Level
}

If I try and access City (from another source file), I get an error saying something like

found   : model.Location.City.type
required: model.Level

I can think of some work-arounds, but I'm wondering if there's a way to keep my names the same i.e. I'd like to access City by typing Location.City.

EDIT:

I'm accessing it like this:

import the.package.name._
Location.City
three-cups
  • 4,375
  • 3
  • 31
  • 41
  • 1
    How and where are you accessing it? – Michael Zajac Oct 21 '14 at 19:48
  • @LimbSoup, I updated my question. I'm accessing it by wildcard-importing the package and then typing `Location.City` – three-cups Oct 21 '14 at 19:53
  • 1
    Your error message says it all: you are not asking for a `Location.Level` but `model.Level`, where `model` must be either one of your packages or a value and you have a path-dependent type there. So you must have another type `Level` in your code. – 0__ Oct 21 '14 at 19:53
  • 1
    After your edit it's still not clear, that error is a type mismatch, where this type mismatch happens? I can compile your code and create a `Location` quite easily, your edit doesn't make sense because you can't have top level declaration which is not inside some sort of class. – Ende Neu Oct 21 '14 at 19:54
  • @0__, you're right. I do have another type `Level`. It was as simple as that. Thanks! Put that in as an answer and I can mark it as correct. – three-cups Oct 21 '14 at 20:09

1 Answers1

2

Your error message says it all: you are not asking for a Location.Level but model.Level, where model must be either one of your packages or a value and you have a path-dependent type there. So you must have another type Level in your code.

0__
  • 66,707
  • 21
  • 171
  • 266