@@ -38,9 +38,24 @@ private void Collect()
3838 }
3939 }
4040
41+ private Type OriginalType ( Type type )
42+ {
43+ if ( type is not CtorType ctorType )
44+ {
45+ return type ;
46+ }
47+ var originalTypeCtorDecl = Monomorphizer . GetOriginalDecl ( ctorType . Decl ) ;
48+ var actualTypeParams = program . monomorphizer . GetTypeInstantiation ( ctorType . Decl ) ;
49+ if ( actualTypeParams == null )
50+ {
51+ return type ;
52+ }
53+ return new CtorType ( Token . NoToken , originalTypeCtorDecl , actualTypeParams . Select ( t => OriginalType ( t ) ) . ToList ( ) ) ;
54+ }
55+
4156 private void Check ( )
4257 {
43- foreach ( var datatypeTypeCtorDecl in linearTypes . Keys . OfType < CtorType > ( ) . Select ( ctorType => ctorType . Decl ) . OfType < DatatypeTypeCtorDecl > ( ) )
58+ foreach ( var datatypeTypeCtorDecl in program . TopLevelDeclarations . OfType < DatatypeTypeCtorDecl > ( ) )
4459 {
4560 var originalTypeCtorDecl = Monomorphizer . GetOriginalDecl ( datatypeTypeCtorDecl ) ;
4661 var actualTypeParams = program . monomorphizer . GetTypeInstantiation ( datatypeTypeCtorDecl ) ;
@@ -50,15 +65,15 @@ private void Check()
5065 var innerType = actualTypeParams [ 0 ] ;
5166 if ( linearTypes . ContainsKey ( innerType ) )
5267 {
53- checkingContext . Error ( originalTypeCtorDecl , "One instantiated with a linear type" ) ;
68+ checkingContext . Error ( originalTypeCtorDecl , $ "One instantiated with a linear type: { OriginalType ( innerType ) } ") ;
5469 }
5570 }
5671 else if ( typeName == "Map" )
5772 {
5873 var keyType = actualTypeParams [ 0 ] ;
5974 if ( ! IsOneType ( keyType ) && linearTypes . ContainsKey ( keyType ) )
6075 {
61- checkingContext . Error ( originalTypeCtorDecl , "Map instantiated with a key type that is neither One _ nor ordinary" ) ;
76+ checkingContext . Error ( originalTypeCtorDecl , $ "Map instantiated with a key type that is neither One _ nor ordinary: { OriginalType ( keyType ) } ") ;
6277 }
6378 }
6479 }
0 commit comments