8000 Revert `@static` annotation by gkossakowski · Pull Request #1340 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Revert @static annotation #1340

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? 8000 Sign in to your account

Merged
merged 8 commits into from
Sep 18, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Fixes SI-6236."
This reverts commit faa114e.
  • Loading branch information
gkossakowski committed Sep 17, 2012
commit 6854842cf88f020289b783983d13ebef4d7605f4
15 changes: 2 additions & 13 deletions src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -911,19 +911,8 @@ abstract class GenICode extends SubComponent {
generatedType = toTypeKind(sym.accessed.info)
val hostOwner = qual.tpe.typeSymbol.orElse(sym.owner)
val hostClass = hostOwner.companionClass
val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) orElse {
if (!currentRun.compiles(hostOwner)) {
// hostOwner was separately compiled -- the static field symbol needs to be recreated in hostClass
import Flags._
debuglog("recreating sym.accessed.name: " + sym.accessed.name)
val objectfield = hostOwner.info.findMember(sym.accessed.name, NoFlags, NoFlags, false)
val staticfield = hostClass.newVariable(newTermName(sym.accessed.name.toString), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo objectfield.tpe
staticfield.addAnnotation(definitions.StaticClass)
hostClass.info.decls enter staticfield
staticfield
} else NoSymbol
}

val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false)

if (sym.isGetter) {
ctx.bb.emit(LOAD_FIELD(staticfield, true) setHostClass hostClass, tree.pos)
ctx
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/CleanUp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
// create a static field in the companion class for this @static field
val stfieldSym = linkedClass.newVariable(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe
stfieldSym.addAnnotation(StaticClass)

val names = classNames.getOrElseUpdate(linkedClass, linkedClass.info.decls.collect {
case sym if sym.name.isTermName => sym.name
} toSet)
Expand Down
13 changes: 2 additions & 11 deletions test/files/run/static-annot/field.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ class Foo
trait Check {
def checkStatic(cls: Class[_]) {
cls.getDeclaredFields.find(_.getName == "bar") match {
case Some(f) =>
assert(Modifier.isStatic(f.getModifiers), "no static modifier")
case None =>
assert(false, "no static field bar in class")
case Some(f) => assert(Modifier.isStatic(f.getModifiers), "no static modifier")
case None => assert(false, "no static field bar in class")
}
}

Expand Down Expand Up @@ -172,20 +170,13 @@ object Foo7 {
@static val bar = "string"
}
class AndHisFriend

object AndHisLonelyFriend {
@static val bar = "another"
}
}


object Test7 extends Check {
def test() {
checkStatic(classOf[Foo7.AndHisFriend])
assert(Foo7.AndHisFriend.bar == "string")

checkStatic(Class.forName("Foo7$AndHisLonelyFriend"))
assert(Foo7.AndHisLonelyFriend.bar == "another")
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/files/run/t6236.check

This file was deleted.

9 changes: 0 additions & 9 deletions test/files/run/t6236/file_1.scala

This file was deleted.

10 changes: 0 additions & 10 deletions test/files/run/t6236/file_2.scala

This file was deleted.

0