Lower Kotlin value externs
ober
fbc5e8d648f2c9df4f1a9e347229b676a7c7d22e
--- a/lib/jerboa/typed/checker.ss +++ b/lib/jerboa/typed/checker.ss @@ -406,6 +406,7 @@ (case kind [(external) 'kotlin-call] [(call) 'kotlin-call] + [(value) 'kotlin-value] [(member-call) 'kotlin-member-call] [(member-get) 'kotlin-member-get] [(member-set) 'kotlin-member-set] --- a/lib/jerboa/typed/core.ss +++ b/lib/jerboa/typed/core.ss @@ -200,6 +200,7 @@ log2 debug-string kotlin-call + kotlin-value kotlin-member-call kotlin-member-get kotlin-member-set --- a/lib/jerboa/typed/kotlin/lower.ss +++ b/lib/jerboa/typed/kotlin/lower.ss @@ -651,6 +651,8 @@ (make-kt-lit 'Char #\0)))] [(kotlin-call) (make-kt-call (make-kt-name (info-ref info 'path (list operator))) args)] + [(kotlin-value) + (make-kt-name (info-ref info 'path (list operator)))] [(kotlin-member-call) (make-kt-member-call (car args) --- a/lib/jerboa/typed/parser.ss +++ b/lib/jerboa/typed/parser.ss @@ -443,6 +443,11 @@ (symbol-list? (cdr form))) (list (cons 'kind 'call) (cons 'path (cdr form)))] + [(and (>= (length form) 2) + (eq? (car form) 'kotlin-value) + (symbol-list? (cdr form))) + (list (cons 'kind 'value) + (cons 'path (cdr form)))] [(and (= (length form) 2) (eq? (car form) 'kotlin-member-call) (symbol? (cadr form))) @@ -463,7 +468,7 @@ (list (cons 'kind 'external))] [else (error 'parse-typed-extern - "expected (kotlin-call PackageOrObject function), (kotlin-member-call method), (kotlin-member-get property), (kotlin-member-set property), or (kotlin-external)" + "expected (kotlin-call PackageOrObject function), (kotlin-value PackageOrObject property), (kotlin-member-call method), (kotlin-member-get property), (kotlin-member-set property), or (kotlin-external)" form)]))) (def (parse-extern form) --- a/tests/test-typed-kotlin.ss +++ b/tests/test-typed-kotlin.ss @@ -343,13 +343,18 @@ (define extern-form '(typed-library (sample typed extern) - (export find) + (export find defaultOptions) (type Context) (type BoxType) + (type TextRecognizerOptions) (extern (boxTypesResolve (context : Context) (raw : String)) : (Nullable BoxType) (kotlin-call BoxTypes resolve)) + (extern (textRecognizerDefaultOptions) : TextRecognizerOptions + (kotlin-value TextRecognizerOptions DEFAULT_OPTIONS)) (def (find (context : Context) (raw : String)) : (Nullable BoxType) - (boxTypesResolve context raw)))) + (boxTypesResolve context raw)) + (def (defaultOptions) : TextRecognizerOptions + (textRecognizerDefaultOptions)))) (define extern-kotlin (typed-library-form->kotlin-string extern-form)) @@ -357,6 +362,10 @@ extern-kotlin "return BoxTypes.resolve(context, raw)") +(test-contains "extern Kotlin value lowers to qualified property" + extern-kotlin + "return TextRecognizerOptions.DEFAULT_OPTIONS") + (define member-extern-form '(typed-library (sample typed memberextern) (export width copyPixels setSelectedGroup)