diff --git a/lib/rouge/lexers/kotlin.rb b/lib/rouge/lexers/kotlin.rb index 1ac63acb51..d60d6efd24 100644 --- a/lib/rouge/lexers/kotlin.rb +++ b/lib/rouge/lexers/kotlin.rb @@ -105,7 +105,8 @@ class Kotlin < RegexLexer state :generic_parameters do rule class_name, Name::Class rule %r'(<)', Punctuation, :generic_parameters - rule %r'(,)', Punctuation + rule %r'(reified|out|in)', Keyword + rule %r'([,:])', Punctuation rule %r'(\s+)', Text rule %r'(>)', Punctuation, :pop! end diff --git a/spec/lexers/kotlin_spec.rb b/spec/lexers/kotlin_spec.rb index d6429cb113..cd4156fae2 100644 --- a/spec/lexers/kotlin_spec.rb +++ b/spec/lexers/kotlin_spec.rb @@ -31,5 +31,11 @@ it 'recognizes label reference in break statement' do assert_tokens_equal 'break@label', ["Keyword", "break"], ["Name.Decorator", "@label"] end + + it 'recognizes type modifiers' do + for modifer in ['reified', 'out', 'in'] do + assert_tokens_equal "<#{modifer} T>", ["Punctuation", "<"], ["Keyword", modifer], ["Text", " "], ["Name.Class", "T"], ["Punctuation", ">"] + end + end end end diff --git a/spec/visual/samples/kotlin b/spec/visual/samples/kotlin index 15591bba55..1ece9ae72d 100644 --- a/spec/visual/samples/kotlin +++ b/spec/visual/samples/kotlin @@ -162,10 +162,14 @@ fun `String`.`backTickedExtensionFunction`() { return } -fun String.genericExtensionFunction() { +fun String.genericExtensionFunction() { return } +inline fun membersOf() = T::class.members +public interface List : Collection {} +public interface Comparable {} + @Deprecated("This is an annotation") fun anAnnotatedFunction() = { }