-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Match types defined in the scope of an opaque definition leak the underlying opaque type if used in separate compilation module.
Note: could be related to #12944
Compiler version
v3.0.2-RC2
Minimized code
See minimized branch at: https://github.com/soronpo/dottybug/tree/match_type_opaque_leak
main/scala/core/Foo.scala
package core
opaque type Foo <: Int = Int
type LeakFoo[M] = M match
case _ => Foomain/scala/LeakFoo.scala
type LeakFoo[M] = core.LeakFoo[M]
val works = summon[LeakFoo[Any] =:= core.Foo]test/scala/Foo.scala
val shouldFail: LeakFoo[Any] = 1
val shouldWork = summon[LeakFoo[Any] =:= core.Foo]Output
[error] -- Error: IdeaProjects\dottybug\src\test\scala\Foo.scala:2:50 --
[error] 2 |val shouldWork = summon[LeakFoo[Any] =:= core.Foo]
[error] | ^
[error] | Cannot prove that core.Foo$package.Foo =:= core.Foo.
[error] one error foundExpectation
shouldFail should generate a type-mismatch error
shouldWork should compile fine.