Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum SourceVersion:
def enablesNamedTuples = isAtLeast(`3.7`)
def enablesBetterFors(using Context) = isAtLeast(`3.8`) || (isAtLeast(`3.7`) && isPreviewEnabled)
/** See PR #23441 and tests/neg/i23435-min */
def enablesDistributeAnd = !isAtLeast(`3.8`)
def enablesDistributeAnd = !isAtLeast(`future`)

def requiresNewSyntax = isAtLeast(future)

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i23435-min.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future

type Or[+A, +B] = A | B

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i23435.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future

trait L[+A]{val a:A}
trait R[+B]{val b: B}
Expand Down
20 changes: 10 additions & 10 deletions tests/neg/i24096.check
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- [E007] Type Mismatch Error: tests/neg/i24096.scala:8:31 -------------------------------------------------------------
8 | case r: Terminal[?] => r // error
| ^
| Found: (r : Pull.Terminal[_] & Pull[F, O, Unit])
| Required: Pull[F2, O2, Unit]
|
| where: F is a type in class StreamPullOps with bounds <: [_²] =>> Any
| F2 is a type in method flatMapOutput with bounds >: [x] =>> F[x] and <: [x] =>> Any
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i24096.scala:10:31 ------------------------------------------------------------
10 | case r: Terminal[?] => r // error
| ^
| Found: (r : Pull.Terminal[_] & Pull[F, O, Unit])
| Required: Pull[F2, O2, Unit]
|
| where: F is a type in class StreamPullOps with bounds <: [_²] =>> Any
| F2 is a type in method flatMapOutput with bounds >: [x] =>> F[x] and <: [x] =>> Any
|
| longer explanation available when compiling with `-explain`
2 changes: 2 additions & 0 deletions tests/neg/i24096.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -source:future

abstract class Pull[+F[_], +O, +R]
object Pull:
abstract class Terminal[+R] extends Pull[Nothing, Nothing, R]
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i3989e.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future

object Test extends App {
trait A[+X](val x: X)
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/singletonInterval.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future

/** Why the singletonInterval logic cannot be applied for lubArgs and glbArgs in TypeComparer. */

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/cb-companion-joins.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future
import language.experimental.modularity

trait M[Self]:
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i10256.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source:3.8
//> using options -source:future

trait Foo[T <: Foo[T]] {
type I <: Foo[I]
Expand Down
8 changes: 4 additions & 4 deletions tests/pos/i11064.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//> using options -source:3.8
//> using options -source:future

trait TypedArray[T, Repr]

trait Ops[T <: TypedArray[_, T]] {
trait Ops[T <: TypedArray[?, T]] {
def typedArray(): T
}

object Test {
def test1(ops: Ops[_ <: TypedArray[_, _]]) = ops.typedArray()
def test2(ops: Ops[_ <: TypedArray[_ <: AnyRef, _]]) = ops.typedArray() // ok, was error: Recursion limit exceeded.
def test1(ops: Ops[? <: TypedArray[?, ?]]) = ops.typedArray()
def test2(ops: Ops[? <: TypedArray[? <: AnyRef, ?]]) = ops.typedArray() // ok, was error: Recursion limit exceeded.
}
46 changes: 46 additions & 0 deletions tests/pos/i24094.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class TyreCompiler[IN <: Tuple, R](val context: Context[R *: IN]):
import context.*

private class Loop[IS <: Tuple, T](
val context: Context[T *: IS],
innerAutomaton: context.Automaton[IS]
) {
private lazy val fixableStates: List[RefinedInitNonAcceptingState[T, IS]] =
innerAutomaton.initStates.map { case is: context.InitNonAcceptingState[?] =>
new RefinedInitNonAcceptingState[T, IS] {
type Tail = is.OS
type OS = List[T] *: Tail
lazy val state = new NonAcceptingState:
val next: List[Transition[OS]] =
is.state.next.flatMap(fixTransition[is.OS](fixableStates, _))
}
}

private def fixTransition[S <: Tuple](
initStates: List[RefinedInitNonAcceptingState[T, IS]],
transition: context.Transition[S]
): List[Transition[List[T] *: S]] = ???

private trait RefinedInitNonAcceptingState[T, IS <: Tuple] extends InitNonAcceptingState[IS]:
type Tail <: Tuple
type OS = List[T] *: Tail
lazy val state: NonAcceptingState[OS]
}

private class Context[R <: Tuple]:
sealed trait State[S <: Tuple]:
val next: List[Transition[S]]
trait NonAcceptingState[S <: Tuple] extends State[S]

sealed trait Transition[IS <: Tuple]:
def state: State[?]

sealed trait InitState[-IS <: Tuple]:
type OS <: Tuple
def state: State[?]

trait InitNonAcceptingState[-IS <: Tuple] extends InitState[IS]:
lazy val state: NonAcceptingState[OS]

trait Automaton[-IS <: Tuple]:
val initStates: List[InitState[IS]]
36 changes: 36 additions & 0 deletions tests/pos/i24097-a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
trait <[+A, -S]
object `<`:
extension [A, S](v: A < S) def map[B, S2](f: A => B < S2): B < (S & S2) = ???

def lift[A, S](v: A): A < S = ???

abstract class ArrowEffect[-Input[_], +Output[_]]
object ArrowEffect:
inline def handleCatching[I[_], O[_], E <: ArrowEffect[I, O], A, B, S, S2, S3](
v: A < (E & S)
): B < (S & S2 & S3) = ???

trait Result[+E, +A]
object Result:
def succeed[E, A](value: A): Result[E, A] = ???

abstract class Error[+E]

type Const[A] = [B] =>> A
sealed trait Abort[-E] extends ArrowEffect[Const[Error[E]], Const[Unit]]
object Abort:
inline def runWith[E, A, S, ER, B, S2](v: A < (Abort[E | ER] & S)) =
ArrowEffect.handleCatching[
Const[Error[E]],
Const[Unit],
Abort[E],
Result[E, A],
B,
Abort[ER] & S,
Abort[ER] & S,
S2
](
v.map:
value => lift:
Result.succeed[E, A](value)
)
25 changes: 25 additions & 0 deletions tests/pos/i24097-b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
trait <[+A, -S]

trait TypeMap[+A]:
def union[B](that: TypeMap[B]): TypeMap[A & B] = ???

trait Tag[E]
trait ContextEffect[+A]
object ContextEffect:
def handle[A, E <: ContextEffect[A], B, S](effectTag: Tag[E], ifDefined: A => A)(
v: B < (E & S)
): B < S = ???

sealed trait Env[+R] extends ContextEffect[TypeMap[R]]
object Env:
def runAll[R >: Nothing, A, S, VR](
env: TypeMap[R],
tag: Tag[Env[R]]
)(
v: A < (Env[R & VR] & S)
) =
ContextEffect.handle(
tag,
_.union(env)
)(v): A < (Env[VR] & S)
???
Loading