File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
test-resources/type-printer Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -661,6 +661,8 @@ class Definitions {
661661 def GetterMetaAnnot (implicit ctx : Context ) = GetterMetaAnnotType .symbol.asClass
662662 lazy val SetterMetaAnnotType = ctx.requiredClassRef(" scala.annotation.meta.setter" )
663663 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
664666
665667 // convenient one-parameter method types
666668 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) {
126126 def isInfixType (tp : Type ): Boolean = tp match {
127127 case AppliedType (tycon, args) =>
128128 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))
131131 case _ => false
132132 }
133133
Original file line number Diff line number Diff line change @@ -16,3 +16,12 @@ scala> def foo: (Int && String) &: Boolean = ???
1616def foo: (Int && String) &: Boolean
1717scala> def foo: Int && (Boolean &: String) = ???
1818def 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