We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Maybe related to #13942
3.1.2-RC1-bin-20211222-c94b333-NIGHTLY-git-c94b333
import scala.quoted.* object Test { inline def foo[A, M[_]]: Unit = ${ fooImpl[A, M] } private def fooImpl[A, M[_]]( using q: Quotes, tc: Type[M], pt: Type[A] ): Expr[Unit] = { import q.reflect.* val ptpe = TypeRepr.of[A] val neededGivenType = TypeRepr.of[M](using tc).appliedTo(ptpe) val neededGiven: Option[Term] = Implicits.search(neededGivenType) match { case suc: ImplicitSearchSuccess => Some(suc.tree) case _ => None } println(neededGiven.mkString) println("---") println(neededGiven.map(_.show).mkString) '{ () } } } // --- /** Type level evidence that type `A` is not type `B`. */ final class IsNot[A, B]() { override val toString = "not" } object IsNot { implicit def defaultEvidence[A, B]: IsNot[A, B] = new IsNot[A, B]() @annotation.implicitAmbiguous("Could not prove type ${A} is not (IsNot) ${A}") implicit def ambiguousEvidence1[A]: IsNot[A, A] = null implicit def ambiguousEvidence2[A]: IsNot[A, A] = null } // --- sealed trait SomeTypeclass[T] object SomeTypeclass extends SomeTypeclassLowPrio { given collection[T, Repr <: Iterable[T]]( using SomeTypeclass[T], Repr IsNot Option[T] ): SomeTypeclass[Repr] = new SomeTypeclass[Repr] {} } sealed trait SomeTypeclassLowPrio { given int: SomeTypeclass[Int] = new SomeTypeclass[Int] {} }
Then when testing:
Test.foo[Seq[Int], SomeTypeclass]
Apply(TypeApply(Ident(collection),List(TypeTree[TypeVar(TypeParamRef(T) -> TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int))], TypeTree[TypeVar(TypeParamRef(Repr) -> AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),trait Seq),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int))))])),List(Ident(int), TypeApply(Ident(defaultEvidence),List(TypeTree[TypeVar(TypeParamRef(A) -> AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),trait Seq),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int))))], TypeTree[TypeVar(TypeParamRef(B) -> AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Option),List(TypeVar(TypeParamRef(T) -> TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)))))])))) --- -- Error: ---------------------------------------------------------------------- 1 |Test.foo[Seq[Int], SomeTypeclass] |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |Exception occurred while executing macro expansion. |scala.MatchError: TypeVar(TypeParamRef(T) -> TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)) (of class dotty.tools.dotc.core.Types$TypeVar) | at scala.quoted.runtime.impl.printers.Extractors$ExtractorsPrinter.visitType(Extractors.scala:242) | at scala.quoted.runtime.impl.printers.Extractors$.showType(Extractors.scala:12) | at scala.quoted.runtime.impl.QuotesImpl$$anon$18.show(QuotesImpl.scala:2987) | at scala.quoted.runtime.impl.QuotesImpl$$anon$18.show(QuotesImpl.scala:2986) | at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.show(QuotesImpl.scala:1708) | at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.show(QuotesImpl.scala:1708)
Successfully show the term representation.
Note that if updating given collection as below, it works fine.
given collection
given collection[T, Repr <: Iterable[T]]( using SomeTypeclass[T] // REMOVED: Repr IsNot Option[T] ): SomeTypeclass[Repr] = new SomeTypeclass[Repr] {}
The text was updated successfully, but these errors were encountered:
Remove TypeApply TypeVars
88d85a7
Fixes scala#14185
Remove reflect TypeApply TypeVars
e491319
be4f651
nicolasstucki
Successfully merging a pull request may close this issue.
Maybe related to #13942
Compiler version
3.1.2-RC1-bin-20211222-c94b333-NIGHTLY-git-c94b333
Minimized code
Then when testing:
Output
Expectation
Successfully show the term representation.
Note that if updating
given collection
as below, it works fine.The text was updated successfully, but these errors were encountered: