From 889ccbceca97c8307cb39577c7eeb68965c2b5cd Mon Sep 17 00:00:00 2001 From: Manuel Dossinger Date: Tue, 8 Sep 2020 20:38:25 +0200 Subject: [PATCH] Fix handling of ::class in Kotlin lexer (#1572) Due to the way the Kotlin lexer treats the 'class' keyword, the use of the callable reference, `::class`, can result in the lexer moving into an incorrect state where it interprets `class` as beginning a class definition. This commit fixes that bug. Co-authored-by: Michael Camilleri --- lib/rouge/lexers/kotlin.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rouge/lexers/kotlin.rb b/lib/rouge/lexers/kotlin.rb index fe83a2adb0..a2cc138878 100644 --- a/lib/rouge/lexers/kotlin.rb +++ b/lib/rouge/lexers/kotlin.rb @@ -65,6 +65,9 @@ class Kotlin < RegexLexer rule %r'/[*].*[*]/', Comment::Multiline # single line block comment rule %r'/[*].*', Comment::Multiline, :comment # multiline block comment rule %r'\n', Text + rule %r'(::)(class)' do + groups Operator, Keyword + end rule %r'::|!!|\?[:.]', Operator rule %r"(\.\.)", Operator # Number literals