mirror of
https://github.com/apple/pkl.git
synced 2026-09-13 13:21:47 +02:00
Enforce that abstract methods are implemented (#1785)
This adds a check that abstract members must be implemented. If any members lack an implementation, an error is thrown describing the missing members. Co-authored-by: Dan Chao <dan.chao@apple.com>
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
abstract module Foo
|
||||
|
||||
abstract function bar(): Int
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
abstract class AbstractMethod {
|
||||
abstract function foo(): Int
|
||||
}
|
||||
|
||||
class MyClass extends AbstractMethod {
|
||||
}
|
||||
|
||||
foo: MyClass
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
abstract class AbstractMethods {
|
||||
abstract function foo(): Int
|
||||
abstract function bar(): Int
|
||||
}
|
||||
|
||||
class MyClass extends AbstractMethods {
|
||||
}
|
||||
|
||||
foo: MyClass
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
extends "../../input-helper/classes/AbstractModule.pkl"
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
abstract class AbstractMethod {
|
||||
abstract function foo(): Int
|
||||
}
|
||||
|
||||
abstract class AbstractIntermediate extends AbstractMethod
|
||||
|
||||
class MyClass extends AbstractIntermediate {
|
||||
}
|
||||
|
||||
foo: MyClass
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
–– Pkl Error ––
|
||||
Class `abstractMethodNotImplemented1#MyClass` should either be declared `abstract`, or should implement method `foo()`.
|
||||
|
||||
x | class MyClass extends AbstractMethod {
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at abstractMethodNotImplemented1 (file:///$snippetsDir/input/errors/abstractMethodNotImplemented1.pkl)
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
–– Pkl Error ––
|
||||
Class `abstractMethodNotImplemented2#MyClass` should either be declared `abstract`, or should implement the following methods:
|
||||
foo()
|
||||
bar()
|
||||
|
||||
x | class MyClass extends AbstractMethods {
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at abstractMethodNotImplemented2 (file:///$snippetsDir/input/errors/abstractMethodNotImplemented2.pkl)
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
–– Pkl Error ––
|
||||
Class `abstractMethodNotImplemented3` should either be declared `abstract`, or should implement method `bar()`.
|
||||
|
||||
x | extends "../../input-helper/classes/AbstractModule.pkl"
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at abstractMethodNotImplemented3 (file:///$snippetsDir/input/errors/abstractMethodNotImplemented3.pkl)
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
–– Pkl Error ––
|
||||
Class `abstractMethodNotImplemented4#MyClass` should either be declared `abstract`, or should implement method `foo()`.
|
||||
|
||||
x | class MyClass extends AbstractIntermediate {
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at abstractMethodNotImplemented4 (file:///$snippetsDir/input/errors/abstractMethodNotImplemented4.pkl)
|
||||
Reference in New Issue
Block a user