Skip to content

TypeTag of path-dependent type cannot be inferred by the compiler #12113

Open
@tribbloid

Description

@tribbloid

This problem has been recorded in:

https://stackoverflow.com/questions/59708880/in-scala-why-it-is-impossible-to-infer-typetag-from-type-alias-or-dependent-typ

A similar problem that may have the same cause has been reported in:

fthomas/singleton-ops#152

reproduction steps

using Scala 2.13.3 OR 2.12.11,

object TTagFromPathDependentType {

  import universe._

  def infer(): Unit = {
    type U = (Int, String)

    val ttg1 = implicitly[TypeTag[(Int, String)]]

    val ttg2 = implicitly[TypeTag[U]]
  }
}

problem

Compiler throws the following error:

[Error] /home/peng/git/shapesafe/spike/src/main/scala/edu/umontreal/kotlingrad/spike/arity/TTagFromPathDependentType.scala:15: implicit error;
!I e (No TypeTag available for U): TypeTag[(Int,String)]
one error found

FAILURE: Build failed with an exception.

If the compiler is working properly it should have easily found the TypeTag for (Int, String)

Metadata

Metadata

Assignees

No one assigned

    Labels

    dealiascompiler isn't dealiasing when it should, or vice versareflection

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions