diff options
author | allisonhb <allisonhb@gmx.com> | 2016-12-07 21:45:30 -0500 |
---|---|---|
committer | allisonhb <allisonhb@gmx.com> | 2016-12-14 14:13:01 -0500 |
commit | fab1db5a3854ae737e1d749eb08be9baf41199f5 (patch) | |
tree | 9db8b4320157afbac06bfb3a832f3682e64bf625 /src/reflect/scala/reflect | |
parent | 8badcadbe51f4a02e495f462f5f2666a24d79cb0 (diff) | |
download | scala-fab1db5a3854ae737e1d749eb08be9baf41199f5.tar.gz scala-fab1db5a3854ae737e1d749eb08be9baf41199f5.tar.bz2 scala-fab1db5a3854ae737e1d749eb08be9baf41199f5.zip |
SI-4700 Make infix notation default for symbolic types.
Add ability to disable this via the @showAsInfix annotation.
Diffstat (limited to 'src/reflect/scala/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/AnnotationInfos.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index cfde164754..14a8e053e9 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -316,8 +316,9 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => /** Check whether any of the arguments mention a symbol */ def refsSymbol(sym: Symbol) = hasArgWhich(_.symbol == sym) - def stringArg(index: Int) = constantAtIndex(index) map (_.stringValue) - def intArg(index: Int) = constantAtIndex(index) map (_.intValue) + def stringArg(index: Int) = constantAtIndex(index) map (_.stringValue) + def intArg(index: Int) = constantAtIndex(index) map (_.intValue) + def booleanArg(index: Int) = constantAtIndex(index) map (_.booleanValue) def symbolArg(index: Int) = argAtIndex(index) collect { case Apply(fun, Literal(str) :: Nil) if fun.symbol == definitions.Symbol_apply => newTermName(str.stringValue) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 44e96163ea..73103668e3 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2101,9 +2101,13 @@ trait Types toBoolean(trivial) } - /* It only makes sense to show 2-ary type constructors infix. */ + /* It only makes sense to show 2-ary type constructors infix. + * By default we do only if it's a symbolic name. */ override def isShowAsInfixType: Boolean = - sym.hasAnnotation(ShowAsInfixAnnotationClass) && hasLength(args, 2) + hasLength(args, 2) && + sym.getAnnotation(ShowAsInfixAnnotationClass) + .map(_ booleanArg 0 getOrElse true) + .getOrElse(!Character.isUnicodeIdentifierStart(sym.decodedName.head)) private[Types] def invalidateTypeRefCaches(): Unit = { parentsCache = null |