Skip to content

Commit f4de761

Browse files
authored
Merge pull request #4894 from dotty-staging/fix-#4891
Fix #4891: Make scala.quoted.Expr covariant
2 parents 429c1f2 + 71052cc commit f4de761

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

library/src/scala/quoted/Expr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala.quoted
22

33
import scala.runtime.quoted.Unpickler.Pickled
44

5-
sealed abstract class Expr[T] {
5+
sealed abstract class Expr[+T] {
66
final def unary_~ : T = throw new Error("~ should have been compiled away")
77

88
/** Evaluate the contents of this expression and return the result.

tests/neg/i4774a.scala renamed to tests/pos/i4774a.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import scala.quoted._
44
object Test {
55
def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{
66
val y: ~t = ~x
7-
~loop( // error: inferred loop[~t] where T should be used
8-
'(y)
9-
)
7+
~loop('(y))
108
}
119
}

tests/pos/i4891.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
object Test {
4+
def foo: Expr[Option[String]] = '(None)
5+
}

0 commit comments

Comments
 (0)