File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ assertImpl: Test$.main(Test_2.scala:7)
2+ true
3+ assertImpl: Test$.main(Test_2.scala:8)
4+ false
5+ assertImpl: Test$.main(Test_2.scala:9)
6+ hi: Test$.main(Test_2.scala:9)
7+ false
Original file line number Diff line number Diff line change 1+ import  scala .quoted ._ 
2+ 
3+ object  Macros  {
4+   def  printStack (tag : String ):  Unit  =  {
5+     println(tag +  " : " +  new  Exception ().getStackTrace().apply(1 ))
6+   }
7+   def  assertImpl (expr : Expr [Boolean ]) =  ' {
8+     printStack(" assertImpl" 
9+     println(~ expr)
10+   }
11+ }
Original file line number Diff line number Diff line change 1+ object  Test  {
2+ 
3+   transparent  def  assert2 (expr : =>  Boolean ):  Unit  =   ~ Macros .assertImpl('(expr))  
4+ 
5+   def  main (args : Array [String ]):  Unit  =  {
6+     val  x  =  1 
7+     assert2(x !=  0 )
8+     assert2(x ==  0 )
9+     assert2 { Macros .printStack(" hi" ==  0  }
10+   }
11+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments