forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle @companionClass and @companionMethod meta-annotations
Fixes scala#17002
- Loading branch information
Showing
6 changed files
with
53 additions
and
10 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
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,20 @@ | ||
import scala.annotation.compileTimeOnly | ||
|
||
sealed trait Test[T] | ||
|
||
object Test: | ||
@compileTimeOnly("Error") | ||
given test0[T]: Test[T] = ??? | ||
|
||
@compileTimeOnly("Error") | ||
given test1[T]: Test[T]() | ||
|
||
@compileTimeOnly("Error") | ||
implicit class ic(x: Int): | ||
def foo = 2 | ||
|
||
test0 // error | ||
|
||
test1 // error | ||
|
||
2.foo // error |
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,10 @@ | ||
import scala.annotation.meta.companionMethod | ||
|
||
@companionMethod | ||
class methOnly extends annotation.Annotation | ||
|
||
class Test | ||
object Test: | ||
|
||
@methOnly | ||
given test2[T]: Test with {} |