Skip to content

Fix #6588: Dealias inferred quoted types #6599

New issue

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

Merged
merged 3 commits into from
Jun 5, 2019

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

def synthesizedTypeTag(formal: Type): Tree = {
def quotedType(t: Type) = {
if (StagingContext.level == 0)
ctx.compilationUnit.needsStaging = true // We will need to run ReifyQuotes
ref(defn.InternalQuoted_typeQuote).appliedToType(t)
}
formal.argInfos match {
case arg :: Nil if !arg.typeSymbol.is(Param) =>
object bindFreeVars extends TypeMap {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This TypeMap is completely useless here. This is already performed by the PCP check in the Staging phase which emits errors with extra level information if the implicit is not found.

foo[V]

type B = V => T
foo[B]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code generated for the type tags is now

def main: Int = 
      {
        type S = Int
        {
          val evidence$1: quoted.Type[Int] = scala.quoted.Type.IntTag
          10:Int
        }
        {
          val evidence$1: quoted.Type[Int] = scala.quoted.Type.IntTag
          10:Int
        }
        type T = Function1[Int, Int]
        {
          val evidence$1: quoted.Type[Int => Int] = '[Int => Int]
          10:Int
        }
        {
          val evidence$1: quoted.Type[Int => Int] = '[Int => Int]
          10:Int
        }
        type U = List[Int]
        {
          val evidence$1: quoted.Type[List[Int]] = '[List[Int]]
          10:Int
        }
        {
          val evidence$1: quoted.Type[List[Int]] = '[List[Int]]
          10:Int
        }
        type N = List
        {
          val evidence$1: quoted.Type[List] = '[List]
          10:Int
        }
        {
          val evidence$1: quoted.Type[List] = '[List]
          10:Int
        }
        type V = List[S]
        {
          val evidence$1: quoted.Type[List[Int]] = '[List[Int]]
          10:Int
        }
        type B = Function1[V, T]
        {
          val evidence$1: quoted.Type[List[Int] => Int => Int] = 
            '[List[Int] => Int => Int]
          10:Int
        }
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the second commit, we get

      ...
      type V = List[S]
      {
        10:Int
      }
      type B = Function1[V, T]
      {
        10:Int
      }

@nicolasstucki nicolasstucki marked this pull request as ready for review June 4, 2019 15:27
@nicolasstucki nicolasstucki requested a review from odersky June 4, 2019 15:27
@@ -388,7 +388,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
case New(_) | Closure(_, _, _) =>
Pure
case TypeApply(fn, _) =>
if (fn.symbol.is(Erased)) Pure else exprPurity(fn)
if (fn.symbol.is(Erased) || fn.symbol == defn.InternalQuoted_typeQuote) Pure else exprPurity(fn)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if we could find a more systematic way to do this. Ideally, we could mark typeQuote to be a pure function. We have a flag for that (it's StableRealizable), but so far this cannot be set from source.

Maybe leave a TODO that we should do the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we have some internal flag to mark those methods?

@odersky odersky assigned nicolasstucki and unassigned odersky Jun 5, 2019
@nicolasstucki
Copy link
Contributor Author

Rebased

@nicolasstucki nicolasstucki merged commit fa62051 into scala:master Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants