Skip to content

Commit

Permalink
add tests for select with target and infix
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Dec 3, 2020
1 parent fa45a3b commit 182176d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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
12 changes: 12 additions & 0 deletions 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

}
22 changes: 22 additions & 0 deletions 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

}

}
12 changes: 12 additions & 0 deletions 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)

}
13 changes: 13 additions & 0 deletions 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

}

}

0 comments on commit 182176d

Please sign in to comment.