Warning when using @newtype in package object
See original GitHub issueI have the following code:
package object stuff {
@newtype case class Thing(underlying: Int)
}
In scala 2.12.x the following warning is issued (making -Xfatal-warning impossible):
[warn] package.scala:10: it is not recommended to define classes/objects inside of package objects.
[warn] If possible, define trait MetricActorRef__Types in package metrics instead.
[warn] @newtype case class MetricActorRef(underlying: ActorRef)
[warn] ^
This warning happens if I use any scala-newtype version > 0.2.1
(that’s the last version that works without the warning).
I am able to work around the issue by using https://github.com/ghik/silencer with the pathFilters pointing to the file in question (the @silent annotation does not work).
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Do I need to define functions when using newtype in Scala?
It seems simpler on the surface, but I'm still left scratching my head. I have this code: package com.craigtreptow.scrayz import io.estatico.
Read more >More types - mypy 0.991 documentation
This section introduces a few additional kinds of types, including NoReturn , NewType , TypedDict , and types for async code. It also...
Read more >autodoc issues with re-exporting NewType and using NewType with ...
Describe the bug The first issue is importing a re-exported NewType type ... correctly without manually setting the __qualname__ I get this: Warning, ......
Read more >typing — Support for type hints — Python 3.11.1 documentation
Note that None as a type hint is a special case and is replaced by type(None) . NewType¶. Use the NewType helper to...
Read more >go/types - Go Packages
Package types declares the data types and implements the algorithms for type-checking of Go packages. Use Config.Check to invoke the type checker for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually this library already uses version-dependent sources. Look for
NewTypeCompatMacros.scala
. You could just add a flag thereemitTrait: Boolean
or whatever and conditionally generate the trait.I think it’s definitely worth doing that, not just because of the warning but also to reduce the overhead in terms of generated class files. 👍
Fixed via #50.