Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8770 from dotty-staging/fix-#8745
Fix #8745: Match Ident prefixes to find potential holes
- Loading branch information
Showing
8 changed files
with
61 additions
and
4 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
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._ | ||
|
||
object Companion extends Trait | ||
trait Trait { | ||
def fun(first: String): String = "anything" | ||
} | ||
|
||
object Macro { | ||
inline def mac(inline tree: String): String = ${ macImpl('tree) } | ||
def macImpl(tree: Expr[String])(using qctx: QuoteContext): Expr[String] = { | ||
tree match { | ||
case vv @ '{ ($s: Trait).fun($arg) } => arg | ||
case _ => Expr("not matched") | ||
} | ||
} | ||
} |
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,6 @@ | ||
import Macro._ | ||
|
||
@main def Test() = { //hello | ||
import Companion._ | ||
mac(fun("blah")) | ||
} |
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,15 @@ | ||
import scala.quoted._ | ||
|
||
object Companion { | ||
def fun(first: String): String = "anything" | ||
} | ||
|
||
object Macro { | ||
inline def mac(inline tree: String): String = ${ macImpl('tree) } | ||
def macImpl(tree: Expr[String])(using qctx: QuoteContext): Expr[String] = { | ||
tree match { | ||
case vv @ '{ ($s: Companion.type).fun($arg) } => arg | ||
case _ => ??? | ||
} | ||
} | ||
} |
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,6 @@ | ||
import Macro._ | ||
|
||
@main def Test() = { //hello | ||
import Companion._ | ||
mac(fun("blah")) | ||
} |