diff --git a/test/tasty/neg/src-2/TestSelectWithTarget.check b/test/tasty/neg/src-2/TestSelectWithTarget.check new file mode 100644 index 000000000000..60ca319eaaf9 --- /dev/null +++ b/test/tasty/neg/src-2/TestSelectWithTarget.check @@ -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 diff --git a/test/tasty/neg/src-2/TestSelectWithTarget_fail.scala b/test/tasty/neg/src-2/TestSelectWithTarget_fail.scala new file mode 100644 index 000000000000..48df0224770e --- /dev/null +++ b/test/tasty/neg/src-2/TestSelectWithTarget_fail.scala @@ -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 + +} diff --git a/test/tasty/neg/src-3/SelectWithTarget.scala b/test/tasty/neg/src-3/SelectWithTarget.scala new file mode 100644 index 000000000000..42bf105ea222 --- /dev/null +++ b/test/tasty/neg/src-3/SelectWithTarget.scala @@ -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 + + } + +} diff --git a/test/tasty/pos/src-2/tastytest/TestInfix.scala b/test/tasty/pos/src-2/tastytest/TestInfix.scala new file mode 100644 index 000000000000..da73e5f81c55 --- /dev/null +++ b/test/tasty/pos/src-2/tastytest/TestInfix.scala @@ -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) + +} diff --git a/test/tasty/pos/src-3/tastytest/Infix.scala b/test/tasty/pos/src-3/tastytest/Infix.scala new file mode 100644 index 000000000000..e3f4efc491b6 --- /dev/null +++ b/test/tasty/pos/src-3/tastytest/Infix.scala @@ -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 + + } + +}