companion extension method not found for opaque type
See original GitHub issueCompiler version
v3.1.0-RC1
Minimized code
opaque type Foo[T] = Int
object Foo:
extension [T](f: Foo[T]) def foo: Int = 1
def bar[T](f: Foo[T]): Unit =
val x = f.foo
Output
value foo is not a member of Foo[T], but could be made available as an extension method.
Expectation
No error.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Opaque Type Aliases - Scala 3 - EPFL
Opaque types aliases provide type abstraction without any overhead. ... None end Logarithm // Extension methods define opaque types' public APIs extension ...
Read more >Opaque Type Aliases
Opaque types aliases provide type abstraction without any overhead. ... None end Logarithm // Extension methods define opaque types' public APIs extension ...
Read more >Opaque Type Alias in Scala 3 - Baeldung
Let's add an extension method to the companion object of our opaque type Year: extension (year: Year) { def value: Int = year...
Read more >scala - Top level opaque type with same underlying type and ...
I ran into an issue when defining opaque types with identical underlying types and extension methods, e.g.: opaque type HandleA = Int object ......
Read more >Scala 3: Opaque Types - Rock the JVM Blog
We discover opaque type aliases in Scala 3 and how we can define new ... companion object) and “non-static” API (i.e. extension methods), ......
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 Free
Top 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
But it works if I put the whole thing in an object. So there’s still something wrong with the toplevel scope here.
OK, I’ll submit a PR for the docs.