Skip to content

Allow abstract type members in objects. #2044

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

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ object Checking {
if (!sym.is(Deferred))
fail(i"`@native' members may not have implementation")
}
else if (sym.is(Deferred, butNot = Param) && !sym.isSelfSym) {
else if (sym.is(Deferred, butNot = Param) && !sym.isType && !sym.isSelfSym) {
if (!sym.owner.isClass || sym.owner.is(Module) || sym.owner.isAnonymousClass)
fail(i"only classes can have declared but undefined members$varNote")
checkWithDeferred(Private)
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/customArgs/typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object typers {
}

type L[X] = scala.collection.immutable.List[X]
type M[X, Y] <: scala.collection.immutable.Map[X, Y] // error: only classes can have declared but undefined members
type M[X, Y] <: scala.collection.immutable.Map[X, Y] // old-error: only classes can have declared but undefined members

object hk {
def f(x: L) // error: missing type parameter
Expand Down
3 changes: 2 additions & 1 deletion tests/neg/i1050c.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ object Tiark4 {
v.brand("boom!")
}
object V { // error: cannot be instantiated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error of the bound >: Any <: Nothing is the reason for the cannot be instantiated error, the full message is quite clear on the source of the issue.

type Y >: Any <: Nothing // error: only classes can have declared but undefined members
type Y >: Any <: Nothing // old-error: only classes can have declared but undefined members
type Z
}
object Tiark5 {
trait A { type L <: Nothing }
Expand Down