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/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ trait Implicits { self: Typer =>

formal.argTypes match {
case arg :: Nil =>
fullyDefinedType(arg.dealias, "ValueOf argument", span) match {
fullyDefinedType(arg.dealias, "ValueOf argument", span).normalized match {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it should be instead

fullyDefinedType(arg.dealias.normalized, "ValueOf argument", span)
// or
fullyDefinedType(arg.normalized.dealias, "ValueOf argument", span)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's most general this way.

case ConstantType(c: Constant) =>
success(Literal(c))
case TypeRef(_, sym) if sym == defn.UnitClass =>
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typelevel0.scala
matchtype.scala
6322.scala
i7087.scala
i7868.scala

# Opaque type
i5720.scala
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/run-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ t8905
t10889
macros-in-same-project1
i5257.scala
i7868.scala
enum-java
38 changes: 38 additions & 0 deletions tests/pos/i7868.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import scala.compiletime._

final case class Coproduct[+Set, +Value, Index <: Int](value: Value & Set, index: Index)

object Coproduct {
opaque type +:[+A, +B] = A | B

trait At[+Set, -Value, Index <: Int] {
def cast: Value <:< Set
}

object At {

given atHead[Head, Tail]: At[Head +: Tail, Head, 0] {
def cast: Head <:< Head +: Tail = summon[Head <:< Head +: Tail]
}

given atTail[Head, Tail, Value, NextIndex <: Int](given atNext: At[Tail, Value, NextIndex]): At[Head +: Tail, Value, S[NextIndex]] {
val cast: Value <:< Head +: Tail = atNext.cast
}

given [A](given A): (() => A)= { () => summon[A]}
}

def upCast[A, B](a: A)(given erased evidence: (A <:< B)): B = a.asInstanceOf[B]

def from[Set, Value, Index <: Int](value: Value)(given erased at: At[Set, Value, Index]): (given ValueOf[Index]) => Coproduct[Set, Value, Index] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the test case slightly to make sure Index was fully defined before looking for ValueOf[Index].

Coproduct[Set, Value, Index](upCast(value: Value)(given at.cast.liftCo[[+X] =>> Value & X]), valueOf[Index])
}

}

object Test extends App {
import Coproduct._

// Error: No singleton value available for scala.compiletime.S[scala.compiletime.S[(0 : Int)]].
val c = from[Set = Int +: String +: Seq[Double] +: Nothing](Nil)
}
8 changes: 8 additions & 0 deletions tests/run/i7868.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.compiletime.S

object Test extends App {
def plusOne[I <: Int](given x: ValueOf[S[I]]): S[I] = x.value
def plusTwo[I <: Int](given x: ValueOf[S[S[I]]]): S[S[I]] = x.value
assert(plusOne[0] == 1)
assert(plusTwo[0] == 2)
}