Skip to content
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

Incrementally compiled code that iterates over Mirror's MirroredElemTypes in a macro sometimes dealiases an opaque type to its underlying type #21430

Open
arainko opened this issue Aug 24, 2024 · 0 comments

Comments

@arainko
Copy link
Contributor

arainko commented Aug 24, 2024

Compiler version

3.3.3

Minimized code

The best I could do is a branch on a public project: https://github.com/arainko/ducktape/tree/issue-197-repro

Steps to reproduce:

  1. Clone the repository with the branch set to issue-197-repro
  2. Navigate to repro.scala (the code should compile if you clean-compiled, it also outputs a compiletime message of the types taken from the destination's Mirror.MirroredElemTypes which reads: Field types: String, Ident)
  3. Add a newline anywhere inside object demo
  4. The code ceases to compile with this ducktape-specific error:
    Configuration is not valid since the provided type (io.github.arainko.ducktape.scoped.Ident) is not a subtype of java.lang.String @ To.id - it gives us a hint towards what went wrong.
    The aforementioned compiletime message changes to Field types: String, String (Ident is an opaque type over String) - we can deduce that Ident was dealiased to String despite the code being outside a scope where this identity is visible.
  5. Clean-compiling makes it behave properly once again.

What's worth noting is that I wasn't able to reproduce the correct behavior of the code if I copy-pasted the offending file to a separate project with ducktape pulled in as a dep. It always fails no matter what I do (on 3.3.3 and 3.5.0).

The code that does the tuple decomposition doesn't do anything that I'd deem 'dangerous' in relation to opaque types (it doesn't .dealias, .widen etc) - it only summons the Mirror of a given type and pattern matches over it (here )

This issue was first reported here: arainko/ducktape#197

Expectation

scoped.Ident is not dealiased to its underlying type.

@arainko arainko added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 24, 2024
@Gedochao Gedochao added stat:needs minimization Needs a self contained minimization area:typeclass-derivation and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants