Skip to content

Commit e8b1f2e

Browse files
committed
Use same priority for type operators, as mandated by the spec
1 parent 6e8dfb4 commit e8b1f2e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/package.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ package object parsing {
99

1010
def precedence(operator: Name, isType: Boolean = false): Int =
1111
if (operator eq nme.ERROR) -1
12+
/* SLS 3.2.10 (https://www.scala-lang.org/files/archive/spec/2.13/03-types.html#infix-types):
13+
* all infix types have the same precedence */
14+
else if (isType) minInfixPrec
1215
else {
1316
val firstCh = operator.firstPart.head
1417
if (isScalaLetter(firstCh)) 1

compiler/test-resources/type-printer/infix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ scala> import scala.annotation.showAsInfix
3232
scala> @scala.annotation.showAsInfix class Mappy[T,U]
3333
// defined class Mappy
3434
scala> def foo: (Int Mappy Boolean) && String = ???
35-
def foo: (Int Mappy Boolean) && String
35+
def foo: Int Mappy Boolean && String
3636
scala> def foo: Int Mappy Boolean && String = ???
3737
def foo: Int Mappy Boolean && String
3838
scala> def foo: Int Mappy (Boolean && String) = ???
39-
def foo: Int Mappy Boolean && String
39+
def foo: Int Mappy (Boolean && String)
4040
scala> @scala.annotation.showAsInfix(false) class ||[T,U]
4141
// defined class ||
4242
scala> def foo: Int || Boolean = ???

0 commit comments

Comments
 (0)