aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-02-03 10:27:39 +0100
committerHans Bolinder <[email protected]>2014-02-22 19:05:47 +0100
commit85a5aca047ea4c3dcdeb1e47cdf523a48140bf18 (patch)
tree48792bcd4ed41c9e8a974c1dc42f425dc8c0a970 /lib/dialyzer
parentf58b946a2d1c1b9c8fa9701932ca2ee21bd7dd5b (diff)
downloadotp-85a5aca047ea4c3dcdeb1e47cdf523a48140bf18.tar.gz
otp-85a5aca047ea4c3dcdeb1e47cdf523a48140bf18.tar.bz2
otp-85a5aca047ea4c3dcdeb1e47cdf523a48140bf18.zip
Introduce parameterized opaque types
Handle immediate opaque types as aliases: A declaration of dict/0 -opaque dict() :: dict(_, _). -opaque dict(Key, Value) :: ... is handled as an alias, that is, when using dict() it is immediately replaced by dict(_, _). This is a means to avoid having to handle equivalent opaque types later. To be changed if it doesn't work well.
Diffstat (limited to 'lib/dialyzer')
-rw-r--r--lib/dialyzer/src/dialyzer_contracts.erl6
-rw-r--r--lib/dialyzer/test/small_SUITE_data/results/contracts_with_subtypes16
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl
index 3467ab4e65..5b2c52b2d0 100644
--- a/lib/dialyzer/src/dialyzer_contracts.erl
+++ b/lib/dialyzer/src/dialyzer_contracts.erl
@@ -404,7 +404,8 @@ contract_from_form([{type, _, 'fun', [_, _]} = Form | Left], RecDict,
throw({error, NewMsg})
end,
NewType = erl_types:t_solve_remote(Type, ExpTypes, AllRecords),
- {NewType, []}
+ NewTypeNoVars = erl_types:subst_all_vars_to_any(NewType),
+ {NewTypeNoVars, []}
end,
NewTypeAcc = [TypeFun | TypeAcc],
NewFormAcc = [{Form, []} | FormAcc],
@@ -418,7 +419,8 @@ contract_from_form([{type, _L1, bounded_fun,
process_constraints(Constr, RecDict, ExpTypes, AllRecords),
Type = erl_types:t_from_form(Form, RecDict, VarDict),
NewType = erl_types:t_solve_remote(Type, ExpTypes, AllRecords),
- {NewType, Constr1}
+ NewTypeNoVars = erl_types:subst_all_vars_to_any(NewType),
+ {NewTypeNoVars, Constr1}
end,
NewTypeAcc = [TypeFun | TypeAcc],
NewFormAcc = [{Form, Constr} | FormAcc],
diff --git a/lib/dialyzer/test/small_SUITE_data/results/contracts_with_subtypes b/lib/dialyzer/test/small_SUITE_data/results/contracts_with_subtypes
index 173ff3a9f1..bfa33cd296 100644
--- a/lib/dialyzer/test/small_SUITE_data/results/contracts_with_subtypes
+++ b/lib/dialyzer/test/small_SUITE_data/results/contracts_with_subtypes
@@ -8,15 +8,15 @@ contracts_with_subtypes.erl:111: The call contracts_with_subtypes:rec_arg({'b',{
contracts_with_subtypes.erl:142: The pattern 1 can never match the type string()
contracts_with_subtypes.erl:145: The pattern 'alpha' can never match the type {'ok',_} | {'ok',_,string()}
contracts_with_subtypes.erl:147: The pattern 42 can never match the type {'ok',_} | {'ok',_,string()}
-contracts_with_subtypes.erl:163: The pattern 'alpha' can never match the type {'ok',X}
-contracts_with_subtypes.erl:165: The pattern 42 can never match the type {'ok',X}
-contracts_with_subtypes.erl:183: The pattern 'alpha' can never match the type {'ok',X}
-contracts_with_subtypes.erl:185: The pattern 42 can never match the type {'ok',X}
+contracts_with_subtypes.erl:163: The pattern 'alpha' can never match the type {'ok',_}
+contracts_with_subtypes.erl:165: The pattern 42 can never match the type {'ok',_}
+contracts_with_subtypes.erl:183: The pattern 'alpha' can never match the type {'ok',_}
+contracts_with_subtypes.erl:185: The pattern 42 can never match the type {'ok',_}
contracts_with_subtypes.erl:202: The pattern 1 can never match the type string()
-contracts_with_subtypes.erl:205: The pattern {'ok', _} can never match the type {'ok',X,string()}
-contracts_with_subtypes.erl:206: The pattern 'alpha' can never match the type {'ok',X,string()}
-contracts_with_subtypes.erl:207: The pattern {'ok', 42} can never match the type {'ok',X,string()}
-contracts_with_subtypes.erl:208: The pattern 42 can never match the type {'ok',X,string()}
+contracts_with_subtypes.erl:205: The pattern {'ok', _} can never match the type {'ok',_,string()}
+contracts_with_subtypes.erl:206: The pattern 'alpha' can never match the type {'ok',_,string()}
+contracts_with_subtypes.erl:207: The pattern {'ok', 42} can never match the type {'ok',_,string()}
+contracts_with_subtypes.erl:208: The pattern 42 can never match the type {'ok',_,string()}
contracts_with_subtypes.erl:234: Function flat_ets_new_t/0 has no local return
contracts_with_subtypes.erl:235: The call contracts_with_subtypes:flat_ets_new(12,[]) breaks the contract (Name,Options) -> atom() when is_subtype(Name,atom()), is_subtype(Options,[Option]), is_subtype(Option,'set' | 'ordered_set' | 'bag' | 'duplicate_bag' | 'public' | 'protected' | 'private' | 'named_table' | {'keypos',integer()} | {'heir',pid(),term()} | {'heir','none'} | {'write_concurrency',boolean()} | {'read_concurrency',boolean()} | 'compressed')
contracts_with_subtypes.erl:23: Invalid type specification for function contracts_with_subtypes:extract2/0. The success typing is () -> 'something'