Skip to content

tasty-reflect: Inspecting type tree fails when a macro is called inside a block or a non-type ascripted method #8764

Closed
@neko-kai

Description

@neko-kai

To reproduce execute:

git clone https://github.com/zio/izumi-reflect.git
cd izumi-reflect
git checkout feature/dotty-macro-expansion-fails-when-not-inside-type-ascripted-method
sbt '++0.24.0-bin-20200420-c560211-NIGHTLY test:compile'

Output

[error] 26 |      val bazTag = LTT[Baz]
[error]    |                   ^^^^^^^^
[error]    |Exception occurred while executing macro expansion.
[error]    |scala.NotImplementedError: an implementation is missing
[error]    |	at scala.Predef$.$qmark$qmark$qmark(Predef.scala:347)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectSymbol(Inspector.scala:120)
[error]    |	at izumi.reflect.dottyreflection.Inspector.prefixOf(Inspector.scala:132)
[error]    |	at izumi.reflect.dottyreflection.Inspector.asNameRefSym(Inspector.scala:219)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectSymbol(Inspector.scala:113)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectTree(Inspector.scala:107)
[error]    |	at izumi.reflect.dottyreflection.Inspector.buildTypeRef(Inspector.scala:33)
[error]    |	at izumi.reflect.dottyreflection.TypeInspections$.apply(TypeInspections.scala:10)
[error]    |	at izumi.reflect.dottyreflection.Inspect$.inspectAny(Inspect.scala:21)
[error]    |
[error]    | This location contains code that was inlined from CurrentDottySupportExtentTest.scala:26
[error]    | This location contains code that was inlined from package.scala:73
[error] -- Error: /private/tmp/izumi-reflect/izumi-reflect/izumi-reflect/src/test/scala/izumi/reflect/test/CurrentDottySupportExtentTest.scala:27:23
[error] 27 |      val bazTag2 = LTT[Baz]
[error]    |                    ^^^^^^^^
[error]    |Exception occurred while executing macro expansion.
[error]    |scala.NotImplementedError: an implementation is missing
[error]    |	at scala.Predef$.$qmark$qmark$qmark(Predef.scala:347)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectSymbol(Inspector.scala:120)
[error]    |	at izumi.reflect.dottyreflection.Inspector.prefixOf(Inspector.scala:132)
[error]    |	at izumi.reflect.dottyreflection.Inspector.asNameRefSym(Inspector.scala:219)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectSymbol(Inspector.scala:113)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectTree(Inspector.scala:107)
[error]    |	at izumi.reflect.dottyreflection.Inspector.buildTypeRef(Inspector.scala:33)
[error]    |	at izumi.reflect.dottyreflection.TypeInspections$.apply(TypeInspections.scala:10)
[error]    |	at izumi.reflect.dottyreflection.Inspect$.inspectAny(Inspect.scala:21)
[error]    |
[error]    | This location contains code that was inlined from CurrentDottySupportExtentTest.scala:27
[error]    | This location contains code that was inlined from package.scala:73
[error] -- Error: /private/tmp/izumi-reflect/izumi-reflect/izumi-reflect/src/test/scala/izumi/reflect/test/CurrentDottySupportExtentTest.scala:29:23
[error] 29 |      val barXTag = LTT[Bar[X]]
[error]    |                    ^^^^^^^^^^^
[error]    |Exception occurred while executing macro expansion.
[error]    |scala.NotImplementedError: an implementation is missing
[error]    |	at scala.Predef$.$qmark$qmark$qmark(Predef.scala:347)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectSymbol(Inspector.scala:120)
[error]    |	at izumi.reflect.dottyreflection.Inspector.prefixOf(Inspector.scala:132)
[error]    |	at izumi.reflect.dottyreflection.Inspector.asNameRefSym(Inspector.scala:219)
[error]    |	at izumi.reflect.dottyreflection.Inspector.asNameRef(Inspector.scala:212)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectTType(Inspector.scala:66)
[error]    |	at izumi.reflect.dottyreflection.Inspector.inspectTree(Inspector.scala:105)
[error]    |	at izumi.reflect.dottyreflection.Inspector.buildTypeRef(Inspector.scala:33)
[error]    |	at izumi.reflect.dottyreflection.TypeInspections$.apply(TypeInspections.scala:10)
[error]    |	at izumi.reflect.dottyreflection.Inspect$.inspectAny(Inspect.scala:21)
[error]    |
[error]    | This location contains code that was inlined from CurrentDottySupportExtentTest.scala:29
[error]    | This location contains code that was inlined from package.scala:73

Expectation

Compilation succeeds if the commented out wrappng method def test(): Unit = { ... } is uncommented.

That is, the content of the quoted.Type[_] value depends directly on whether or not the LTT inline method is called inside a def test or inside the class body, even though the types referred to are defined inside the current block in both situations. Moreover if the inline calls are placed inside a method, but without a type ascription, def test() = { ... }, the result is the same error.

/cc @nicolasstucki

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions