Skip to content

Commit ae756ad

Browse files
committed
Add regression tests
1 parent c4a6bed commit ae756ad

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

tests/pos/i22974a/Maybe_1.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package pack
2+
import Maybe._
3+
opaque type Maybe[+A] >: (Absent | Present[A]) = Absent | Present[A]
4+
object Maybe:
5+
sealed abstract class Absent
6+
case object Absent extends Absent
7+
object internal:
8+
case class PresentAbsent(val depth: Int)
9+
opaque type Present[+A] = A | internal.PresentAbsent
10+
11+
extension [A](self: Maybe[A]) {
12+
inline def flatten[B]: Maybe[B] = ???
13+
inline def isDefined: Boolean = ???
14+
}

tests/pos/i22974a/macro_1.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted._
2+
3+
inline def passThorugh(inline condition: Boolean): Any =
4+
${ passThorughImpl('{condition}) }
5+
6+
def passThorughImpl(condition: Expr[Boolean])(using Quotes): Expr[Any] = condition

tests/pos/i22974a/main_2.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
def main(): Unit =
3+
import pack.Maybe
4+
val res: Maybe[Maybe[Int]] = ???
5+
passThorugh(res.flatten.isDefined)
6+
}

tests/pos/i22974b.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object outer:
2+
opaque type Queue = Queue.Unsafe
3+
object Queue:
4+
abstract class Unsafe
5+
opaque type Unbounded = Queue
6+
object Unbounded:
7+
inline def initWith()(f: Unbounded => Unit): Unit =
8+
f(Unsafe.init())
9+
10+
opaque type Unsafe <: Queue.Unsafe = Queue
11+
object Unsafe:
12+
def init[A](): Unsafe = ???
13+
14+
object Resource:
15+
def run: Unit =
16+
outer.Queue.Unbounded.initWith() { q =>
17+
???
18+
}

tests/pos/i22974c.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object other:
2+
sealed abstract class Absent
3+
case object Absent extends Absent
4+
case class PresentAbsent(val depth: Int)
5+
opaque type Present[+A] = A | PresentAbsent
6+
opaque type Maybe[+A] >: (Absent | Present[A]) = Absent | Present[A]
7+
8+
extension [A](self: Maybe[A]) {
9+
inline def flatten[B]: Maybe[B] = if self.isEmpty then Absent else ???
10+
def isEmpty: Boolean = self.isInstanceOf[Absent]
11+
}
12+
13+
class Test {
14+
def main(): Unit =
15+
import other.Maybe
16+
val res: Maybe[Maybe[Int]] = ???
17+
res.flatten
18+
}

0 commit comments

Comments
 (0)