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 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 28, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 30, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 30, 2012

@scabug scabug closed this 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.