Skip to content

Accommodate adapted Scala 2 annotation value #17516

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented May 15, 2023

Fixes #17515

When unpickling a Scala 2 annotation argument, the annotation constructor is overloaded and the argument winds up adapted, "constant".asInstanceOf[String]. In Erasure.adaptToType, help it realize that the type is conforming.

This allows pulling the constant arg out. Edit: just go back to ignoring the cast in ad hoc special case.

Just for compileTimeOnly, use an amended argument[Adapted]ConstantString to ignore asInstanceOf. (Presumably that is not typed as a constant type. Does that mean argumentConstantString would benefit from the fix?)

@som-snytt som-snytt closed this May 16, 2023
@som-snytt som-snytt reopened this May 16, 2023
@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from 4624695 to 897d7a7 Compare May 16, 2023 04:17
@som-snytt som-snytt closed this May 16, 2023
@som-snytt som-snytt reopened this May 16, 2023
@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from 897d7a7 to 4878939 Compare May 16, 2023 08:53
@som-snytt som-snytt marked this pull request as ready for review June 1, 2023 20:48
@som-snytt som-snytt marked this pull request as draft April 5, 2024 01:22
@som-snytt som-snytt closed this Sep 15, 2024
@som-snytt som-snytt reopened this Apr 14, 2025
@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from 4878939 to 86a3225 Compare April 14, 2025 15:11
@som-snytt som-snytt marked this pull request as ready for review April 14, 2025 15:13
@som-snytt
Copy link
Contributor Author

looks spurious

Test 'tests\run-tasty-inspector\i14785.scala' failed with output:               
List(out\runWithCompiler\run-tasty-inspector\i14785, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.16\scala-library-2.13.16.jar, C:\actions-runner2\_work\scala3\scala3\library\..\out\bootstrap\scala3-library-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-library_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.16\scala-library-2.13.16.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\modules\scala-asm\9.7.1-scala-1\scala-asm-9.7.1-scala-1.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\jline\jline-terminal\3.29.0\jline-terminal-3.29.0.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\jline\jline-reader\3.29.0\jline-reader-3.29.0.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-sbt\compiler-interface\1.10.7\compiler-interface-1.10.7.jar, C:\actions-runner2\_work\scala3\scala3\interfaces\target\scala3-interfaces-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\library\..\out\bootstrap\scala3-library-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-library_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\tasty\..\out\bootstrap\tasty-core-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\tasty-core_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\compiler\..\out\bootstrap\scala3-compiler-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-compiler_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\tasty-inspector\..\out\bootstrap\scala3-tasty-inspector\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-tasty-inspector_3-3.7.1-RC1-bin-SNAPSHOT.jar, out\runWithCompiler\run-tasty-inspector\i8389, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.16\scala-library-2.13.16.jar, C:\actions-runner2\_work\scala3\scala3\library\..\out\bootstrap\scala3-library-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-library_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.16\scala-library-2.13.16.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\modules\scala-asm\9.7.1-scala-1\scala-asm-9.7.1-scala-1.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\jline\jline-terminal\3.29.0\jline-terminal-3.29.0.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\jline\jline-reader\3.29.0\jline-reader-3.29.0.jar, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-sbt\compiler-interface\1.10.7\compiler-interface-1.10.7.jar, C:\actions-runner2\_work\scala3\scala3\interfaces\target\scala3-interfaces-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\library\..\out\bootstrap\scala3-library-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-library_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\tasty\..\out\bootstrap\tasty-core-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\tasty-core_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\compiler\..\out\bootstrap\scala3-compiler-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-compiler_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:\actions-runner2\_work\scala3\scala3\tasty-inspector\..\out\bootstrap\scala3-tasty-inspector\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-tasty-inspector_3-3.7.1-RC1-bin-SNAPSHOT.jar, out\runWithCompiler\run-tasty-inspector\isSuperAccessor, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.16\scala-library-2.13.16.jar, C:\actions-runner2\_work\scala3\scala3\library\..\out\bootstrap\scala3-library-bootstrapped\scala-3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped\scala3-library_3-3.7.1-RC1-bin-SNAPSHOT.jar, C:

@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from 86a3225 to ef2ffb8 Compare April 17, 2025 17:09
@som-snytt som-snytt marked this pull request as draft April 29, 2025 03:05
@som-snytt
Copy link
Contributor Author

This seems to be an artifact of compilation by Scala 2, either the way Scala 2 writes the attribute or the way Scala 3 unpickles it.

@som-snytt
Copy link
Contributor Author

I don't know yet if this is a separate issue:

4 |@implicitNotFound("nope": @nowarn)
  |                  ^^^^^^^^^^^^^^^
  |            @implicitNotFound requires constant expressions as a parameter

It compiles with 2 and is consumed correctly by 3.

@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from ef2ffb8 to 1cb905f Compare August 3, 2025 02:14
@som-snytt som-snytt force-pushed the issue/17515-CTO-Unit branch from 1cb905f to 8203c20 Compare August 3, 2025 07:28
@som-snytt som-snytt changed the title Accommodate quasi-constant annotation Accommodate adapted Scala 2 annotation value Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strangely omitted compileTimeOnly message for Unit companion
1 participant