diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 12ef1915e933..67b7d2fe6d9d 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -2,7 +2,7 @@ package scala.quoted import scala.runtime.quoted.Unpickler.Pickled -sealed abstract class Expr[T] { +sealed abstract class Expr[+T] { final def unary_~ : T = throw new Error("~ should have been compiled away") /** Evaluate the contents of this expression and return the result. diff --git a/tests/neg/i4774a.scala b/tests/pos/i4774a.scala similarity index 61% rename from tests/neg/i4774a.scala rename to tests/pos/i4774a.scala index 1c9fff1ef65f..6a1f6ec0588e 100644 --- a/tests/neg/i4774a.scala +++ b/tests/pos/i4774a.scala @@ -4,8 +4,6 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y: ~t = ~x - ~loop( // error: inferred loop[~t] where T should be used - '(y) - ) + ~loop('(y)) } } diff --git a/tests/pos/i4891.scala b/tests/pos/i4891.scala new file mode 100644 index 000000000000..e59e57968765 --- /dev/null +++ b/tests/pos/i4891.scala @@ -0,0 +1,5 @@ +import scala.quoted._ + +object Test { + def foo: Expr[Option[String]] = '(None) +}