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
False Presentation Compiler errors due to vals in Definitions referencing non-top-level symbols interacting with "mirror symbol" loading #7678
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7678?orig=1 |
@dotta said: |
@dotta said: |
@retronym said: This is based on a slightly reduced test case: package test object Test { I haven't traced the point of the symbol divergence yet. Does this sound similar to any previous problems? |
@retronym said: https://github.com/retronym/scala/compare/ticket/7678-2.10.x |
@retronym said: package test
import language.implicitConversions
object Test {
type T = scala.languageFeature.implicitConversions
implicit def foo(a: Int) = 0
} Hyperlink through the type Using this test: import scala.tools.partest._
object Test extends CompilerTest {
override def code = ""
def check(source: String, unit: global.CompilationUnit) = ()
val compiler = newCompiler()
new compiler.Run()
import compiler._
val cm = reflect.runtime.currentMirror
val instanceMirror = cm.reflect(definitions)
val members = instanceMirror.symbol.typeSignature.members
def resultType(tp: cm.universe.Type) = tp match {
case cm.universe.NullaryMethodType(res) => res
case t => t
}
val symFields = for {
m <- members.toList
if m.isMethod
if m.asTerm.isGetter
sig = m.typeSignature
res = resultType(sig)
base = res.baseType(cm.universe.typeOf[Symbol].typeSymbol)
if base != cm.universe.NoType
methMirror = instanceMirror.reflectMethod(m.asMethod)
definedSym <- scala.util.Try(methMirror().asInstanceOf[Symbol]).toOption.toList
if (!definedSym.owner.isPackageClass)
} yield (m.name, definedSym)
println(symFields.mkString("\n"))
} I see these non-top-level symbols cached in
I wonder whether the fix for this should be in |
@adriaanm said: |
@retronym said (edited on Jul 22, 2013 5:49:43 AM UTC): /** Find a 'mirror' of symbol `sym` in unit `unit`. Pre: `unit is loaded. */
private def findMirrorSymbol(sym: Symbol, unit: RichCompilationUnit): Symbol = { The problem is that it ends up in the decls of its owner's (TypeTags) info. |
@retronym said: The symptoms could be fixed by avoiding caching non-top-level symbols in Definitions. But we should also consider the broader problem: Should we let the results of type-checking sources of third-party JARs infiltrate the compiler used to type check at all? I can think of a few reasons why this is a bad idea:
But how could we go about firewalling our symbol table from the vaguaries of third party source JARs? The rough idea we had:
Hyperlinking from a call-site to a non-nullary method would have to find the corresponding overload based on type signatures. No doubt the details would be somewhat devilish. But it seems like a workable solution. Mirko suggests that this problem might become more prevalent with ScalaSearch. |
@dragos said: |
@xeno-by said: |
@retronym said: |
@vigdorchik said: |
At the moment, I can reproduce this only inside the Scala IDE for Eclipse.
In an empty project, create a source and paste the following:
hold command and with the mouse hover the
ru.TypeTag
type on the 4th line (no need to navigate, it's enough to wait for the hyperlinking coloration to happen in the editor). Also, for the bug to manifest, it seems to be relevant that you ask hyperlinking onru.TypeTag
.type a space after
List(1,2,3)
and wait for the presentation compiler to re-typecheck your source.Now you should see the following error reported on
getTypeTag
The text was updated successfully, but these errors were encountered: