-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label
Description
Compiler version
3.3.7
Minimized code
Given an interface:
trait Foo {
// implementers can use this, but shouldn't be public Foo API
protected final def p: Int = 4
def foo: Int
}and a macro like:
inline def macro = $macroImpl
def macroImpl(using Quotes)(): Expr[Foo] = '{
new Foo {
def foo: Int = p
}
}Output
If you use
val foo = macroGives an error message
undefined: this.inline$p # -1: TermRef(ThisType(TypeRef(NoPrefix,class $anon)),inline$p) at typer
Expectation
It should work, as the regular Scala snippet that does this does work. Ideally, I would be able to mark def p as private [pkg], which wouldn't work either (but in this case, I can buy that this would be inlined outside of pkg and therefore could leak scope, not that I'd mind, but this is a separate issue/feature request (#24822 ).)
Metadata
Metadata
Assignees
Labels
itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label