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

Type inference when inheriting class with non-public constructor #10122

Open
scabug opened this Issue Dec 26, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Dec 26, 2016

cat inference/other/BaseClass.scala:

package inference.other
class BaseClass[T] protected(value: T)

cat inference/Derived.scala

package inference
class Derived extends other.BaseClass("value")

Compile:

scalac inference/other/BaseClass.scala inference/Derived.scala 
inference/Derived.scala:3: error: constructor BaseClass in class BaseClass cannot be accessed in package inference
 Access to protected constructor BaseClass not permitted because
 enclosing package inference is not a subclass of
 class BaseClass in package other where target is defined
class Derived extends other.BaseClass("value")
                            ^
inference/Derived.scala:3: error: no arguments allowed for nullary constructor Object: ()Object
class Derived extends other.BaseClass("value")
                                      ^
two errors found

If classes in the same package, everything is fine. If type parameter is specified extends other.BaseClass[String]("value") everything is also fine.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Dec 26, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10122?orig=1
Reporter: Dmitry Komanov (dkomanov)
Affected Versions: 2.11.8, 2.12.1

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