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

Existing classes are shadowed by type aliases inside the object #74

Open
Mee-Tree opened this issue Mar 1, 2023 · 0 comments
Open

Existing classes are shadowed by type aliases inside the object #74

Mee-Tree opened this issue Mar 1, 2023 · 0 comments

Comments

@Mee-Tree
Copy link

Mee-Tree commented Mar 1, 2023

Example:

case class Type(name: String)

@newtype case class Foo(value: List[Type])

val value: List[Type] = List(Type("abc"))
Foo(value)

The code does not compile due to the following error:

type mismatch;
 found   : List[Type]
 required: List[Foo.Type]

The simplest solution is to rename all type aliases to avoid the possibility of name collision (like prefixing them with $).

type $Base = ...
type $Repr = ...
type $Type = ...
type $Tag = ...

Currently, as a workaround, the user can create an alias (if changing the name isn't an option), and the code would work as expected:

type TType = Type
@newtype case class Foo(value: List[TType])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant