False type mismatch involving the singleton type of the result of a transparent inline method
See original GitHub issueCompiler version
3.1.2
Minimized code
trait Quotes
transparent inline def quotes(using q: Quotes) = q
class QuotesExt[Q <: Quotes]
object QuotesExt {
def apply(q: Quotes): QuotesExt[q.type] =
new QuotesExt[q.type]
}
def foo(q: Quotes, qe: QuotesExt[q.type]): Unit =
()
def doesNotCompile(using Quotes): Unit =
foo(quotes, QuotesExt(quotes))
// Workaround 1: use explicit type annotation
def compiles(using Quotes): Unit =
foo(quotes: quotes.type, QuotesExt(quotes))
// Workaround 2: avoid the transparent inline method `quotes`
def alsoCompiles(using q: Quotes): Unit =
foo(q, QuotesExt(q))
Output
-- [E007] Type Mismatch Error: test.scala:16:23 --------------------------------
16 | foo(quotes, QuotesExt(quotes))
| ^^^^^^^^^^^^^^^^^
| Found: QuotesExt[(x$1 : Quotes)]
| Required: QuotesExt[(?1 : (using q: Quotes): Quotes)]
|
| where: ?1 is an unknown value of type (using q: Quotes): Quotes
longer explanation available when compiling with `-explain`
1 error found
Expectation
The code should compile.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Inline - Scala 3 - EPFL
Here, the inline method choose returns an instance of either of the two types A or B . If choose had not been...
Read more >Strange type mismatch with a macro: found - Stack Overflow
1 Answer 1 ... You're making your life harder by trying to funnel your type information back through the names of type parameters...
Read more >Inline
The inline method is a "blackbox" in the sense that details of its implementation do not leak out. But if a transparent modifier...
Read more >Node.js v19.3.0 Documentation
When assert.doesNotThrow() is called, it will immediately call the fn function. If an error is thrown and it is the same type as...
Read more >VBA Type Mismatch Error - The Ultimate Guide
In general, VBA is very forgiving when you assign the wrong value type to a variable e.g.. Dim x As Long ' VBA...
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
Workaround
Note: if
foo
is curried, then the snippet compiles successfully: