Skip to content

Compiler crashes with "no-symbol does not have owner" #805

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

Closed
scabug opened this issue Apr 25, 2008 · 5 comments
Closed

Compiler crashes with "no-symbol does not have owner" #805

scabug opened this issue Apr 25, 2008 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 25, 2008

Hello,

I encountered a bug with the compiler of version 2.7.1-rc2 and was able to reduce it to the following example :

Scala code :

package fr.up5.mi.noel.scala
object Test {
  def make(t: java.Test) : Test = TestList(t.args.toList)
}
case class TestList[T](elements: List[T])(implicit f: T => Test)

Java code :

package java;
public class Test {
  public Test[] args;
}

What is strange is :

The bug appears only when using "scala" in the package name, in conjunction with a java class (I think the array in the java class is important, I tried to reproduce the bug with a scala class instead of a java class and it did not appeared) and using implicit parameters for the TestList class !

The error is :

Test.scala:4: error: not found: type Test
  def make(t: java.Test) : Test = TestList(t.args.toList)
                           ^
Test.scala:7: error: type Nothing is not a member of package fr.up5.mi.noel.scala
case class TestList[T](elements: List[T])(implicit f: T => Test)
                    ^
Test.scala:7: error: type Function1 is not a member of package fr.up5.mi.noel.scala
case class TestList[T](elements: List[T])(implicit f: T => Test)
                                                        ^
Exception in thread "main" java.lang.Error: no-symbol does not have owner
        at scala.tools.nsc.symtab.Symbols$$NoSymbol$$.owner(Symbols.scala:1565)
        at scala.tools.nsc.symtab.Symbols$$Symbol.fullNameString(Symbols.scala:1156)
        at scala.tools.nsc.symtab.Symbols$$Symbol.fullNameString(Symbols.scala:1166)
        at scala.tools.nsc.typechecker.Typers$$Typer.implicitManifest$$1(Typers.scala:3584)
        at scala.tools.nsc.typechecker.Typers$$Typer.inferImplicit(Typers.scala:3593)
        at scala.tools.nsc.typechecker.Typers$$Typer.implicitArg$$1(Typers.scala:3644)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$applyImplicitArgs$$1.apply(Typers.scala:3648)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$applyImplicitArgs$$1.apply(Typers.scala:3648)
        at scala.List.map(List.scala:798)
        at scala.tools.nsc.typechecker.Typers$$Typer.applyImplicitArgs(Typers.scala:3648)
        at scala.tools.nsc.typechecker.Typers$$Typer.adapt(Typers.scala:644)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3233)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3276)
        at scala.tools.nsc.typechecker.Typers$$Typer.transformedOrTyped(Typers.scala:3325)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedDefDef(Typers.scala:1315)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2966)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedTemplate(Typers.scala:1165)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedModuleDef(Typers.scala:1063)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2960)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Analyzer$$typerFactory$$$$anon$$2.apply(Analyzer.scala:40)
        at scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:257)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.Iterator$$class.foreach(Iterator.scala:395)
        at scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:266)
        at scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:243)
        at scala.tools.nsc.Global$$Run.compileSources(Global.scala:555)
        at scala.tools.nsc.Global$$Run.compile(Global.scala:640)
        at scala.tools.nsc.Main$$.process(Main.scala:84)
        at scala.tools.nsc.Main$$.main(Main.scala:98)
        at scala.tools.nsc.Main.main(Main.scala)

Note that this example doesn't mean anything and should not compile if there was not this bug, but at first I had an example that should work and that did not.

If you prefer that I make a better example that should compile, I can try to do it :)

@scabug
Copy link
Author

scabug commented Apr 25, 2008

Imported From: https://issues.scala-lang.org/browse/SI-805?orig=1
Reporter: vector

@scabug
Copy link
Author

scabug commented Apr 29, 2008

@lrytz said:
Hi,

I can't reproduce your problem, I never get the java.lang.Error.

An example that should compile but does not would be good. Also give us instructions on how to reproduce it (e.g. "call javac on Test.java, then scalac on ...").

Concerning your example: defining a scala object that has the same name as a java class is not supported.

@scabug
Copy link
Author

scabug commented Apr 29, 2008

vector said:
Hello,

I modified my example to make it compilable, but that do not compile :)

There is the java file, you put it in a file : BASEDIR/test/java/JavaTest.java

package test.java;
public class TestJava {
	public TestJava[] args;
}

Now there is the scala file, you put it in a file : BASEDIR/test/scala/ScalaTest.scala

package test.scala
import test.java.TestJava
case class TestScala(x: TestJava)
object TestScala {
  implicit def javaToScala(x: TestJava) : TestScala = TestScala(x)
  def make(t: TestJava) : TestList[TestJava] = t.args match {
    case Array() => TestList(List())
    case _ => TestList(t.args.toList)
  }
}
case class TestList[T](elements: List[T])(implicit f: T => TestScala)

After, you go in BASEDIR/ then you type : javac test/java/TestJava.java
then scalac test/scala/TestScala.scala

And I get this error :

TestScala.scala:17: error: type Nothing is not a member of package test.scala
case class TestList[T](elements: List[T])(implicit f: T => TestScala)
                    ^
TestScala.scala:17: error: type Function1 is not a member of package test.scala
case class TestList[T](elements: List[T])(implicit f: T => TestScala)
                                                        ^
Exception in thread "main" java.lang.Error: no-symbol does not have owner
        at scala.tools.nsc.symtab.Symbols$$NoSymbol$$.owner(Symbols.scala:1565)
        at scala.tools.nsc.symtab.Symbols$$Symbol.fullNameString(Symbols.scala:1156)
        at scala.tools.nsc.symtab.Symbols$$Symbol.fullNameString(Symbols.scala:1166)
        at scala.tools.nsc.typechecker.Typers$$Typer.implicitManifest$$1(Typers.scala:3584)
        at scala.tools.nsc.typechecker.Typers$$Typer.inferImplicit(Typers.scala:3593)
        at scala.tools.nsc.typechecker.Typers$$Typer.implicitArg$$1(Typers.scala:3644)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$applyImplicitArgs$$1.apply(Typers.scala:3648)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$applyImplicitArgs$$1.apply(Typers.scala:3648)
        at scala.List.map(List.scala:798)
        at scala.tools.nsc.typechecker.Typers$$Typer.applyImplicitArgs(Typers.scala:3648)
        at scala.tools.nsc.typechecker.Typers$$Typer.adapt(Typers.scala:644)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3233)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3276)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedCase(Typers.scala:1395)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedCases$$1.apply(Typers.scala:1414)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedCases$$1.apply(Typers.scala:1413)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedCases(Typers.scala:1413)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3042)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3276)
        at scala.tools.nsc.typechecker.Typers$$Typer.transformedOrTyped(Typers.scala:3325)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedDefDef(Typers.scala:1315)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2966)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.List$$.loop$$1(List.scala:297)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedTemplate(Typers.scala:1165)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedModuleDef(Typers.scala:1063)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2960)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.List$$.loop$$1(List.scala:297)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.List$$.loop$$1(List.scala:297)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
        at scala.tools.nsc.typechecker.Analyzer$$typerFactory$$$$anon$$2.apply(Analyzer.scala:40)
        at scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:257)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.Iterator$$class.foreach(Iterator.scala:395)
        at scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:266)
        at scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:243)
        at scala.tools.nsc.Global$$Run.compileSources(Global.scala:555)
        at scala.tools.nsc.Global$$Run.compile(Global.scala:640)
        at scala.tools.nsc.Main$$.process(Main.scala:84)
        at scala.tools.nsc.Main$$.main(Main.scala:98)
        at scala.tools.nsc.Main.main(Main.scala)

And if you remove the "scala" in the package, it compiles.

So I think it is only a problem with the scala package name ...

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone next_feature deleted

@scabug
Copy link
Author

scabug commented May 4, 2009

@paulp said:
Fixed in r17632. This was a variation of the bug which caused #430, and if you look at my final comment there you can see I expected more like it. Unfortunately the "obvious" fix to eliminate them all doesn't work, so it remains a matter for study.

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

No branches or pull requests

2 participants