Skip to content

Quotes are not checked for override errors / @deprecated usage / @experimental usage #17400

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

Open
smarter opened this issue May 3, 2023 · 1 comment
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug

Comments

@smarter
Copy link
Member

smarter commented May 3, 2023

Compiler version

3.3.1-RC1-bin-20230502-dee0065-NIGHTLY

Minimized code

import scala.annotation.experimental
import scala.quoted.*

class A:
  def a: Int = 1

def checkOverride(using Quotes) =
  '{
     class Sub extends A:
       def a: String = ""
     new Sub
   }

class B:
  @deprecated def dep: Int = 1

def checkDeprecated(using Quotes) =
  '{
     val b = new B
     b.dep
   }

@experimental class C

def checkExperimental(using Quotes) =
  '{
     println(new C)
   }

Output

No compiler error

Expectation

  • checkOverride should emit an error since String is not a subtype of Int and the override keyword is missing
  • checkDeprecated should emit a deprecation warning
  • checkExperimental should emit an error since C is experimental.

The fact that we don't check for override errors has weird consequences like in #17398 (comment).

@smarter smarter added itype:bug area:metaprogramming:quotes Issues related to quotes and splices labels May 3, 2023
@smarter smarter changed the title Quotes are not checked for override errors / @deprecated usage / @experimental usagze Quotes are not checked for override errors / @deprecated usage / @experimental usage May 3, 2023
@nicolasstucki
Copy link
Contributor

The issue is that all the code within quotes is pickled and encoded as a TASTy binary in PickleQuoted. Therefore the AST is never seen by the checking phases.

The solution is to keep both the pickled and non-pickled versions of the AST for more phases. The question is in which structure to retain the original AST.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 12, 2023
This enables the checking phases to analyze the contents of quoted
expression.

Fixes scala#17400
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 12, 2023
This enables the checking phases to analyze the contents of quoted
expression.

Fixes scala#15700
Fixes scala#17400
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 17, 2023
This enables the checking phases to analyze the contents of quoted
expression.

Fixes scala#15700
Fixes scala#17400
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 6, 2023
This enables the checking phases to analyze the contents of quoted
expression.

Fixes scala#15700
Fixes scala#17400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants