You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -47,7 +49,7 @@ The `@alpha` annotation serves a dual purpose:
47
49
5. Definitions with names in backticks that are not legal host platform names
48
50
should have an `@alpha` annotation. Lack of such an annotation will raise a deprecation warning.
49
51
50
-
6.@alpha annotations must agree: If two definitions are members of an object or class with the same name and matching types, then either none of them has an `@alpha` annotation, or both have `@alpha` annotations with the same name.
52
+
6.`@alpha` annotations must agree: If two definitions are members of an object or class with the same name and matching types, then either none of them has an `@alpha` annotation, or both have `@alpha` annotations with the same name.
51
53
52
54
7. There must be a one-to-one relationship between external and internal names:
53
55
If two definitions are members of an object or class with matching types and both have `@alpha` annotations with the same external name, then their internal method names must also be the same.
@@ -56,6 +58,8 @@ The `@alpha` annotation serves a dual purpose:
56
58
57
59
An `@infix` annotation on a method definition allows using the method as an infix operation. Example:
58
60
```scala
61
+
importscala.annotation.alpha
62
+
59
63
traitMultiSet[T] {
60
64
61
65
@infix
@@ -70,13 +74,15 @@ trait MultiSet[T] {
70
74
vals1, s2:MultiSet[Int]
71
75
72
76
s1 union s2 // OK
77
+
s1 `union` s2 // also OK but unusual
73
78
s1.union(s2) // also OK
74
79
75
80
s1.difference(s2) // OK
76
81
s1 `difference` s2 // OK
77
82
s1 difference s2 // gives a deprecation warning
78
83
79
84
s1 * s2 // OK
85
+
s1 `*` s2 // also OK, but unusual
80
86
s1.*(s2) // also OK, but unusual
81
87
```
82
88
Infix operations involving alphanumeric operators are deprecated, unless
@@ -91,7 +97,7 @@ any unicode character `c` for which `java.lang.Character.isIdentifierPart(c)` re
91
97
92
98
Infix operations involving symbolic operators are always allowed, so `@infix` is redundant for methods with symbolic names.
93
99
94
-
The @infix annotation can also be given to a type:
100
+
The `@infix` annotation can also be given to a type:
95
101
```
96
102
@infix type or[X, Y]
97
103
val x: String or Int = ...
@@ -118,15 +124,15 @@ The purpose of the `@infix` annotation is to achieve consistency across a code b
118
124
@infix def (x: A) op (y1: B, y2: B):R// error: two parameters
119
125
```
120
126
121
-
4. @infix annotations can also be giventotype, traitorclassdefinitions that have exactly two typeparameters. Aninfixtypelike
127
+
4. `@infix` annotations can also be giventotype, traitorclassdefinitions that have exactly two typeparameters. Aninfixtypelike
122
128
123
129
```scala
124
130
@infix typeop[X, Y]
125
131
```
126
132
127
133
can be applied using infix syntax, i.e. `A op B`.
128
134
129
-
5. To smooth migration to Scala3.0, alphanumeric operations will only be deprecated from Scala3.1 onwards,
135
+
5. To smooth migration to Scala3.0, alphanumeric operators will only be deprecated from Scala3.1 onwards,
130
136
or if the `-strict` option is giveninDotty/Scala3.
0 commit comments