File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed
compiler/src/dotty/tools/dotc/printing Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1- package dotty .tools .dotc
1+ package dotty .tools
2+ package dotc
23package printing
34
45import core ._
@@ -166,13 +167,17 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
166167 ~ " "
167168 ~ toText(appType.resultType)
168169
169- def isInfixType (tp : Type ): Boolean = tp match {
170+ def isInfixType (tp : Type ): Boolean = tp match
170171 case AppliedType (tycon, args) =>
171- args.length == 2 &&
172- tycon.typeSymbol.getAnnotation(defn.ShowAsInfixAnnot ).map(_.argumentConstant(0 ).forall(_.booleanValue))
173- .getOrElse(! Character .isUnicodeIdentifierStart(tycon.typeSymbol.name.toString.head))
172+ args.length == 2
173+ && {
174+ val sym = tycon.typeSymbol
175+ sym.is(Infix )
176+ || sym.getAnnotation(defn.ShowAsInfixAnnot )
177+ .exists(_.argumentConstant(0 ).forall(_.booleanValue))
178+ || ! Character .isUnicodeIdentifierStart(tycon.typeSymbol.name.toString.head)
179+ }
174180 case _ => false
175- }
176181
177182 def tyconName (tp : Type ): Name = tp.typeSymbol.name
178183 def checkAssocMismatch (tp : Type , isRightAssoc : Boolean ) = tp match {
Original file line number Diff line number Diff line change 1+ -- [E007] Type Mismatch Error: tests/neg/print-infix-type.scala:8:29 ---------------------------------------------------
2+ 8 | val x: over[String, Int] = f // error
3+ | ^
4+ | Found: Int over String
5+ | Required: String over Int
6+
7+ longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ object A :
2+
3+ opaque infix type over [A , B ] = (A , B )
4+ def f : over[Int , String ] = (1 , " " )
5+
6+ object B :
7+ import A .*
8+ val x : over[String , Int ] = f // error
You can’t perform that action at this time.
0 commit comments