File tree 3 files changed +13
-2
lines changed
test-resources/type-printer
3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -661,6 +661,8 @@ class Definitions {
661
661
def GetterMetaAnnot (implicit ctx : Context ) = GetterMetaAnnotType .symbol.asClass
662
662
lazy val SetterMetaAnnotType = ctx.requiredClassRef(" scala.annotation.meta.setter" )
663
663
def SetterMetaAnnot (implicit ctx : Context ) = SetterMetaAnnotType .symbol.asClass
664
+ lazy val ShowAsInfixAnotType = ctx.requiredClassRef(" scala.annotation.showAsInfix" )
665
+ def ShowAsInfixAnnot (implicit ctx : Context ) = ShowAsInfixAnotType .symbol.asClass
664
666
665
667
// convenient one-parameter method types
666
668
def methOfAny (tp : Type ) = MethodType (List (AnyType ), tp)
Original file line number Diff line number Diff line change @@ -126,8 +126,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
126
126
def isInfixType (tp : Type ): Boolean = tp match {
127
127
case AppliedType (tycon, args) =>
128
128
args.length == 2 &&
129
- ! Character .isUnicodeIdentifierStart( tycon.typeSymbol.name.toString.head )
130
- // TODO: Once we use the 2.12 stdlib, also check the @showAsInfix annotation
129
+ tycon.typeSymbol.getAnnotation(defn. ShowAsInfixAnnot ).map(_.argumentConstant( 0 ).forall(_.booleanValue) )
130
+ .getOrElse( ! Character .isUnicodeIdentifierStart(tycon.typeSymbol.name.toString.head))
131
131
case _ => false
132
132
}
133
133
Original file line number Diff line number Diff line change @@ -16,3 +16,12 @@ scala> def foo: (Int && String) &: Boolean = ???
16
16
def foo: (Int && String) &: Boolean
17
17
scala> def foo: Int && (Boolean &: String) = ???
18
18
def foo: Int && (Boolean &: String)
19
+ scala> import scala.annotation.showAsInfix
20
+ scala> @scala.annotation.showAsInfix class Mappy[T,U]
21
+ // defined class Mappy
22
+ scala> def foo: Int Mappy (Boolean && String) = ???
23
+ def foo: Int Mappy (Boolean && String)
24
+ scala> @scala.annotation.showAsInfix(false) class ||[T,U]
25
+ // defined class ||
26
+ scala> def foo: Int || Boolean = ???
27
+ def foo: ||[Int, Boolean]
You can’t perform that action at this time.
0 commit comments