mirror of
https://github.com/apple/pkl.git
synced 2026-09-13 13:21:47 +02:00
Error when inferring a self type in a method argument (#1847)
This commit is contained in:
+8
@@ -16,7 +16,12 @@ class Qux extends Foo {
|
||||
function bar(baz: Foo): Int = thisBar(new { x = baz.x })
|
||||
}
|
||||
|
||||
class Quux {
|
||||
function selfType(arg: this): String = arg.getClass().toString()
|
||||
}
|
||||
|
||||
function bar(baz: Foo): Int = baz.x
|
||||
function selfType(arg: this): String = arg.getClass().toString()
|
||||
|
||||
const function outerMethod(a: Int, b: Qux) = a + b.x * 2
|
||||
|
||||
@@ -41,6 +46,9 @@ intrinsicConstructor = test.catch(() -> List(new {}))
|
||||
genericMethod = test.catch(() -> Pair(new {}, new {}))
|
||||
fnApply = test.catch(() -> quux.apply(new {}))
|
||||
tooManyParams = test.catch(() -> bar(new {}, new {}))
|
||||
finalSelfType = test.catch(() -> new Quux {}.selfType(new {}))
|
||||
nonFinalSelfType1 = test.catch(() -> selfType(new {}))
|
||||
nonFinalSelfType2 = test.catch(() -> new Qux {}.selfType(new {}))
|
||||
|
||||
class Bar1 { x: Int = 1 }
|
||||
class Bar2 { x: Int = 2 }
|
||||
|
||||
+3
@@ -14,5 +14,8 @@ intrinsicConstructor = "Cannot tell which parent to amend."
|
||||
genericMethod = "Cannot tell which parent to amend."
|
||||
fnApply = "Cannot tell which parent to amend."
|
||||
tooManyParams = "Expected 1 function argument but got 2."
|
||||
finalSelfType = "Cannot tell which parent to amend."
|
||||
nonFinalSelfType1 = "Cannot tell which parent to amend."
|
||||
nonFinalSelfType2 = "Cannot tell which parent to amend."
|
||||
polyCall1 = 1
|
||||
polyCall2 = 20
|
||||
|
||||
Reference in New Issue
Block a user