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

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

Closed
scabug opened this issue Dec 26, 2016 · 2 comments
Closed

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

scabug opened this issue Dec 26, 2016 · 2 comments

Comments

@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
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

@som-snytt
Copy link

Duplicates #6617

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2024
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