Skip to content

Commit 2de183e

Browse files
committed
Clear out patterns from types_test.exs and use aliases
1 parent cce861e commit 2de183e

File tree

3 files changed

+310
-325
lines changed

3 files changed

+310
-325
lines changed

lib/elixir/lib/module/types/expr.ex

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
defmodule Module.Types.Expr do
22
@moduledoc false
33

4-
alias Module.Types.Remote
5-
4+
alias Module.Types.{Remote, Pattern}
65
import Module.Types.{Helpers, Infer}
7-
import Module.Types.Pattern, only: [of_guard: 3, of_pattern: 3]
86

97
def of_expr(expr, %{context: stack_context} = stack, context) when stack_context != :expr do
108
of_expr(expr, %{stack | context: :expr}, context)
@@ -135,7 +133,7 @@ defmodule Module.Types.Expr do
135133
stack = push_expr_stack(expr, stack)
136134

137135
with {:ok, left_type, context} <-
138-
of_pattern(left_expr, stack, context),
136+
Pattern.of_pattern(left_expr, stack, context),
139137
{:ok, right_type, context} <- of_expr(right_expr, stack, context),
140138
do: unify(right_type, left_type, %{stack | context: :pattern}, context)
141139
end
@@ -400,9 +398,9 @@ defmodule Module.Types.Expr do
400398
defp for_clause({:<-, _, [left, expr]}, stack, context) do
401399
{pattern, guards} = extract_head([left])
402400

403-
with {:ok, _pattern_type, context} <- of_pattern(pattern, stack, context),
401+
with {:ok, _pattern_type, context} <- Pattern.of_pattern(pattern, stack, context),
404402
# TODO: Check that of_guard/3 returns a boolean
405-
{:ok, _guard_type, context} <- of_guard(guards_to_or(guards), stack, context),
403+
{:ok, _guard_type, context} <- Pattern.of_guard(guards_to_or(guards), stack, context),
406404
{:ok, _expr_type, context} <- of_expr(expr, stack, context),
407405
do: {:ok, context}
408406
end
@@ -428,7 +426,7 @@ defmodule Module.Types.Expr do
428426
end
429427

430428
defp for_option({:do, [{:->, _, [pattern, body]}]}, stack, context) do
431-
case of_pattern(pattern, stack, context) do
429+
case Pattern.of_pattern(pattern, stack, context) do
432430
{:ok, _pattern_type, context} -> of_expr_context(body, stack, context)
433431
{:error, reason} -> {:error, reason}
434432
end
@@ -441,9 +439,9 @@ defmodule Module.Types.Expr do
441439
defp with_clause({:<-, _, [left, expr]}, stack, context) do
442440
{pattern, guards} = extract_head([left])
443441

444-
with {:ok, _pattern_type, context} <- of_pattern(pattern, stack, context),
442+
with {:ok, _pattern_type, context} <- Pattern.of_pattern(pattern, stack, context),
445443
# TODO: Check that of_guard/3 returns a boolean
446-
{:ok, _guard_type, context} <- of_guard(guards_to_or(guards), stack, context),
444+
{:ok, _guard_type, context} <- Pattern.of_guard(guards_to_or(guards), stack, context),
447445
{:ok, _expr_type, context} <- of_expr(expr, stack, context),
448446
do: {:ok, context}
449447
end
@@ -472,9 +470,9 @@ defmodule Module.Types.Expr do
472470
{patterns, guards} = extract_head(head)
473471

474472
with {:ok, _pattern_types, context} <-
475-
map_reduce_ok(patterns, context, &of_pattern(&1, stack, &2)),
473+
map_reduce_ok(patterns, context, &Pattern.of_pattern(&1, stack, &2)),
476474
# TODO: Check that of_guard/3 returns a boolean
477-
{:ok, _guard_type, context} <- of_guard(guards_to_or(guards), stack, context),
475+
{:ok, _guard_type, context} <- Pattern.of_guard(guards_to_or(guards), stack, context),
478476
{:ok, _expr_type, _context} <- of_expr(body, stack, context),
479477
do: :ok
480478
end)

0 commit comments

Comments
 (0)