Revert "Revert "Reject abstract members in non-abstract classes" (#1688)" (#1780)

This reverts commit 1bf00b84ea.

Co-authored-by: Vinayak <vinayak@vama.app>
This commit is contained in:
Jen Basch
2026-07-16 11:34:20 -07:00
committed by GitHub
co-authored by Vinayak
parent a1421ff667
commit 3d03a47933
11 changed files with 70 additions and 3 deletions
@@ -0,0 +1,5 @@
class Foo {
abstract bar: Int
}
res = new Foo { bar = 5 }
@@ -0,0 +1 @@
abstract foo: Int
@@ -0,0 +1,5 @@
class Foo {
abstract function bar(): Int
}
res = new Foo {}
@@ -0,0 +1,8 @@
–– Pkl Error ––
Cannot define an abstract member in a non-abstract class.
x | abstract bar: Int
^^^^^^^^
at abstractMemberInNonAbstractClass#Foo (file:///$snippetsDir/input/errors/abstractMemberInNonAbstractClass.pkl)
A member can only be `abstract` if its enclosing class is also `abstract`.
@@ -0,0 +1,8 @@
–– Pkl Error ––
Cannot define an abstract member in a non-abstract class.
x | abstract foo: Int
^^^^^^^^
at abstractMemberInNonAbstractModule (file:///$snippetsDir/input/errors/abstractMemberInNonAbstractModule.pkl)
A member can only be `abstract` if its enclosing class is also `abstract`.
@@ -0,0 +1,8 @@
–– Pkl Error ––
Cannot define an abstract member in a non-abstract class.
x | abstract function bar(): Int
^^^^^^^^
at abstractMethodInNonAbstractClass#Foo (file:///$snippetsDir/input/errors/abstractMethodInNonAbstractClass.pkl)
A member can only be `abstract` if its enclosing class is also `abstract`.