Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SAM types to contain match alias refinements #20092

Merged
merged 2 commits into from
Apr 5, 2024
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/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5892,7 +5892,7 @@ object Types extends TypeUtils {

/** Copy type aliases refinements to `toTp` from `fromTp` */
def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match
case RefinedType(fromParent, name, info: TypeAlias) if tp0.member(name).exists =>
case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists =>
val parent1 = withRefinements(toType, fromParent)
RefinedType(toType, name, info)
case _ => toType
Expand Down
32 changes: 32 additions & 0 deletions tests/pos/i20080.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

trait Zippable[-A, -B]:
type Out
def zip(left: A, right: B): Out

object Zippable extends ZippableLowPrio:
given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) =
(left, right) => left :* right

trait ZippableLowPrio:
given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) =
(left, right) => (left, right)


object Minimization:

trait Fun1:
type Out
def apply(x: Any): Out

type M[X] = X match
case String => X

def test[A] =

val _: Fun1 { type Out = M[A] } = new Fun1:
type Out = M[A]
def apply(x: Any): Out = ???

val _: Fun1 { type Out = M[A] } = x => ???

val _: Fun1 { type Out = A match {case String => A} } = x => ???
Loading