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

Classes can't have unit fields? #8036

Closed
travisbrown opened this issue Jan 19, 2020 · 3 comments
Closed

Classes can't have unit fields? #8036

travisbrown opened this issue Jan 19, 2020 · 3 comments

Comments

@travisbrown
Copy link
Contributor

minimized code

class UnitClass(val x: Unit)

object Test {
  def main(args: Array[String]): Unit = {
    println(new UnitClass(()))
  }
}
Compiles but fails at runtime
Exception in thread "main" java.lang.NoSuchFieldError: UnitClass.x
	at UnitClass.<init>(Test.scala:1)
	at Test$.main(Test.scala:5)
	at Test.main(Test.scala)

expectation

It works fine on Scala 2. It also works fine if you change the Unit to e.g. Int or String.

@travisbrown
Copy link
Contributor Author

FWIW this isn't from the Cats tests but is something I ran into while trying to minimize the issue in #8035.

@smarter
Copy link
Member

smarter commented Jan 19, 2020

Duplicate of #6987

@smarter smarter closed this as completed Jan 19, 2020
@travisbrown
Copy link
Contributor Author

Oh, thanks, I should have looked more closely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants