forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix references to class members defined in quotes
If an inner quote selects a symbol that is defined in an outer quote we need to transform it or reject it. The issue is that the inner quote cannot contain a reference to the type of the class defined in the outer quote. Any such reference is erased the parents of that class that are statically know outside those quotes. If the selected symbol is overriding a symbol in one of those statically known classes, we can use that overridden symbol instead. If not we have to reject the code. Fixes scala#17103
- Loading branch information
1 parent
b92bddd
commit f6a703d
Showing
5 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import scala.quoted.* | ||
|
||
def test(using Quotes): Expr[Unit] = | ||
'{ | ||
trait C: | ||
def d: Int | ||
val c: C = ??? | ||
${ | ||
val expr = '{ | ||
val cRef: c.type = ??? | ||
cRef.d // error | ||
() | ||
} | ||
expr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import scala.quoted.* | ||
|
||
trait C0: | ||
def d: Int | ||
|
||
def test(using Quotes): Expr[Unit] = | ||
'{ | ||
trait C1 extends C0: | ||
def d: Int | ||
trait C extends C1: | ||
def d: Int | ||
val c: C = ??? | ||
${ | ||
val expr = '{ | ||
val cRef: C = ??? | ||
cRef.d // calls C0.d | ||
() | ||
} | ||
expr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import scala.quoted.* | ||
|
||
trait C0: | ||
def d: Int | ||
|
||
def test(using Quotes): Expr[Unit] = | ||
'{ | ||
trait C1 extends C0: | ||
def d: Int | ||
trait C extends C1: | ||
def d: Int | ||
val c: C = ??? | ||
${ | ||
val expr = '{ | ||
val cRef: c.type = ??? | ||
cRef.d // calls C0.d | ||
() | ||
} | ||
expr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters