-   Notifications  
You must be signed in to change notification settings  - Fork 1.1k
 
Closed
Description
The transparent inline macro that exists within an opaque source can leak the underlying opaque type.
 Note that this does not occur if the macro is not transparent, or if the inline is not a macro.
 Additionally, we require another pass through a transparent leak definition to expose this leak (in this example it is implemented with given ... with, but that could be a transparent inline that does the same thing).
Compiler version
v3.1.0-RC1
Minimized code
Minimized project at: https://github.com/soronpo/dottybug/tree/transparent_opaque_leak
MyOpaque.scala
import scala.quoted.* opaque type MyOpaque = Int object MyOpaque: val one: MyOpaque = 1 transparent inline def apply(): MyOpaque = ${ applyMacro } private def applyMacro(using Quotes): Expr[MyOpaque] = import quotes.reflect.* '{ one }Leak.scala
trait Leak[T]: type Out given [T]: Leak[T] with type Out = T extension [T](t: T)(using l: Leak[T]) def leak: l.Out = ??? val x = MyOpaque().leak val shouldWork = summon[x.type <:< MyOpaque]Output
[error] 8 |val shouldWork = summon[x.type <:< MyOpaque] [error] | ^ [error] | Cannot prove that (x : given_Leak_T[Int]#Out) <:< MyOpaque. [error] one error foundExpectation
No error.
TomasMikula and BalmungSan