diff options
author | Vlad Ureche <vlad.ureche@gmail.com> | 2016-09-14 14:06:01 +0100 |
---|---|---|
committer | Vlad Ureche <vlad.ureche@gmail.com> | 2016-09-19 20:06:29 +0200 |
commit | e60768b62151a160026985269a87fd5b63ee0ae8 (patch) | |
tree | 86eafa3b66d6f27657967075714068e16b5c79c3 /src/reflect/scala/reflect/internal/Types.scala | |
parent | fdb3105228db20e347a61e61e2e1d86b27683d0d (diff) | |
download | scala-e60768b62151a160026985269a87fd5b63ee0ae8.tar.gz scala-e60768b62151a160026985269a87fd5b63ee0ae8.tar.bz2 scala-e60768b62151a160026985269a87fd5b63ee0ae8.zip |
SI-4700 Add `@infix` annotation for type printing
```
scala> import scala.annotation.infix
import scala.annotation.infix
scala> @infix class &&[T, U]
defined class $amp$amp
scala> def foo: Int && Boolean = ???
foo: Int && Boolean
```
Diffstat (limited to 'src/reflect/scala/reflect/internal/Types.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 7dda805378..54200dea8e 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -307,6 +307,9 @@ trait Types /** Is this type completed (i.e. not a lazy type)? */ def isComplete: Boolean = true + /** Should this be printed as an infix type (@showAsInfix class &&[T, U])? */ + def isShowAsInfixType: Boolean = false + /** If this is a lazy type, assign a new type to `sym`. */ def complete(sym: Symbol) {} @@ -2097,6 +2100,9 @@ trait Types trivial = fromBoolean(!sym.isTypeParameter && pre.isTrivial && areTrivialTypes(args)) toBoolean(trivial) } + + override def isShowAsInfixType: Boolean = sym.hasAnnotation(ShowAsInfixAnnotationClass) + private[Types] def invalidateTypeRefCaches(): Unit = { parentsCache = null parentsPeriod = NoPeriod @@ -2345,6 +2351,14 @@ trait Types xs.init.mkString("(", ", ", ")") + " => " + xs.last } } + else if (isShowAsInfixType && args.length == 2) + args(0) + " " + sym.decodedName + " " + + ( + if (args(1).isShowAsInfixType) + "(" + args(1) + ")" + else + args(1) + ) else if (isTupleTypeDirect(this)) tupleTypeString else if (sym.isAliasType && prefixChain.exists(_.termSymbol.isSynthetic) && (this ne dealias)) |