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
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/export.md
+37-3Lines changed: 37 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -153,9 +153,11 @@ extension (x: String)
153
153
privatedefmoreOps=newStringOps(x)
154
154
exportmoreOps.*
155
155
```
156
-
In this case the qualifier expression must be an identifier that refers to a unique parameterless extension method in the same extension clause. The export will create
157
-
extension methods for all accessible term members
158
-
in the result of the qualifier path. For instance, the extension above would be expanded to
156
+
In this case the qualifier expression must be an identifier that refers to a unique parameterless extension method in the same extension clause.
157
+
158
+
An export will then create extension methods for all accessible term members,
159
+
matching the selectors, in the result of the qualifier path.
160
+
For instance, the extension above would be expanded to
159
161
```scala
160
162
extension (x: String)
161
163
deftake(n: Int):String= x.substring(0, n)
@@ -165,6 +167,38 @@ extension (x: String)
165
167
defcapitalize:String= moreOps.capitalize
166
168
```
167
169
170
+
### A Note on Exporting Extension Methods
171
+
**Note:** extension methods can have surprising results if exported from within an extension (i.e. they
172
+
are exported as-if they were an ordinary method). Observe the following example:
0 commit comments