Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for select with target and infix
- Loading branch information
1 parent
fa45a3b
commit 182176d
Showing
5 changed files
with
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TestSelectWithTarget_fail.scala:10: error: Unsupported Scala 3 selection of method foo with @targetName("fooString"); found in method selectFooString in object tastytest.SelectWithTarget. | ||
def test = SelectWithTarget.selectFooString | ||
^ | ||
1 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,12 @@ | ||
package tastytest | ||
|
||
object TestSelectWithTarget { | ||
|
||
// We error when an annotation selects a | ||
// method overloaded with a targetAnnot | ||
// until we can erase them correctly. | ||
// e.g. the annotation arguments may be | ||
// reflected by a macro into real trees | ||
def test = SelectWithTarget.selectFooString | ||
|
||
} |
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,22 @@ | ||
package tastytest | ||
|
||
import scala.annotation.{StaticAnnotation, targetName} | ||
|
||
object SelectWithTarget { | ||
|
||
class defAnnot(arg: Any) extends StaticAnnotation | ||
|
||
@defAnnot(Overloads.foo("hi")) | ||
def selectFooString: Int = 23 | ||
|
||
object Overloads { | ||
|
||
@targetName("fooString") | ||
def foo(t: => String): Int = t.length | ||
|
||
@targetName("fooInt") | ||
def foo(t: => Int): Int = t | ||
|
||
} | ||
|
||
} |
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,12 @@ | ||
package tastytest | ||
|
||
import Infix.BoxedInt | ||
|
||
object TestInfix { | ||
|
||
val x = BoxedInt(0) | ||
val y = BoxedInt(2) | ||
|
||
def test = assert((x min y) == x) | ||
|
||
} |
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,13 @@ | ||
package tastytest | ||
|
||
object Infix { | ||
|
||
final case class BoxedInt(toInt: Int) { | ||
|
||
infix def min (that: BoxedInt): BoxedInt = | ||
if toInt.min(that.toInt) == toInt then this | ||
else that | ||
|
||
} | ||
|
||
} |