@@ -884,7 +884,7 @@ pub fn resolve_name_res<'db>(
884884 ScopeId :: Item ( item) => match item {
885885 ItemKind :: Struct ( _) | ItemKind :: Contract ( _) | ItemKind :: Enum ( _) => {
886886 let adt_ref = AdtRef :: try_from_item ( item) . unwrap ( ) ;
887- PathRes :: Ty ( ty_from_adtref ( db, path, adt_ref, args) ?)
887+ PathRes :: Ty ( ty_from_adtref ( db, path, adt_ref, args, assumptions ) ?)
888888 }
889889
890890 ItemKind :: TopMod ( _) | ItemKind :: Mod ( _) => PathRes :: Mod ( scope_id) ,
@@ -915,18 +915,7 @@ pub fn resolve_name_res<'db>(
915915 ItemKind :: TypeAlias ( type_alias) => {
916916 let alias = lower_type_alias ( db, type_alias) ;
917917 let expected = alias. params ( db) . len ( ) ;
918- if args. len ( ) < expected {
919- PathRes :: TyAlias (
920- alias. clone ( ) ,
921- TyId :: invalid (
922- db,
923- InvalidCause :: UnboundTypeAliasParam {
924- alias : type_alias,
925- n_given_args : args. len ( ) ,
926- } ,
927- ) ,
928- )
929- } else if args. len ( ) > expected {
918+ if args. len ( ) > expected {
930919 return Err ( PathResError :: new (
931920 PathResErrorKind :: ArgNumMismatch {
932921 expected,
@@ -935,7 +924,26 @@ pub fn resolve_name_res<'db>(
935924 path,
936925 ) ) ;
937926 } else {
938- let instantiated = alias. alias_to . instantiate ( db, args) ;
927+ let completed = alias. param_set . complete_explicit_args_with_defaults (
928+ db,
929+ None ,
930+ args,
931+ assumptions,
932+ ) ;
933+ if completed. len ( ) < expected {
934+ return Ok ( PathRes :: TyAlias (
935+ alias. clone ( ) ,
936+ TyId :: invalid (
937+ db,
938+ InvalidCause :: UnboundTypeAliasParam {
939+ alias : type_alias,
940+ n_given_args : args. len ( ) ,
941+ } ,
942+ ) ,
943+ ) ) ;
944+ }
945+
946+ let instantiated = alias. alias_to . instantiate ( db, & completed) ;
939947 if let TyData :: Invalid ( InvalidCause :: TooManyGenericArgs {
940948 expected,
941949 given,
@@ -1035,7 +1043,7 @@ pub fn resolve_name_res<'db>(
10351043 } else {
10361044 // The variant was imported via `use`.
10371045 debug_assert ! ( path. parent( db) . is_none( ) ) ;
1038- ty_from_adtref ( db, path, var. enum_ . into ( ) , & [ ] ) ?
1046+ ty_from_adtref ( db, path, var. enum_ . into ( ) , & [ ] , assumptions ) ?
10391047 } ;
10401048 // TODO report error if args isn't empty
10411049 PathRes :: EnumVariant ( ResolvedVariant {
@@ -1073,10 +1081,15 @@ fn ty_from_adtref<'db>(
10731081 path : PathId < ' db > ,
10741082 adt_ref : AdtRef < ' db > ,
10751083 args : & [ TyId < ' db > ] ,
1084+ assumptions : PredicateListId < ' db > ,
10761085) -> PathResolutionResult < ' db , TyId < ' db > > {
10771086 let adt = lower_adt ( db, adt_ref) ;
10781087 let ty = TyId :: adt ( db, adt) ;
1079- let applied = TyId :: foldl ( db, ty, args) ;
1088+ // Fill trailing defaults (if any)
1089+ let completed_args =
1090+ adt. param_set ( db)
1091+ . complete_explicit_args_with_defaults ( db, None , args, assumptions) ;
1092+ let applied = TyId :: foldl ( db, ty, & completed_args) ;
10801093 if let TyData :: Invalid ( InvalidCause :: TooManyGenericArgs { expected, given } ) = applied. data ( db)
10811094 {
10821095 Err ( PathResError :: new (
0 commit comments