-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(scala) add Scala 3 extension soft keyword
Based on https://github.com/scala/vscode-scala-syntax/blob/57e0829cd46980699570101a68c320a20330d36c/src/typescript/Scala.tmLanguage.ts#L1134. Also see https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html#syntax.
- Loading branch information
1 parent
e91ffbd
commit cef8dce
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>) <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">plus</span></span>(y: <span class="hljs-type">Int</span>) = x + y | ||
|
||
<span class="hljs-keyword">extension</span> [<span class="hljs-type">T</span>](x: <span class="hljs-type">T</span>) <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= () | ||
|
||
<span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>) | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">1</span> | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">2</span> | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-title">Foo</span> </span>{ | ||
<span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>) | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">1</span> | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">2</span> | ||
} | ||
|
||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">extension</span></span>(file: <span class="hljs-type">File</span>) = | ||
file.extension | ||
|
||
file | ||
.extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extension (x: Int) def plus(y: Int) = x + y | ||
|
||
extension [T](x: T) def f = () | ||
|
||
extension (x: Int) | ||
def f = 1 | ||
def f = 2 | ||
|
||
object Foo { | ||
extension (x: Int) | ||
def f = 1 | ||
def f = 2 | ||
} | ||
|
||
def extension(file: File) = | ||
file.extension | ||
|
||
file | ||
.extension |