Skip to content

Commit

Permalink
Add extension method to check if a symbol is overriden in a template (#…
Browse files Browse the repository at this point in the history
…12)

Add `scala.quoted` package with a single extension method to check if a
given definition overrides a given symbol
  • Loading branch information
hamzaremmal authored Oct 15, 2024
2 parents eef8f96 + 023b508 commit 761f5d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/scala/steps/quoted/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package steps.quoted

import scala.quoted.*

extension(using Quotes)(inline cls: quotes.reflect.Symbol)

/** Check if a given class, trait or object overrides a given definition
*
* @param cls The class, trait or object to inspect
* @param sym The symbol that should be overriden
* @return true if the definition is overriden, false otherwise
*/
inline def overrides(inline sym: quotes.reflect.Symbol): Boolean =
sym.overridingSymbol(cls).exists

end extension

0 comments on commit 761f5d7

Please sign in to comment.