I'm feeling stupid, but I cannot find an example f...
# getting-started
m
I'm feeling stupid, but I cannot find an example for what the syntax is for what I want to do. I'm trying to create generic class, where the generic type is two lower limits and the class implements an interface via delegation. From the grammer
Copy code
classDeclaration (used by declaration)
  : modifiers? ('class' | ('fun'? 'interface'))
    simpleIdentifier typeParameters?
    primaryConstructor?
    (':' delegationSpecifiers)?
    typeConstraints?
    (classBody | enumClassBody)?
  ;
I would expect this to work, but it doesn't
Copy code
class Foo<T>(t: T, bar: Bar) : Bar by bar where T: T1, T : T2 {}
I've tried a few variants, adding commas or colon between the by bar and the where. If I remove the
by
it compiles.
y
I believe you need a newline right before the
where
. It's maybe a compiler bug thus and not an issue with the grammar
m
That worked, thanks
where
is a soft keyword so it is only recognized specifically in contexts where it is expected, so the delegation expression just consumes it like a normal identifier (and then breaks)
k
I guess you could also use a semicolon instead of a newline if you prefer?
e
no, the syntax doesn't permit a semicolon there, it'll end the class declaration