Skip to content

Compiler Error on constructor visibility problem in extends clause #6216

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 Aug 10, 2012 · 7 comments
Closed

Compiler Error on constructor visibility problem in extends clause #6216

scabug opened this issue Aug 10, 2012 · 7 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Aug 10, 2012

Compiler throws an error trying to compile the declaration line of a scala subclass of a java super class.

[ant:scalac] java.lang.Error: Unexpected tree in genLoad: DynamicBooleanProperty.super/class scala.reflect.generic.Trees$Super at: source-/Users/gorzell/dev/git/oss/archaius-gorzell/archaius-scala/src/main/scala/com/netflix/config/scala/DynamicBooleanProperty.scala,line-8,offset=105
[ant:scalac] 	at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1126)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1226)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1224)
[ant:scalac] 	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
[ant:scalac] 	at scala.collection.immutable.List.foldLeft(List.scala:45)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadArguments(GenICode.scala:1224)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:924)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1175)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:921)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:174)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:143)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:143)
[ant:scalac] 	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
[ant:scalac] 	at scala.collection.immutable.List.foldLeft(List.scala:45)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genStat(GenICode.scala:143)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1052)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:114)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
[ant:scalac] 	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
[ant:scalac] 	at scala.collection.immutable.List.foreach(List.scala:45)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:136)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:88)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
[ant:scalac] 	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
[ant:scalac] 	at scala.collection.immutable.List.foreach(List.scala:45)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:79)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:65)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:61)
[ant:scalac] 	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
[ant:scalac] 	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
[ant:scalac] 	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
[ant:scalac] 	at scala.collection.Iterator$class.foreach(Iterator.scala:660)
[ant:scalac] 	at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:316)
[ant:scalac] 	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
[ant:scalac] 	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:54)
[ant:scalac] 	at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
[ant:scalac] 	at scala.tools.nsc.Global$Run.compile(Global.scala:1038)
[ant:scalac] 	at scala.tools.ant.Scalac.executeInternal(Scalac.scala:629)
[ant:scalac] 	at scala.tools.ant.Scalac.execute(Scalac.scala:577)

Java Class

public class DynamicStringProperty extends PropertyWrapper<String> {

    DynamicStringProperty(String propName, String defaultValue) {
        super(propName, defaultValue);
    }

    /**
     * Get the current value from the underlying DynamicProperty
     */
    public String get() {
        return prop.getString(defaultValue);
    }

    @Override
    public String getValue() {
        return get();
    }
}

Scala Class:

class DynamicStringProperty(property: String, defaultVal: String)
  extends com.netflix.config.DynamicStringProperty(property, defaultVal) {

  def apply(): Option[String] = Option(get())
}
@scabug
Copy link
Author

scabug commented Aug 10, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6216?orig=1
Reporter: Greg Orzell (gorzell)
Affected Versions: 2.9.1, 2.9.2

@scabug
Copy link
Author

scabug commented Aug 11, 2012

@magarciaEPFL said:
Please provide a self-contained example, otherwise we can't even look at this. The provided Java class depends on DynamicProperty which in turn depends on a load of other stuff.

@scabug
Copy link
Author

scabug commented Aug 11, 2012

Greg Orzell (gorzell) said (edited on Aug 14, 2012 10:07:09 PM UTC):
fully contained code can be found here: gorzell/archaius@3fd6ae3 I will try to come up with a more limited example, but since I don't know what is causing the failure it could be tough.

@scabug
Copy link
Author

scabug commented Aug 21, 2012

Greg Orzell (gorzell) said:
I believe that the root cause here was that i was trying to extend a class with a package protected constructor from outside the package, but the compiler just choking doesn't make that very clear.

@scabug
Copy link
Author

scabug commented Nov 10, 2012

@jsalvata said:
I've hit this without involvement of a Java class -- just scala code:

object Test {
  sealed class Result private(val id: Short, val isFinal: Boolean)
  case class Ok() extends Result(1, true)
}

(I intended "private[Test]" -- easy to get it wrong)

@scabug
Copy link
Author

scabug commented Nov 10, 2012

@jsalvata said:
I've removed the "java-interop" tag, since my example doesn't (seem to) involve any Java interoperability.

I've changed the summary to what I believe are the common aspects of both reported cases.

@scabug
Copy link
Author

scabug commented Nov 11, 2012

@paulp said:
In 2.10 your example fails correctly. I expect the other one does as well.

<console>:9: error: constructor Result in class Result cannot be accessed in class Ok
         case class Ok() extends Result(1, true)
                      ^

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