Skip to content

Commit a4db9bf

Browse files
committed
relax assumptions on protocol contracts
fixes crash when dialyzer is able to infer concrete types
1 parent 6c84c34 commit a4db9bf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/language_server/lib/language_server/providers/code_lens/type_spec/contract_translator.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.TypeSpec.ContractTranslator
145145
Code.ensure_loaded?(mod) and function_exported?(mod, :__protocol__, 1) ->
146146
# defprotocol
147147
# defs in defprotocol do not have when and have at least 1 arg
148-
{:"::", [], [{:foo, [], [{:any, [], []} | rest]}, {:any, [], []}]} = ast
148+
{:"::", [], [{:foo, [], [_ | rest_args]}, res]} = ast
149149
# first arg in defprotocol defs is always of type t
150-
{:"::", [], [{:foo, [], [{:t, [], []} | rest]}, {:any, [], []}]}
150+
{:"::", [], [{:foo, [], [{:t, [], []} | rest_args]}, res]}
151151

152152
Code.ensure_loaded?(mod) and function_exported?(mod, :__impl__, 1) ->
153153
# defimpl

0 commit comments

Comments
 (0)