File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed
compiler/src/dotty/tools/dotc/core
library/src/scala/annotation Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -883,6 +883,10 @@ class Definitions {
883883 def ShowAsInfixAnnot (implicit ctx : Context ): ClassSymbol = ShowAsInfixAnotType .symbol.asClass
884884 lazy val FunctionalInterfaceAnnotType = ctx.requiredClassRef(" java.lang.FunctionalInterface" )
885885 def FunctionalInterfaceAnnot (implicit ctx : Context ) = FunctionalInterfaceAnnotType .symbol.asClass
886+ lazy val InfixAnnotType = ctx.requiredClassRef(" scala.annotation.infix" )
887+ def InfixAnnot (implicit ctx : Context ) = InfixAnnotType .symbol.asClass
888+ lazy val AlphaAnnotType = ctx.requiredClassRef(" scala.annotation.alpha" )
889+ def AlphaAnnot (implicit ctx : Context ) = AlphaAnnotType .symbol.asClass
886890
887891 // convenient one-parameter method types
888892 def methOfAny (tp : Type ): MethodType = MethodType (List (AnyType ), tp)
Original file line number Diff line number Diff line change 1+ package scala .annotation
2+
3+ final class alpha (name : String ) extends StaticAnnotation
Original file line number Diff line number Diff line change 1+ package scala .annotation
2+
3+ final class infix extends StaticAnnotation
Original file line number Diff line number Diff line change 1+ import annotation .{infix , alpha }
2+ object Test extends App {
3+
4+ case class Rational (n : Int , d : Int ) {
5+ @ infix def + (that : Rational ) =
6+ Rational (this .n * that.d + that.n * this .d, this .d * that.d)
7+ @ infix @ alpha(" multiply" ) def * (that : Rational ) =
8+ Rational (this .n * that.n, this .d * that.d)
9+ }
10+
11+ val r1 = Rational (1 ,2 )
12+ val r2 = Rational (2 ,3 )
13+ println(r1 * r2)
14+ println(r1 + r2)
15+ }
You can’t perform that action at this time.
0 commit comments