Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour when parameterising singleton type #179

Open
tindzk opened this Issue Feb 12, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@tindzk
Copy link

tindzk commented Feb 12, 2018

The following example yields a type mismatch:

class StringSingletonList[T <: Singleton with String](values: List[T])
new StringSingletonList(List("a", "a"))
// inferred type arguments [String] do not conform to class StringSingletonList's type parameter bounds [T <: Singleton with String]

Strangely, the argument's type is inferred correctly:

List("a", "a"): List[_ <: Singleton with String] 
// res1: List[String] = List("a", "a")

These two declarations can be used as a workaround:

class StringSingletonList[T <: Singleton](values: List[T with String])
class StringSingletonList[T <: String](values: List[T with Singleton])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.