-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix quotes with references to path dependent types
- Loading branch information
1 parent
ed57e32
commit 31d94d7
Showing
5 changed files
with
109 additions
and
20 deletions.
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
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
70 changes: 70 additions & 0 deletions
70
tests/pos-macros/path-dependent-type-capture/Macro_1.scala
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,70 @@ | ||
import scala.quoted.* | ||
|
||
trait A: | ||
type T | ||
val b: B | ||
|
||
trait B: | ||
type T | ||
def f: Unit | ||
|
||
trait C0: | ||
type U | ||
val d: D0 | ||
trait D0: | ||
type U | ||
def h: Unit | ||
object Macro: | ||
inline def generateCode: Unit = ${ generateCodeExpr } | ||
|
||
def generateCodeExpr(using Quotes): Expr[Unit] = | ||
'{ | ||
$testLocalPathsGlobalClasses | ||
$testLocalPathsLocalClasses | ||
} | ||
|
||
def testLocalPathsGlobalClasses(using Quotes): Expr[Unit] = | ||
'{ | ||
type T | ||
val a: A = ??? | ||
${ | ||
val expr = '{ | ||
val t: T = ??? | ||
val aT: a.T = ??? | ||
val abT: a.b.T = ??? | ||
val aRef: a.type = ??? | ||
aRef.b | ||
aRef.b.f | ||
val abRef: a.b.type = ??? | ||
abRef.f | ||
() | ||
} | ||
expr | ||
} | ||
} | ||
|
||
def testLocalPathsLocalClasses(using Quotes): Expr[Unit] = | ||
'{ | ||
type U | ||
trait C extends C0: | ||
type U | ||
val d: D | ||
trait D extends D0: | ||
type U | ||
def h: Unit | ||
val c: C = ??? | ||
${ | ||
val expr = '{ | ||
val u: U = ??? | ||
val cU: c.U = ??? | ||
val cdU: c.d.U = ??? | ||
val cRef: c.type = ??? | ||
cRef.d | ||
cRef.d.h | ||
val cdRef: c.d.type = ??? | ||
cdRef.h | ||
() | ||
} | ||
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 @@ | ||
@main def test = Macro.generateCode |