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/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
// leave the original tuple type; don't mix with & TupleXXL which would only obscure things
pt
case _ =>
pt & body1.tpe
body1.tpe & pt
val sym = newPatternBoundSymbol(name, symTp, tree.span)
if (pt == defn.ImplicitScrutineeTypeRef || tree.mods.is(Given)) sym.setFlag(Given)
if (ctx.mode.is(Mode.InPatternAlternative))
Expand Down
6 changes: 3 additions & 3 deletions tests/neg/i13780-1.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/i13780-1.scala:38:24 ----------------------------------------------------------
38 | case x: (h *: t) => x.head // error
| ^^^^^^
| Found: Tuple.Head[VS & h *: t]
| Found: Tuple.Head[h *: t & VS]
| Required: h
| Note that implicit conversions were not tried because the result of an implicit conversion
| must be more specific than h
Expand All @@ -13,8 +13,8 @@
|
| Note: a match type could not be fully reduced:
|
| trying to reduce Tuple.Head[VS & h *: t]
| failed since selector VS & h *: t
| trying to reduce Tuple.Head[h *: t & VS]
| failed since selector h *: t & VS
| does not uniquely determine parameter x in
| case x *: _ => x
| The computed bounds for the parameter are:
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i24096.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/i24096.scala:8:31 -------------------------------------------------------------
8 | case r: Terminal[?] => r // error
| ^
| Found: (r : Pull[F, O, Unit] & Pull.Terminal[_])
| Found: (r : Pull.Terminal[_] & Pull[F, O, Unit])
| Required: Pull[F2, O2, Unit]
|
| where: F is a type in class StreamPullOps with bounds <: [_²] =>> Any
Expand Down
31 changes: 31 additions & 0 deletions tests/pos/i24038a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
final class MBufferLong:
final def +=(elem: Long): this.type = ???

type M[Tup <: Tuple] <: Tuple = Tup match
case EmptyTuple => EmptyTuple
case h *: t => BufferOf[h] *: M[t]

type M2[T <: Tuple] <: Tuple = (T, M[T]) match
case (h *: t, a *: b) => BufferOf[h] *: M2[t]
case (EmptyTuple, EmptyTuple) => EmptyTuple
case (_, EmptyTuple) => EmptyTuple
case (EmptyTuple, _) => EmptyTuple

type BufferOf[T] = T match
case Long => MBufferLong

inline def append[T](t: T, buffer: BufferOf[T]): BufferOf[T] =
inline (t, buffer) match
case (x: Long, y: BufferOf[Long]) => y.+=(x)
buffer

transparent inline def appendBuffers[T <: Tuple](t: T, buffers: M[T]): M2[T] = {
inline (t, buffers) match
case abcd: ((h *: t), bh *: bt) =>
val (hh *: tt, bh *: bt) = abcd
val x: BufferOf[h] = append[h](hh, bh.asInstanceOf[BufferOf[h]])
x *: appendBuffers[t](tt, bt.asInstanceOf[M[t]])
case _: (EmptyTuple, EmptyTuple) => EmptyTuple
case _: (_, EmptyTuple) => EmptyTuple
case _: (EmptyTuple, _) => EmptyTuple
}
12 changes: 12 additions & 0 deletions tests/pos/i24038b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
final class MBufferLong

type M[Tup <: Tuple] <: Tuple = Tup match
case EmptyTuple => EmptyTuple
case h *: t => MBufferLong *: M[t]

def appendBuffers[T <: Tuple](t: T, buffers: M[T]): Unit = {
(t, buffers) match
case abcd: (h *: t, bh *: bt) =>
val (hh *: tt, bh *: bt) = abcd
summon[hh.type <:< h]
}
4 changes: 2 additions & 2 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -4991,8 +4991,8 @@ _empty_/Txn# => trait Txn [typeparam T <: Txn[T]] extends Object { self: Txn[T]
_empty_/Txn#[T] => typeparam T <: Txn[T]
_empty_/Txn#`<init>`(). => primary ctor <init> [typeparam T <: Txn[T]](): Txn[T]
local0 => val local out: Repr[Out]
local1 => val local inObj: Repr[In] & Obj[In]
local2 => val local outObj: Repr[Out] & Obj[Out]
local1 => val local inObj: Obj[In] & Repr[In]
local2 => val local outObj: Obj[Out] & Repr[Out]

Occurrences:
[1:6..1:9): Txn <- _empty_/Txn#
Expand Down
Loading