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

$asInstanceOf sometimes shows up in tab completion #6368

Closed
scabug opened this issue Sep 12, 2012 · 10 comments
Closed

$asInstanceOf sometimes shows up in tab completion #6368

scabug opened this issue Sep 12, 2012 · 10 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 12, 2012

The title says it all. Here is the stack trace:

java.lang.AssertionError: assertion failed: null.$asInstanceOfInt
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:754)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:850)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1226)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1224)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
at scala.collection.immutable.List.foldLeft(List.scala:76)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadArguments(GenICode.scala:1224)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:924)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:114)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:76)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:136)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:88)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:76)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:79)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:65)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:61)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
at scala.collection.Iterator$class.foreach(Iterator.scala:772)
at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:318)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:54)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
at scala.tools.nsc.Global$Run.compile(Global.scala:1041)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:90)
at xsbt.CachedCompiler0.liftedTree1$1(CompilerInterface.scala:72)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:72)
at xsbt.CompilerInterface.run(CompilerInterface.scala:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:73)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:35)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:29)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:101)
at sbt.compiler.AggressiveCompile$$anonfun$4.compileScala$1(AggressiveCompile.scala:70)
at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:88)
at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:60)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:24)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:22)
at sbt.inc.Incremental$.cycle(Incremental.scala:39)
at sbt.inc.Incremental$.compile(Incremental.scala:26)
at sbt.inc.IncrementalCompile$.apply(Compile.scala:20)
at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:96)
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:31)
at sbt.Compiler$.apply(Compiler.scala:79)
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:571)
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:571)
at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$5.work(System.scala:71)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:238)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)

@scabug
Copy link
Author

scabug commented Sep 12, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6368?orig=1
Reporter: Kim Stebel (kimstebel)
Affected Versions: 2.9.2, 2.10.0-M7

@scabug
Copy link
Author

scabug commented Sep 13, 2012

@paulp said:
I'm not at all sure what you expect to happen, but calling $asInstanceOf directly is how you say "I would like to crash." Perhaps you are thinking of asInstanceOf.

@scabug
Copy link
Author

scabug commented Sep 13, 2012

Kim Stebel (kimstebel) said:
I would expect a crash at runtime, but at compile time??

@scabug
Copy link
Author

scabug commented Sep 13, 2012

@sschaef said:
Why is this even allowed when it lets the compiler crash?

@scabug
Copy link
Author

scabug commented Sep 13, 2012

@som-snytt said:
I think somewhere there must be a policy statement about identifiers with embedded "$". With one "$", you get an eon in Purgatory, two "$$" means straight to Hell. But if I'm not mistaken, the Typesafe online store does sell a keyboard with the "$" disabled. Shift-4 generates the unicode =>. Perhaps Kim means, "I would accept a crash at runtime." Frankly, no-one expects the Spanish Inquisition! Full disclosure: Kim was encouraged on SO to file, even with the explicit proviso that it's a "really bad snippet of code." So the rule must be, "Bad snippets in, bad snippets out."

@scabug
Copy link
Author

scabug commented Sep 13, 2012

Kim Stebel (kimstebel) said:
Okay, that was funny. But why does this even show up in the autocomplete options of the repl? It should be hidden to protect the innocent and safe them from eternal damnation.

@scabug
Copy link
Author

scabug commented Sep 14, 2012

@paulp said:
In general, it doesn't show up. After brief experimentation, I see it on string literals and nowhere else. That much is a bug. Where are you seeing it?

@scabug
Copy link
Author

scabug commented Sep 14, 2012

Kim Stebel (kimstebel) said:
I see it on null.

@scabug
Copy link
Author

scabug commented May 20, 2013

@JamesIry said:
2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

@scabug
Copy link
Author

scabug commented Apr 21, 2016

@som-snytt said (edited on Apr 21, 2016 6:38:12 AM UTC):
This was fixed by the new completion in 2.11.8.

It used to appear under double-tab, null. or "".

The previous backend error, on an attempt to use $asInstanceOf, was

should have been unboxed by erasure: "".$asInstanceOf[Int]()

and is now

Erasure should have added an unboxing operation to prevent this cast. Tree: "".$asInstanceOf[Int]()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants