What is the type of quasiquote that matched type parameters?

Alexander Myltsev

I have a quoasiquote matcher where q"someMethod[$ts]()" where def someMethod[I <: shapeless.HList]()".

Printing ts gives:

List(shapeless.HNil)

or, e.g.

List(String, Int)

Then I try to assign:

val types: List[scala.reflect.api.Types.Type] = ts

that causes compiler error:

[error] type mismatch;
[error]  found   : List[_125.u.Tree] where val _125: scala.reflect.api.QuasiquoteCompat.TypeAppliedExtractor{val u: OpTreeContext.this.c.universe.type}
[error]  required: List[Context.this.c.universe.Type]

How to compose List[scala.reflect.api.Types.Type] from ts?

Travis Brown

As your error message states, ts is a list of trees. More specifically, these will be type trees, and you can extract their types with the tpe method:

val types: List[scala.reflect.api.Types#Type] = ts.map(_.tpe)

Note that I'm using a type projection, since Types is neither a package nor an object, so Types.Type won't work.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Printing type parameters in Rascal

来自分类Dev

What is the difference between type conversion and type assertion?

来自分类Dev

Same template class with type/non-type parameters?

来自分类Dev

KnownType attribute cannot use type parameters

来自分类Dev

Trying to write DRY Scala code with type parameters

来自分类Dev

Confusion about rvalue reference: what is its type?

来自分类Dev

What is the maximum length for keyword type in elasticsearch?

来自分类Dev

what object type/instance to use for synchronization

来自分类Dev

what is the correct way to add type definition for this module

来自分类Dev

Scala Quasiquote吊装

来自分类Dev

Scala quasiquote concatenation

来自分类Dev

Python 3: for a class type, what happens when in is called?

来自分类Dev

What type of padding does python use for RSA module?

来自分类Dev

The parameters dictionary contains a null entry for parameter 'userId' of non-nullable type 'System.Int32' for method

来自分类Dev

CloudFormation模板格式错误:每个Parameters对象必须包含Type成员

来自分类Dev

Dart / Flutter混淆,“对参数使用通用函数类型语法”(use_function_type_syntax_for_parameters)

来自分类Dev

如何使用 UNION 语句在 python 中合并两个 SQLite 表(当前收到“ValueError: parameters are of unsupported type”错误消息)

来自分类Dev

What can be said about the value of fundamental type members of moved from object during move construction?

来自分类Dev

What object type is the instance element parameter pass into the link function of an angular directive?

来自分类Dev

What causes the Android Dalvik java.lang.VerifyError "Invalid reg type for array index"?

来自分类Dev

What is the shortest non-interactive command to type in a prompt, on a fresh Windows 10, that downloads the latest Firefox installer?

来自分类Dev

unordered_map <TYPE,bool>与set <TYPE>

来自分类Dev

Argument type is not assignable to parameter type although it inherits

来自分类Dev

type =“ text / ecmascript”与type =“ text / javascript”

来自分类Dev

type =“ text / ecmascript”与type =“ text / javascript”

来自分类Dev

如何使输入的type =“ tel”用作type =“ password”

来自分类Dev

Type unification with multi-parameter type classes

来自分类Dev

元组<{type 1},{type 2}>作为类?

来自分类Dev

Type definitions and type mismatch in a higher order function

Related 相关文章

  1. 1

    Printing type parameters in Rascal

  2. 2

    What is the difference between type conversion and type assertion?

  3. 3

    Same template class with type/non-type parameters?

  4. 4

    KnownType attribute cannot use type parameters

  5. 5

    Trying to write DRY Scala code with type parameters

  6. 6

    Confusion about rvalue reference: what is its type?

  7. 7

    What is the maximum length for keyword type in elasticsearch?

  8. 8

    what object type/instance to use for synchronization

  9. 9

    what is the correct way to add type definition for this module

  10. 10

    Scala Quasiquote吊装

  11. 11

    Scala quasiquote concatenation

  12. 12

    Python 3: for a class type, what happens when in is called?

  13. 13

    What type of padding does python use for RSA module?

  14. 14

    The parameters dictionary contains a null entry for parameter 'userId' of non-nullable type 'System.Int32' for method

  15. 15

    CloudFormation模板格式错误:每个Parameters对象必须包含Type成员

  16. 16

    Dart / Flutter混淆,“对参数使用通用函数类型语法”(use_function_type_syntax_for_parameters)

  17. 17

    如何使用 UNION 语句在 python 中合并两个 SQLite 表(当前收到“ValueError: parameters are of unsupported type”错误消息)

  18. 18

    What can be said about the value of fundamental type members of moved from object during move construction?

  19. 19

    What object type is the instance element parameter pass into the link function of an angular directive?

  20. 20

    What causes the Android Dalvik java.lang.VerifyError "Invalid reg type for array index"?

  21. 21

    What is the shortest non-interactive command to type in a prompt, on a fresh Windows 10, that downloads the latest Firefox installer?

  22. 22

    unordered_map <TYPE,bool>与set <TYPE>

  23. 23

    Argument type is not assignable to parameter type although it inherits

  24. 24

    type =“ text / ecmascript”与type =“ text / javascript”

  25. 25

    type =“ text / ecmascript”与type =“ text / javascript”

  26. 26

    如何使输入的type =“ tel”用作type =“ password”

  27. 27

    Type unification with multi-parameter type classes

  28. 28

    元组<{type 1},{type 2}>作为类?

  29. 29

    Type definitions and type mismatch in a higher order function

热门标签

归档