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

@static final val: crash #6294

Closed
scabug opened this issue Aug 28, 2012 · 5 comments
Closed

@static final val: crash #6294

scabug opened this issue Aug 28, 2012 · 5 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Aug 28, 2012

object A {
  @annotation.static final val x = 123
}

no-symbol does not have an owner
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:48)
	at scala.tools.nsc.Global.abort(Global.scala:246)
	at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3113)
	at scala.tools.nsc.backend.icode.Opcodes$opcodes$LOAD_FIELD.<init>(Opcodes.scala:224)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:130)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:72)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:72)
	at scala.collection.immutable.List.foreach(List.scala:309)
@scabug
Copy link
Author

scabug commented Aug 28, 2012

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

@scabug
Copy link
Author

scabug commented Aug 30, 2012

@axel22 said (edited on Aug 30, 2012 8:31:36 AM UTC):
Interesting. I didn't know that val s get transformed into def s directly by the compiler sometimes.

This, for instance, works:

object A {
  @annotation.static final val x = {
    "abcdef".length * 123
  }
}

@scabug
Copy link
Author

scabug commented Aug 30, 2012

@axel22 said:
I'm not sure in which phase a transformation from a val to def takes place (i.e. where simple constants get inlined into the getter accessor), but wherever it's done, the accessed field of the symbol should be reset to NoSymbol. After all, the method definition x below:

package <empty> {
  object A extends Object {
    final <stable> <accessor> def x(): Int = 123;
    def <init>(): A.type = {
      A.super.<init>();
      ()
    }
  }
}

is no longer a getter.

@scabug
Copy link
Author

scabug commented Aug 30, 2012

@axel22 said:
Apparently, this is done in constructors.

@scabug
Copy link
Author

scabug commented Aug 30, 2012

@axel22 said:
scala/scala#1217

@scabug scabug closed this as completed Aug 30, 2012
@scabug scabug added the backend label Apr 7, 2017
@scabug scabug added this to the 2.10.0-M7 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants