@@ -613,8 +613,15 @@ extends Importer:
613
613
case InfixApp (lhs : Ident , Keyword .`:`, rhs) =>
614
614
Param (FldFlags .empty, fieldOrVarSym(ParamBind , lhs), S (term(rhs))) :: Nil
615
615
case App (Ident (" ," ), list) => params(list)._1
616
- case TypeDef (Mod , inner, _, _) => param(inner)
617
- .map(p => p.copy(flags = p.flags.copy(mod = true )))
616
+ case TypeDef (Mod , inner, N , N ) =>
617
+ val ps = param(inner).map(p => p.copy(flags = p.flags.copy(mod = true )))
618
+ for p <- ps if p.flags.mod do p.sign match
619
+ case N =>
620
+ raise(ErrorReport (msg " Module parameters must have explicit types. " -> t.toLoc :: Nil ))
621
+ case S (ret) if ModuleChecker .isTypeParam(ret) =>
622
+ raise(ErrorReport (msg " Module parameters must have concrete types. " -> t.toLoc :: Nil ))
623
+ case _ => ()
624
+ ps
618
625
case TermDef (ImmutVal , inner, _) => param(inner)
619
626
620
627
def params (t : Tree ): Ctxl [(Ls [Param ], Ctx )] = t match
@@ -682,7 +689,15 @@ extends Importer:
682
689
while trav.changed do
683
690
trav.changed = false
684
691
go(s)
692
+
693
+ object ModuleChecker :
685
694
695
+ /** Checks if a term is a reference to a type parameter. */
696
+ def isTypeParam (t : Term ): Bool = t.symbol
697
+ .filter(_.isInstanceOf [VarSymbol ])
698
+ .flatMap(_.asInstanceOf [VarSymbol ].decl)
699
+ .fold(false )(_.isInstanceOf [TyParam ])
700
+
686
701
class VarianceTraverser (var changed : Bool = true ) extends Traverser :
687
702
override def traverseType (pol : Pol )(trm : Term ): Unit = trm match
688
703
case Term .TyApp (lhs, targs) =>
0 commit comments