File tree 2 files changed +34
-0
lines changed
tests/neg-custom-args/fatal-warnings/i16876
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ def findMethodSymbol (using q : Quotes )(s : quotes.reflect.Symbol ): quotes.reflect.Symbol =
4
+ if s.isDefDef then
5
+ s
6
+ else
7
+ findMethodSymbol(using q)(s.owner)
8
+ end findMethodSymbol
9
+
10
+
11
+ inline def adder : Int = $ {
12
+ adderImpl
13
+ }
14
+
15
+ def adderImpl (using q : Quotes ): Expr [Int ] =
16
+ import quotes .reflect .*
17
+
18
+ val inputs = findMethodSymbol(using q)(q.reflect.Symbol .spliceOwner).tree match
19
+ case DefDef (_, params, _, _) =>
20
+ params.last match
21
+ case TermParamClause (valDefs) =>
22
+ valDefs.map(vd => Ref (vd.symbol).asExprOf[Int ])
23
+ inputs.reduce((exp1, exp2) => ' { $exp1 + $exp2 })
Original file line number Diff line number Diff line change
1
+ // scalac: -Wunused:all
2
+
3
+ object Foo {
4
+ private def myMethod (a : Int , b : Int , c : Int ) = adder // ok
5
+ myMethod(1 , 2 , 3 )
6
+
7
+ private def myMethodFailing (a : Int , b : Int , c : Int ) = a + 0 // error // error
8
+ myMethodFailing(1 , 2 , 3 )
9
+ }
10
+
11
+
You can’t perform that action at this time.
0 commit comments