Skip to content
Draft
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
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,11 @@ object ProtoTypes {
override def eql(that: Type): Boolean = that match
case that: ViewProto => (argType eq that.argType) && (resType eq that.resType)
case _ => false

// equals comes from case class; no need to redefine

override def fold[T](x: T, ta: TypeAccumulator[T])(using Context): T =
ta(x, argType)
}

object ViewProto {
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/17305.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/17305.scala:15:47 -------------------------------------------------------------
15 | .use((pair) => myAssert(pair)(someAssertion(2))) // error
| ^^^^^^^^^^^^^^^^
| Found: Assertion[Int]
| Required: Assertion[Long]
|
| longer explanation available when compiling with `-explain`
37 changes: 37 additions & 0 deletions tests/neg/17305.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
trait Wrapper[A1] {
def use(a: A1 => Unit): Unit
}

trait Assertion[A2] {}

def hideTypeInOut[A3](
c1: A3
)(using
hider: HideAInOut[A3]
): Wrapper[hider.Out] = ???

def entryPoint(): Unit = {
hideTypeInOut(1L)
.use((pair) => myAssert(pair)(someAssertion(2))) // error
}

private def myAssert[A4](a: A4)(assertion: Assertion[A4]): Unit = ()

// This should be Unit or generic, but let compiler figure it out
private def someAssertion(i: Int): Assertion[Int] = ???

trait HideAInOut[-A] {
type Out
def get(left: A): Out
}

object HideAInOut {

type Out[HideA, HideB] = HideAInOut[HideA] { type Out = HideB }

given [ImplicitA]: HideAInOut.Out[ImplicitA, ImplicitA] =
new HideAInOut[ImplicitA] {
type Out = ImplicitA
def get(left: ImplicitA): Out = left
}
}
Loading