Skip to content

Commit 4e59461

Browse files
authored
Merge pull request #266 from eed3si9n/wip/refinement
2 parents 798ec78 + 4b7736c commit 4e59461

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

corpus/types.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ def cloneAndReset(obj: Cloneable with Resetable): Cloneable = {
194194

195195
class F extends Cloneable with Resetable with Serializable {}
196196

197+
type G = H[A1] {
198+
def foo[A2 <: Stepper[_]]: A2
199+
}
200+
197201
--------------------------------------------------------------------------------
198202

199203
(compilation_unit
@@ -213,7 +217,25 @@ class F extends Cloneable with Resetable with Serializable {}
213217
(type_identifier)
214218
(type_identifier)
215219
(type_identifier))
216-
(template_body)))
220+
(template_body))
221+
(type_definition
222+
(type_identifier)
223+
(compound_type
224+
(generic_type
225+
(type_identifier)
226+
(type_arguments
227+
(type_identifier)))
228+
(refinement
229+
(function_declaration
230+
(identifier)
231+
(type_parameters
232+
(identifier)
233+
(upper_bound
234+
(generic_type
235+
(type_identifier)
236+
(type_arguments
237+
(wildcard)))))
238+
(type_identifier))))))
217239

218240
================================================================================
219241
Infix types

grammar.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,14 @@ module.exports = grammar({
682682
* DefParam ::= {Annotation} [‘inline’] Param
683683
* Param ::= id ‘:’ ParamType [‘=’ Expr]
684684
*/
685-
parameter: $ => seq(
685+
parameter: $ => prec.left(PREC.control, seq(
686686
repeat($.annotation),
687687
optional($.inline_modifier),
688688
field('name', $._identifier),
689689
':',
690690
field('type', $._param_type),
691691
optional(seq('=', field('default_value', $.expression)))
692-
),
692+
)),
693693

694694
_block: $ => prec.left(seq(
695695
sep1($._semicolon, choice(
@@ -760,11 +760,25 @@ module.exports = grammar({
760760
$.wildcard,
761761
),
762762

763-
compound_type: $ => prec(PREC.compound, seq(
764-
field('base', $._annotated_type),
765-
repeat1(seq('with', field('extra', $._annotated_type))),
766-
// TODO: Refinement.
767-
)),
763+
compound_type: $ => choice(
764+
prec.left(PREC.compound, seq(
765+
field('base', $._annotated_type),
766+
repeat1(seq('with', field('extra', $._annotated_type))),
767+
)),
768+
prec.left(-1, seq(
769+
field('base', $._annotated_type),
770+
$._refinement,
771+
)),
772+
prec.left(-1, seq(
773+
prec.left(PREC.compound, seq(
774+
field('base', $._annotated_type),
775+
repeat1(seq('with', field('extra', $._annotated_type))),
776+
)),
777+
$._refinement,
778+
)),
779+
),
780+
781+
_refinement: $ => alias($.template_body, $.refinement),
768782

769783
// This does not include _simple_type since _annotated_type covers it.
770784
_infix_type_choice: $ => prec.left(PREC.infix, choice(

script/smoke_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# This is an integration test to generally check the quality of parsing.
44

55
SCALA_SCALA_LIBRARY_EXPECTED=95
6-
SCALA_SCALA_COMPILER_EXPECTED=84
6+
SCALA_SCALA_COMPILER_EXPECTED=87
77
DOTTY_COMPILER_EXPECTED=81
8-
SYNTAX_COMPLEXITY_CEILING=2300
8+
SYNTAX_COMPLEXITY_CEILING=2800
99

1010
if [ ! -d "$SCALA_SCALA_DIR" ]; then
1111
echo "\$SCALA_SCALA_DIR must be set"

0 commit comments

Comments
 (0)