From 4ed7a60caf3648571de9a120e095f9cf3a0151c4 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Fri, 14 Sep 2012 10:41:51 +0200 Subject: Revert "Fix SI-4581." This reverts commit 373f22a2022519ab894c1ea77460e6460d7c2ee4. --- test/files/run/static-annot-repl.check | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test/files/run/static-annot-repl.check') diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check index 3a1532b823..d1029a9809 100644 --- a/test/files/run/static-annot-repl.check +++ b/test/files/run/static-annot-repl.check @@ -13,9 +13,7 @@ scala> @static val x2 = 43 x2: Int = 43 scala> @static def x3 = 44 -:8: error: The @static annotation is not allowed on method definitions. - @static def x3 = 44 - ^ +x3: Int scala> x1 res0: Int = 42 @@ -24,15 +22,11 @@ scala> x2 res1: Int = 43 scala> x3 -:9: error: not found: value x3 - x3 - ^ +res2: Int = 44 scala> class Test { @static def x = 42 } -:9: error: The @static annotation is not allowed on method definitions. - @static def x = 42 - ^ +defined class Test scala> \ No newline at end of file -- cgit v1.2.3 From 6b9e1a0747159128da1e84795c1be6698e16ee43 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Fri, 14 Sep 2012 10:45:43 +0200 Subject: Revert "Fixes SI-6189." This reverts commit 5a8dfad583b825158cf0abdae5d73a4a7f8cd997. Conflicts: src/compiler/scala/tools/nsc/backend/icode/GenICode.scala --- .../scala/tools/nsc/backend/icode/GenICode.scala | 10 ++----- .../scala/tools/nsc/transform/CleanUp.scala | 1 - test/files/neg/static-annot.scala | 6 ---- test/files/run/static-annot-repl.check | 32 ---------------------- test/files/run/static-annot-repl.scala | 22 --------------- 5 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 test/files/run/static-annot-repl.check delete mode 100644 test/files/run/static-annot-repl.scala (limited to 'test/files/run/static-annot-repl.check') diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 0bccd5fe0e..697c2bf23b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -900,17 +900,13 @@ abstract class GenICode extends SubComponent { case app @ Apply(fun @ Select(qual, _), args) if !ctx.method.symbol.isStaticConstructor - && fun.symbol.isAccessor && fun.symbol.accessed.hasStaticAnnotation - && qual.tpe.typeSymbol.orElse(fun.symbol.owner).companionClass != NoSymbol => + && fun.symbol.isAccessor && fun.symbol.accessed.hasStaticAnnotation => // bypass the accessor to the companion object and load the static field directly - // this bypass is not done: - // - if the static intializer for the static field itself - // - if there is no companion class of the object owner - this happens in the REPL + // the only place were this bypass is not done, is the static intializer for the static field itself def genLoadApply5 = { val sym = fun.symbol generatedType = toTypeKind(sym.accessed.info) - val hostOwner = qual.tpe.typeSymbol.orElse(sym.owner) - val hostClass = hostOwner.companionClass + val hostClass = qual.tpe.typeSymbol.orElse(sym.owner).companionClass val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) if (sym.isGetter) { diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 62a0c78c5c..a705e85310 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -783,7 +783,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL { // add field definition to new defs newStaticMembers append stfieldDef newStaticInits append stfieldInit - case _ => // ignore @static on other members } } diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala index c0b5ed30d8..c6c626d42b 100644 --- a/test/files/neg/static-annot.scala +++ b/test/files/neg/static-annot.scala @@ -45,9 +45,3 @@ class PrivateProtectedLazy { println(PrivateProtectedLazy.baz) println(PrivateProtectedLazy.bam) } - - -class StaticDef { - // this should not crash the compiler - @static def x = 42 -} diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check deleted file mode 100644 index d1029a9809..0000000000 --- a/test/files/run/static-annot-repl.check +++ /dev/null @@ -1,32 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> import annotation.static -import annotation.static - -scala> @static var x1 = 42 -x1: Int = 42 - -scala> @static val x2 = 43 -x2: Int = 43 - -scala> @static def x3 = 44 -x3: Int - -scala> x1 -res0: Int = 42 - -scala> x2 -res1: Int = 43 - -scala> x3 -res2: Int = 44 - -scala> class Test { - @static def x = 42 -} -defined class Test - -scala> \ No newline at end of file diff --git a/test/files/run/static-annot-repl.scala b/test/files/run/static-annot-repl.scala deleted file mode 100644 index 1d2e9b2d7e..0000000000 --- a/test/files/run/static-annot-repl.scala +++ /dev/null @@ -1,22 +0,0 @@ - - - -import scala.tools.partest.ReplTest - - - -object Test extends ReplTest { - def code = """ -import annotation.static -@static var x1 = 42 -@static val x2 = 43 -@static def x3 = 44 -x1 -x2 -x3 -class Test { - @static def x = 42 -} -""" - -} -- cgit v1.2.3