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

The AnnotatedType seems not working with ExistentialType in the runtime reflection #10016

Closed
scabug opened this issue Nov 1, 2016 · 10 comments · Fixed by scala/scala#9693
Closed

Comments

@scabug
Copy link

scabug commented Nov 1, 2016

sample code snippet:

object Entice extends App {

  import scala.reflect.runtime.universe._

  def normal0(x: (List[Int] {def value})@SerialVersionUID(1L) with Int {def xxx: Int}) = ???

  def normal(x: (List[T] forSome {type T})@SerialVersionUID(1L) with Int {def xxx: Int}) = ???

  println(typeOf[Entice.type].member(TermName("normal0")).info.paramLists.head.head.info.asInstanceOf[RefinedType].parents.head.getClass)
  println(typeOf[Entice.type].member(TermName("normal")).info.paramLists.head.head.info.asInstanceOf[RefinedType].parents.head.getClass)
}

The output is:


    class scala.reflect.internal.Types$AnnotatedType
    class scala.reflect.internal.Types$ExistentialType

IMO the second line in the output should be AnnotatedType as same as the 1st line, doesn't it?

May i missed something?

@scabug
Copy link
Author

scabug commented Nov 1, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10016?orig=1
Reporter: miao qian (noddle)
Affected Versions: 2.11.8, 2.12.0

@scabug
Copy link
Author

scabug commented Nov 7, 2016

@SethTisue said:
This seems like more of a question than a bug report. I'd suggest asking on Stack Overflow or the mailing lists.

If you become confident this is a bug, it would helpful to have more minimal reproduction. For example, I assume the SerialVersionUID stuff is irrelevant — or is it? What is the minimum code necessary to demonstrate the issue?

@scabug
Copy link
Author

scabug commented Nov 15, 2016

miao qian (noddle) said (edited on Nov 15, 2016 6:06:38 AM UTC):
The simplest code as follows:

scala> class TraceTypeParameters extends scala.annotation.Annotation
defined class TraceTypeParameters

scala> class B[T]
defined class B

scala> val b = new B[Int] {def x = 1}
b: B[Int]{def x: Int} = $anon$1@45658133

scala> b: (B[_])@TraceTypeParameters
res0: B[_] = $anon$1@45658133

The res0 losts associated annotation info.

@scabug
Copy link
Author

scabug commented Nov 15, 2016

miao qian (noddle) said:
If I try as follows, it looks good( there is not any annotation type infomation loss) :

scala> b: (B[_]{def x: Int})@TraceTypeParameters
res1: B[_]{def x: Int} @TraceTypeParameters = $anon$1@45658133

scala> b: (B[Int])@TraceTypeParameters
res2: B[Int] @TraceTypeParameters = $anon$1@45658133

@scabug
Copy link
Author

scabug commented Nov 15, 2016

miao qian (noddle) said:
I think it is a bug, and the suspected code located in the line 211 of scala.reflect.internal.Types class file, which discards the annotation infos.

@scabug
Copy link
Author

scabug commented Nov 26, 2016

miao qian (noddle) said:
ping...

@scabug
Copy link
Author

scabug commented Dec 10, 2016

@SethTisue said:
I see this is a regression since 2.10, where we see:

scala> import scala.language.existentials
import scala.language.existentials

scala> b: (B[_])@TraceTypeParameters
res1: B[_$1] @TraceTypeParameters forSome { type _$1 } = $anon$1@2957fcb0

re: line 211, I'm not sure what line you mean of what file — can you link to it on GitHub?

@scabug
Copy link
Author

scabug commented Dec 22, 2016

miao qian (noddle) said (edited on Dec 22, 2016 9:43:14 AM UTC):
sorry for late, you can check my commit in here , and may i create a PR for it?

@scabug
Copy link
Author

scabug commented Dec 22, 2016

@adriaanm said:
Thanks for your report and for identifying the problem! I think the regression was caused by scala/scala#1900. I'll submit a PR that reverts it. I don't think the two new overrides in your commit are needed for the compiler. Are they motivated by a compiler plugin you are working on?

@scabug
Copy link
Author

scabug commented Dec 23, 2016

@adriaanm said:
scala/scala#5613

@scabug scabug added this to the 2.12.3 milestone Apr 7, 2017
@retronym retronym modified the milestones: 2.12.3, 2.12.4 Jul 8, 2017
@adriaanm adriaanm modified the milestones: 2.12.4, 2.12.5 Oct 10, 2017
@SethTisue SethTisue modified the milestones: 2.12.5, Backlog Mar 1, 2018
@adriaanm adriaanm removed their assignment Sep 28, 2018
joroKr21 added a commit to joroKr21/scala that referenced this issue Jul 11, 2021
Copied from scala#5613, credit goes to @adriaanm
joroKr21 added a commit to joroKr21/scala that referenced this issue Jul 11, 2021
Copied from scala#5613, credit goes to @adriaanm
@dwijnand dwijnand added has PR and removed has PR labels Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants