Singleton type

Problem
-------
Currently singleton types are treated as `stable_type_identifier`.

Solution
--------
This adds `singleton_type`.
pull/481/head
Eugene Yokota 2023-01-14 15:37:55 +07:00
parent c22c572eda
commit 4c3cb92b4b
2 changed files with 24 additions and 0 deletions

@ -293,6 +293,23 @@ class Test(d: "hello", b: 25)
(literal_type
(integer_literal))))))
==================================
Singleton Types
==================================
class A:
def foobar: this.type = this
type X = A.B.type
---
(compilation_unit
(class_definition
(identifier)
(template_body
(function_definition (identifier) (singleton_type (identifier)) (identifier))
(type_definition (type_identifier) (singleton_type (stable_identifier (identifier) (identifier)))))))
==================================
Opaque type aliases (Scala 3)
==================================

@ -682,6 +682,7 @@ module.exports = grammar({
$.generic_type,
$.projected_type,
$.tuple_type,
$.singleton_type,
$.stable_type_identifier,
$._type_identifier,
$.wildcard,
@ -705,6 +706,12 @@ module.exports = grammar({
')',
),
singleton_type: $ => prec.left(PREC.stable_type_id, seq(
choice($._identifier, $.stable_identifier),
'.',
'type',
)),
stable_type_identifier: $ => prec.left(PREC.stable_type_id, seq(
choice($._identifier, $.stable_identifier),
'.',