scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
231 stars 21 forks source link

Disable constant folding of classOf in presentation compiler #9477

Open scabug opened 8 years ago

scabug commented 8 years ago

To merge this:

https://github.com/retronym/scala/commit/689b6db

We need to adapt:

https://github.com/scala-ide/scala-ide/blob/4.2.0-rc3/org.scala-ide.sdt.core/src/org/scalaide/core/internal/jdt/model/ScalaStructureBuilder.scala#L45

So as to avoid these test failures in scala-ide

Failed tests:   throwsAnnotationOfClassConstructorsAndMethodsAreAvailableInJava_t100105(org.scalaide.core.structurebuilder.StructureBuilderTest): 
  throwsAnnotationOfTraitMethodsAreAvailableInJava_t1000707(org.scalaide.core.structurebuilder.StructureBuilderTest): 
  throwsAnnotationOfTraitMethodsAreAvailableInJava_t1000800(org.scalaide.core.structurebuilder.StructureBuilderTest): 

I tried:

      val typeNames = for(AnnotationInfo(_, List(t), _) <- throwsAnnotations)
        yield {
          javaTypeNameMono(t.tpe).toCharArray
        }

But this didn't work immediately, so I dropped the change from my PR and opened this ticket.

While we're looking at this, we should see if the IDE also needs an update for the recently added variant of @throws that that uses a type parameter:


scala> tb.typecheck(q"@throws[String] def foo = 0")
res4: tb.u.Tree = @throws[String](scala.this.throws.<init>$default$1[String]) def foo: Int = 0

Probably the IDE should use the extractor AnnotationInfos.ThrownException in the compiler, and we should update that in the commit that disables constant folding of classOf calls.

/cc @sschaef

scabug commented 8 years ago

Imported From: https://issues.scala-lang.org/browse/SI-9477?orig=1 Reporter: @retronym

scabug commented 8 years ago

@retronym said: Note: Scala refactoring was already prepared for this change in: https://github.com/scala-ide/scala-refactoring/pull/96

scabug commented 8 years ago

@retronym said: The motivation here is to support IDE functionality (e.g. navigation, completion) within the type arguments of classOf).